<!---
// Clear Form
// 
// Requires that the form have a name (<form name="formName">)
//   OR use the THIS variable. So long as the form object is what is passed.
// 
// Usage:
//   formClear(formName,formName1,...,formNamex);
// Output: 
//   Clears the named form(s)
// 
// Usage: 
//   formClear();
// Output:
//   Clears all forms on the page
// 
function formClear() {
  // Cycle through all forms and call formClear()
  if (arguments.length==0) {
    for (n=0; n<document.forms.length; n++) {
      new formClear(document.forms[n]);
    }
  }
  else {
    for (n=0; n<arguments.length; n++) {
      var theForm = arguments[n];                   // Set the form
      for (i=0; i<theForm.elements.length; i++) {   // Clear form elements
        if (theForm.elements[i].type=="text" || theForm.elements[i].type=="hidden" || theForm.elements[i].type=="textarea") theForm.elements[i].value = '';
        else if (theForm.elements[i].type=="checkbox" || theForm.elements[i].type=="radio") theForm.elements[i].checked = false;
        else if (theForm.elements[i].type=="select-one") theForm.elements[i].selectedIndex = 0;
        else if (theForm.elements[i].type=="select-one" && theForm.elements[i].getAttribute("multiple")=="multiple") theForm.elements[i].selectedIndex = -1;
        else if (theForm.elements[i].type=="select-multiple") theForm.elements[i].selectedIndex = -1;
      }
    }
  }
}


// Set the background color of form elements
// 
// Requires that the form have a name (<form name="formName">)
//   OR use the THIS variable. So long as the form object is what is passed.
// 
// Usage:
//   formBGColor(formName,"color",formName1,"color1",...,formNameX,"colorX")
// Output: 
//   Changes form(s) element(s) background color
// 
// Usage: 
//   formBGColor.all();
// Output:
//   Changes all forms element(s) background color
// 
function formBGColor() {
  // Check that there are at least 2 and then an even number of parameters
  if ( arguments.length<2 || arguments.length/2!=Math.round(arguments.length/2) ) {
    alert('formBGColor() needs at least 2 and must have matching form/color parameters.\n\nformBGColor(formName,"color")');
    return false;
  }
  
  // Cycle through the given form/color pairs
  for (n=0; n<arguments.length; n++) {
    var theForm = arguments[n];
    n++;
    var color = arguments[n];
    for (i=0; i<theForm.elements.length; i++) {
      if (theForm.elements[i].type!="button") theForm.elements[i].style.background = color;
    }
  }
  
  // Cycle through all forms and call formBGColor()
  this.all = function(color) { // This still doesn't work
    for (n=0; n<document.forms.length; n++) {
      new formBGColor(document.forms[n],color);
    }
  }
}


// Change background color and clear value of form(s) element(s)
// 
// Usage:
//   formReset(form,"color",form1,"color1",...,formX,"colorX")
//   formReset.all()
// 
function formReset() {
  // Check that there are at least 2 and then an even number of parameters
  if ( arguments.length<2 || arguments.length/2!=Math.round(arguments.length/2) ) {
    alert('formReset() needs at least 2 and must have matching form/color parameters.\n\nformReset(formName,"color")');
    for (n=0; n<arguments.length; n++) {
      alert(arguments.length/2);
    }
    return false;
  }
  else {
    // Cycle through the given form/color pairs
    for (n=0; n<arguments.length; n++) {
      var theForm = arguments[n];
      n++;
      var color = arguments[n];
      new formClear(theForm);
      new formBGColor(theForm,color);
    }
  }
  
  this.all = function(color) { // This still doesn't work
    new formClear();
    new formBGColor.all(color);
  }
}

//--->