//Originally written by Fabian Portilla (rfportilla@yahoo.com)
//This script may be used as is or can be modified as long as
//you post this message on the top.  If you make changes, simply 
//add your signature and nothing else above mine.

function switch_display( chkboxId, elemId, dispstyleon, dispstyleoff ) {
// This function switches visibility for a section of HTML (typically a DIV) based on a checkbox
// Make sure you use ID names for your checkbox and the element you want to set visibility on
// Use the following line in onclick event of checkbox:
// switch_display( %Checkbox ID%, %DIV ID%, ['none' | 'inline'], ['none' | 'inline'] )
// Use the following line at the end of your form to make sure that you reconcile visibility 
// on refresh:
// <script language="javascript" type="text/javascript"> window.onload = function () {switch_display( %Checkbox ID%, %DIV ID%, [none | inline], [none | inline] );}

  var DivID = document.getElementById(elemId);
  var chkbox = document.getElementById(chkboxId);
  if (chkbox.checked) {
    DivID.style.display = dispstyleon;
  } else {
    DivID.style.display = dispstyleoff;
  }
}

function switch_display_rad( field, chkvalue, elemId, dispstyleon, dispstyleoff ) {
// Same as switch_display except on a radio button, it uses the input "name" attribute passed in as
// this.form."name" and compares with a chkvalue (desired selected radio for behavior).
// Use the following:
// switch_display_rad( this.form.%name%, %Check Value%, %DIV ID%, ['none' | 'inline'], ['none' | 'inline'] )
// Also, remember to use similar script line as above at the end of your form.
// switch_display_rad( document.%form_name%.%field_name%, %check Value%, %DIV ID%, ['none' | 'inline'], ['none' | 'inline'] )
  var DivID = document.getElementById(elemId);

  var checkvalue = get_rad_value (field)

  if (checkvalue == chkvalue) {
    DivID.style.display = dispstyleon;
  } else {
    DivID.style.display = dispstyleoff;
  }
}

function get_rad_value (field) {
  for (i=0, n=field.length; i<n; i++) {
    if (field[i].checked) {
      var checkvalue = field[i].value;
      break;
    }
  }
  return checkvalue;
}

	