// JavaScript source file for RA BBS.
// Copyright Ray Chien 2003, all rights reserved.

// Settings for the input field


// Just_Execute: Disables the object (as a button) and submits the form it belongs to.
// arguments:
//     rep = name of the object in the form.
// - This only supports W3C
function Just_Execute(rep){
  if (document.getElementById){
     rep.disabled = true;

     rep.form.submit();
  }
}

// checkSize: not really 'check' but changes the SIZE attribute of the object to fit the current value.
// arguments:
//     field = name of the object (must have SIZE attribute)
//     mins = minimum size
//     maxs = maximum size
//
function checkSize(field, mins, maxs){
  mysize = field.value.length;
  if (mysize < mins){ mysize = mins;  }
  if (mysize > maxs){ mysize = maxs;  }

  field.size = mysize;
}

// checkRow: not really 'check' but changes the ROWS attribute of the object to fit the current value.
// arguments:
//     field = name of the object (must have ROWS and COLS attributes)
//     min1 = minimum size
//     max1 = maximum size
//     pad = # of extra line to add to the estimated required lines.
//
function checkRow(field, min1, max1, pad){

mygosh = field.value.split(/\n/);
// Width of textfield in letters.
wpl = field.cols;

var getrows = pad;
var len = 0;

for (var a=0; a<mygosh.length; a++){
  interm = mygosh[a].split(/ /);
  len = 0;
  getrows++;
  for (var b=0; b<interm.length; b++){
    len += interm[b].length + 1;
    if (len > wpl){
       getrows++;
       len = interm[b].length + 1;
    }
  }
}
if (getrows < min1) {  getrows = min1;	}
if (getrows > max1){  getrows = max1;  }

field.rows = getrows;

//Not sure?  Check this.
//mystatus = 'Width=' + wpl + ', Current=' + len + ', Rows=' + getrows + '(' + mygosh.length + ')(' + interm.length + ')';
//window.status = mystatus;
}

// ShowHelper
// Shows the helper document in a separate window.
function ShowHelper(){

window.open('../templates/searchoptions.htm','helper','width=300, height=500, toolbar=no, menubar=no, scrollbars=yes, resizable=yes');

}
