  // Form validation functions for required fields

	  // Global for all functions
	  var FormError;
	  var ErrorMsg;

  // Trim white-space
  function RTrim(theString)
  {
    var start = 0;
    var end = theString.length - 1;
    var trimming = true;

    while ( trimming && end >= start )
    {
      if ( theString.charAt(end) == " " )
      { end--; }
      else
      { trimming = false; }
    }
    if ( end < 0 ) { end = 0; }
    return theString.substring(start,end + 1);
  }
  
  // Check if blank or null
  function IsBlank(value) {
  
  	if ((value == null) || (RTrim(value) == ""))
		return true;
	else
		return false;  	
  }
  
  // Check input, select and textarea fields for input
  function CheckInputField(theField, theMessage) {
		
		if (IsBlank(theField.value)) {
		  if (!FormError) theField.focus();  
		  FormError = true;
		  ErrorMsg += "\n    " + theMessage;
		}
  }
  
  // Check radio array for input
  function CheckRadioField(theField, theMessage) {
		
		// check for input in array
		var hasInput = false;
		for (i=0;i<theField.length;i++)
		{
			if (theField[i].checked)
			{
				hasInput = true;
			}
		}		
		
		if (! hasInput) {
		  if (!FormError) theField[0].focus();  
		  FormError = true;
		  ErrorMsg += "\n    " + theMessage;
		}
  }
  
  function CheckCheckBox(theField, theMessage){
			if (theField.checked == false) {
		  if (!FormError) theField.focus();  
		  FormError = true;
		  ErrorMsg += "\n    " + theMessage;
		}
  }