
  function fValidateRequired(pobjInputControl)	{

    // validates a input control to be filled out
	  var flgValidateOK = true;

    // only perform validation if the  Input control can be referenced
    if (pobjInputControl) {

		  pobjInputControl.style.backgroundColor = '';

        // get type of Input control: textbox or listbox
  		  var inputType  = pobjInputControl.type;
  		  var inputName = pobjInputControl.name;

        switch(inputType) {
          case "select":
            // multiselect listbox
            flgValidateOK = (pobjInputControl.options[pobjInputControl.selectedIndex] != -1);
            break;
            
          case "select-one":
            // single-select
            var intSelectedIndex = pobjInputControl.selectedIndex;

            flgValidateOK = (intSelectedIndex > 0);
            break;

          default:
            // in a textbox, directly access the value
    		    flgValidateOK = (trim(pobjInputControl.value).length > 0);
            break;
        } // switch

      // if validation fails, display error message
		  if (!flgValidateOK) {
      	window.alert(unescape("") );
      	pobjInputControl.style.backgroundColor = "FF9999";
			  markControl(pobjInputControl);
      } else {
        pobjInputControl.style.backgroundColor = "";
      }   // flgValidateOK

	  } //(pobjInputControl)

    return flgValidateOK;

  } // function

  function fValidateEmail(pobjInputControl) {

    var flgValidateOK;

    flgValidateOK = true;
      
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    // only perform validation if the  Input control can be referenced
    if (pobjInputControl) {

      if (pobjInputControl.value != '') {

        if (reg.test(pobjInputControl.value) == false) {
     
          window.alert(pobjInputControl.value + unescape("... ") );
          pobjInputControl.style.backgroundColor = "FF9999";
          markControl(pobjInputControl);
          flgValidateOK = false;
        } else {
          pobjInputControl.style.backgroundColor = "";
        }   // backgroundColor
      
      }
    }  // pobjInputControl
    return flgValidateOK;
  }   // fValidateEmail

  function fValidateNumber(pobjInputControl) {

    var flgValidateOK;

    flgValidateOK = true;
      
    var reg = /^-?[0-9]+$/;

    // only perform validation if the  Input control can be referenced
    if (pobjInputControl) {

      if (pobjInputControl.value != '') {

        if (reg.test(pobjInputControl.value) == false) {
     
          window.alert(pobjInputControl.value + unescape("... ") );
          pobjInputControl.style.backgroundColor = "FF9999";
          markControl(pobjInputControl);
          flgValidateOK = false;
        } else {
          pobjInputControl.style.backgroundColor = "";
        }   // backgroundColor
      
      }
    }  // pobjInputControl

    return flgValidateOK;
  }   // fValidateNumber


  function fValidateDate(pobjInputControl) {

    var flgValidateOK;

    flgValidateOK = true;

    var reg1 = /^+$/;
    var reg2 = /^+$/;
    var reg3 = /^+$/;

    // only perform validation if the  Input control can be referenced
    if (pobjInputControl) {

      if (pobjInputControl.value != '') {

        if ((reg1.test(pobjInputControl.value) == false) && (reg2.test(pobjInputControl.value) == false) && (reg3.test(pobjInputControl.value) == false)) {

          window.alert(pobjInputControl.value + unescape('... , (' + '' + ')'));
          pobjInputControl.style.backgroundColor = "FF9999";
          markControl(pobjInputControl);
          flgValidateOK = false;
        } else {
        pobjInputControl.style.backgroundColor = "";
        }   // backgroundColor
      } // pobjInputControl.value

    }  // pobjInputControl

    return flgValidateOK;
  }   // fValidateDate

function trim(str) {
  // strips off leading and trailing whitespace from a string
  str = str.replace (/^\s+/g, "");
  str = str.replace (/\s+$/g, "");
  return str;
}

function markControl(control) {
  // move the focus to a control, and select its content. The problem is:
  // if a control is invisible or disabled, the .focus and .select
  // methods cause errors.

  if ((control.type != "hidden")
     && (control.style["visibility"] != "hidden")
     && (control.getAttribute("disabled") != true)
     && (control.style["display"] != "none")) {
    try {
      if (control.focus)
        control.focus();
      if (control.select)
       control.select();
    }
    finally {
      return true;
    }
  }
  return true;
}

