
  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;

        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;
        }

        // if validation fails, display error message
		if (!flgValidateOK) {
      		pobjInputControl.style.backgroundColor = "FF9999";
      		alert("Required Field");
			markControl(pobjInputControl);
		} // flgValidateOK

	} //(pobjInputControl)

    return flgValidateOK;

  } // function


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;
}






























































