<!-- Begin to hide script contents from old browsers.

///////////////////////////////////////////////////////////////////////////////
//
// IntToChar
//
//   Return "char" value for the given int.  (Note: A - z only)
//
///////////////////////////////////////////////////////////////////////////////

var CharArray = new Array(
 "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T",
 "U","V","W","X","Y","Z","","","","","","",
 "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t",
 "u","v","w","x","y","z");

function IntToChar(intValue) {

  if ( intValue < 65 || intValue > 122 ) {
    return "";
  }

  var adjIntValue = intValue - 65;

  return CharArray[adjIntValue];
}

///////////////////////////////////////////////////////////////////////////////
//
// IsZipcode: check if valid US zip code (##### or #####-####)
//
///////////////////////////////////////////////////////////////////////////////

function IsZipcode(strZip) {
  var strLeft="", strRight="", strVal = new String(strZip);

  if (IsEmpty(strVal))
      return true;
  if (IsWhitespace(strVal))
      return false;

  if (strVal.length != 5 && strVal.length != 10)
      return false;

  if ((strVal.length == 5) && IsDigit(strVal))
      return true;

  if ((strVal.length == 10) && IsDigit(strVal.substring(0, 5)) && 
                      IsDigit(strVal.substring(6)))
      return true;

  return false;
}

///////////////////////////////////////////////////////////////////////////////
//
// IsDatePart: check if nVal is valid day: 1-31, month:1-12, year:YYYY
//
///////////////////////////////////////////////////////////////////////////////

function IsDatePart(nVal, strType) {
  var strBuffer = new String(nVal);

  if (IsEmpty(strBuffer) || IsWhitespace(strBuffer))
      return false;
  
  nVal = parseInt(strBuffer);
  if (!IsDigit(nVal))
      return false;

  if ((strType == "Year") && (nVal < 0 || (nVal > 99 && nVal < 1000) || nVal > 9999))
      return false;
  else if ((strType == "Month") && (nVal < 1 || nVal > 12))
      return false;
  else if ((strType == "Day") && (nVal < 1 || nVal > 31))
      return false;

  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateDate
//
// Check if object is a valid date
//
// Valid formats:  MM (or) M / DD (or) D / Y (or) YY (or) YYYY
//                 YY > 40 should be 19YY
//                 YY <= 40 should be 20YY
// 
// Input:          obj     - form object
//                 minDate - Minimum date (MM/DD/YYYY)
//
// Return:         true / false
//                 change obj.value to (MM/DD/YYYY) if it is valid, otherwise
//                 clear obj.value
//
///////////////////////////////////////////////////////////////////////////////

function ValidateDate(obj,minDate) {
  obj.value = RemoveSpaces(obj.value);
  var strBuffer= new String(obj.value);
  var cDelimiter='';
  var strMonth=0, strDay=0, strYear=0;
  var nPos=-1;

  if (IsEmpty(strBuffer))
    return true;
  if (IsWhitespace(strBuffer)) {
    //obj.value = '';
    return false;
  }

  // Get the delimiter used
  if (Occurs('/', strBuffer) == 2)
    cDelimiter = '/';
  else if (Occurs('-', strBuffer) == 2)
    cDelimiter = '-';

  // If no '/' or '-' found return false
  if (cDelimiter == '') {
    //obj.value = '';
    return false;
  }

  // validate month, date, and year (Y, YY, YYYY are valid year formats)
  nPos = strBuffer.indexOf(cDelimiter);
  strMonth = strBuffer.substring(0, nPos);
  if (strMonth.length > 2 || !IsDigit(strMonth)) {
    //obj.value = '';
    return false;
  }

  strBuffer = strBuffer.substring(nPos+1);
  nPos = strBuffer.indexOf(cDelimiter);
  strDay = strBuffer.substring(0, nPos);
  if (strDay.length > 2 || !IsDigit(strDay)) {
    //obj.value = '';
    return false;
  }

  strBuffer = strBuffer.substring(nPos+1);
  strYear = strBuffer;
  if ((strYear.length > 4) || (strYear.length == 3) || !IsDigit(strYear)) {
    //obj.value = '';
    return false;
  }

  // if YY < 40 then YYYY=20YY, else if YY >= 40 then YYYY=19YY
  var iYear = parseInt(strYear,10);
  if (iYear < 40)
    strYear = "20" + (iYear < 10 ? '0' + iYear:iYear);
  else if (iYear >= 40 && iYear < 100)
    strYear = "19" + strYear;

  // Pad month if less than 10
  var iMon = parseInt(strMonth,10);
  strMonth = (iMon < 10 ? '0' + iMon:iMon);

  // Pad days if less than 10
  var iDay = parseInt(strDay,10);
  strDay = (iDay < 10 ? '0' + iDay:iDay);

  strBuffer = strMonth + '/' + strDay + '/' + strYear;

  // validate date
  var dBuffer = new Date(strBuffer);
  if (dBuffer.getDate() != parseInt(strDay,10) ||
        dBuffer.getMonth()+1 != parseInt(strMonth,10) ||
        dBuffer.getFullYear() != parseInt(strYear,10)) {
    //obj.value = '';
    return false;
  }

  // Check to see if the date is before the minimum date if one is specified
  if ( minDate != null && minDate != '' ) {
    var minStrBuffer= new String(minDate);

    // validate month, date, and year (Y, YY, YYYY are valid year formats)
    nPos = minStrBuffer.indexOf('/');
    minStrMonth = minStrBuffer.substring(0, nPos);

    minStrBuffer = minStrBuffer.substring(nPos+1);
    nPos = minStrBuffer.indexOf('/');
    minStrDay = minStrBuffer.substring(0,nPos);

    minStrBuffer = minStrBuffer.substring(nPos+1);
    minStrYear = minStrBuffer;

    if ( strYear < minStrYear ) {
      //obj.value = '';
      return false;
    } else if ( strYear == minStrYear ) {
      if ( strMonth < minStrMonth ) {
        //obj.value = '';
        return false;
      } else if ( strMonth == minStrMonth ) {
        if ( strDay < minStrDay ) {
          //obj.value = '';
          return false;
        }
      }
    }
  }

  obj.value = strBuffer;
  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateDay
//
// Check if given day is valid based on the year and month provided
//
// Valid formats:  DD (or) D
//                 MM (or) M 
//                 Y (or) YY (or) YYYY
//                 YY > 40 should be 19YY
//                 YY <= 40 should be 20YY
// 
// Input:          day, month, year
//
// Return:         true / false
//                 change dayObj.value to (DD) if it is valid, otherwise
//                 clear value
//
///////////////////////////////////////////////////////////////////////////////

function ValidateDay(dayObj, month, year) {
  dayObj.value = RemoveSpaces(dayObj.value);
  var strDay= new String(dayObj.value);

  if (IsEmpty(strDay))
    return true;
  if (IsWhitespace(strDay)) {
    obj.value = '';
    return false;
  }

  var strMonth = new String(month);
  if (strMonth.length > 2 || !IsDigit(strMonth)) {
    dayObj.value = '';
    return false;
  }

  var strYear = new String(year);
  if ((strYear.length > 4) || (strYear.length == 3) || !IsDigit(strYear)) {
    dayObj.value = '';
    return false;
  }

  // if YY < 40 then YYYY=20YY, else if YY >= 40 then YYYY=19YY
  var iYear = parseInt(strYear,10);
  if (iYear < 40)
    strYear = "20" + (iYear < 10 ? '0' + iYear:iYear);
  else if (iYear >= 40 && iYear < 100)
    strYear = "19" + strYear;

  // Pad month if less than 10
  var iMon = parseInt(strMonth,10);
  strMonth = (iMon < 10 ? '0' + iMon:iMon);

  // Pad days if less than 10
  var iDay = parseInt(strDay,10);
  strDay = (iDay < 10 ? '0' + iDay:iDay);

  var strBuffer = strMonth + '/' + strDay + '/' + strYear;

  // validate date
  var dBuffer = new Date(strBuffer);
  if (dBuffer.getDate() != parseInt(strDay,10) ||
        dBuffer.getMonth()+1 != parseInt(strMonth,10) ||
        dBuffer.getFullYear() != parseInt(strYear,10)) {
    dayObj.value = '';
    return false;
  }

  dayObj.value = strDay;
  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// CheckDate
//
// Check if object is a valid date. If it is not, then popup an alert message
//
// Input:          obj     - form object
//
///////////////////////////////////////////////////////////////////////////////

function CheckDate(obj) {
  if ( !ValidateDate( obj, '' ) ) {
    alert("Invalid Date      ");
    obj.focus();
  }
}

///////////////////////////////////////////////////////////////////////////////
//
// CheckDay
//
// Check if object is a valid day based on the given month and year
//
// Input:          dayObj     - form "text" object
//
///////////////////////////////////////////////////////////////////////////////

function CheckDay(dayObj,month,year) {
  if ( !ValidateDay( dayObj,month,year ) ) {
    alert("Invalid Day  ");
    dayObj.focus();
  }
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateField
//
// NOTE: 
//  -- always RemoveSpaces field value before calling any of these functions
//  -- if field is empty, the function call will return true
//
// Parameters:  objFld - Field reference
//              strType - "Integer" | "Float" | "Zip" | "Date" | "DatePartYear" | "Digit"
//              showAlert - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateField(objFld, strType, showAlert) {
  objFld.value = RemoveSpaces(objFld.value);
  if (IsEmpty(objFld.value))
      return true;

  // Remove commas from Integer and Float fields
  if ((strType == "Integer") || (strType == "Float"))
      objFld.value = ReplaceAll(objFld.value, ",", "");

  if ((strType == "Digit") && !IsDigit(objFld.value)) {
    if (showAlert) {
      alert("Please enter a response in numerical format\n(please " + 
            "exclude dollar signs, commas, parenthesis, etc.)     ");
      //objFld.value = "";
      objFld.focus();
    }
    return false;
  }

  if (strType == "Integer") {
    if (!IsInteger(parseInt(objFld.value))) {
      if (showAlert) {
        alert("Please enter a response in numerical format\n(please " + 
              "exclude dollar signs, commas, parenthesis, etc.)     ");
        //objFld.value = "";
        objFld.focus();
      }
      return false;
    }
  }

  if (strType == "Float") {
    if (!IsFloat(parseFloat(objFld.value))) {
      if (showAlert) {
        alert("Please enter a response in numerical format\n(please " + 
              "exclude dollar signs, commas, parenthesis, etc.)     ");
        //objFld.value = "";
        objFld.focus();
      }
      return false;
    }
  }

  if (strType == "Zip") {
    if (!IsZipcode(objFld.value)) {
      if (showAlert) {
        alert("Please enter valid zip code value     ");
        //objFld.value = "";
        objFld.focus();
      }
      return false;
    }
  }

  if (strType == "Date") {
    if (!ValidateDate(objFld)) {
      if (showAlert) {
        alert("Please enter valid date value (MM/DD/YYYY)     ");
        //objFld.value = "";
        objFld.focus();
      }
      return false;
    }
  }

  if (strType == "DatePartYear" && ValidateField(objFld, "Digit")) {
    if (!IsDatePart(objFld.value, "Year")) {
      if (showAlert) {
        alert("Please enter valid year value     ");
        //objFld.value = "";
        objFld.focus();
      }
      return false;
    } else if (objFld.value < 100)
      objFld.value = (objFld.value < 50 ? 2000:1900) + parseInt(objFld.value);
  }

  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateRange
//
//   Check the range of the field value.
//
// Parameters:  objFld - Field reference
//              fLower - Inclusive lower boundary
//              fUpper - Inclusive upper boundary
//              showAlert - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateRange(objFld, fLower, fUpper, showAlert) {
  var fVal = 0.0;

  if (IsEmpty(objFld.value)) {
    return true;
  }

  fVal = parseFloat(objFld.value);

  if ((fVal >= fLower) && (fVal <= fUpper))
    return true;

  if ( fLower == fUpper ) {
    if (showAlert)
      alert("Value can only be " + fUpper + "     ");
  } else if ( fUpper < fLower ) {
    if (showAlert)
      alert("There is no valid value that can be specified     ");
  } else {
    if (showAlert)
      alert("Value needs to be between " + fLower + " and " + fUpper + "     ");
  }

  if (showAlert) {
    //objFld.value = "";
    objFld.focus();
  }

  return false;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateMinValue
//
//   Check to see if the field value is greater than the minimum value
//
// Parameters:  objFld - Field reference
//              minVal - Minimum value
//              showAlert - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateMinValue(objFld, minVal, showAlert) {
  var fVal = 0.0;

  if (IsEmpty(objFld.value))
    return true;
  if (!IsFloat(objFld.value))
    return false;

  fVal = parseFloat(objFld.value);

  if (fVal >= minVal)
    return true;

  if (showAlert) {
    alert("Value needs to be greater than or equal to " + minVal + "     ");
    //objFld.value = "";
    objFld.focus();
  }

  return false;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateLength
//
//   Check the length of the field value.
//
// Parameters:  objFld - Field reference
//              strType - field type ( Digit, Char )
//              minLength - Min length
//              maxLength - Max length
//              showAlert - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateLength(objFld, strType, minLength, maxLength, showAlert) {

  var strVal = new String(objFld.value);
  var displayType;

  if ( strType == "Digit" ) {
    displayType = "digits";
  }
  else {
    displayType = "characters";
  }

  if (strVal.length < minLength) {
    if (showAlert) {
      alert("Minimum number of " + displayType + " required is " + minLength + ".     ");
      //objFld.value = "";
      objFld.focus();
    }
    return false;
  }

  if (strVal.length > maxLength) {
    if (showAlert) {
      alert("Maximum number of " + displayType + " allowed is " + maxLength + ".     ");
      //objFld.value = "";
      objFld.focus();
    }
    return false;
  }

  return true;
}


///////////////////////////////////////////////////////////////////////////////
//
// ConvertNumber
//
// The following function is used to convert a value to a number to a specified precision.
//
// Input:  Number or String
//         Precision
//
// Return: Rounded number as a string
//
///////////////////////////////////////////////////////////////////////////////

function ConvertNumber(objFld, precision) {

  if ( IsEmpty( objFld.value ) ) {
    objFld.value = '0.00';
  }

  if (!IsFloat(parseFloat(objFld.value))) {
    objFld.value = "0.00";
  } else {
    objFld.value = FormatNumber( objFld.value, precision );
  }

  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateEmail
//
// Email address must be of form a@b.c i.e., there must be at least one
// character before the '@' there must be at least one character before and
// after the '.' the characters '@' and '.' are both required.
// 
// Parameters:  objFld     - Field reference
//              showAlert  - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateEmail(objFld, showAlert) {

  var strInvalid = "*?#&^~`'\\[]<>;/:\" ";
  var bAliasedEmail = false;
  var strAliasedEmail="";
  var i = 0, bValid = true;

  objFld.value = RemoveSpaces(objFld.value);
  if (IsEmpty(objFld.value))
    return true;

  var strEmail = new String(objFld.value);

  // Assumption: if strEmail contains < and >, Email is between < and >
  if (strEmail.indexOf('<') < strEmail.indexOf('>') && strEmail.indexOf('<') >= 0) {
    bAliasedEmail = true;
    strAliasedEmail = strEmail;
    strEmail = strEmail.substring(strEmail.indexOf('<')+1, 
        strEmail.indexOf('>'));
  }

  if (strEmail.length < 5)  // check the length
    bValid = false;
  else if (strEmail.lastIndexOf("@") <= 0 ||            // check positions of @ and .
           (strEmail.lastIndexOf(".") - strEmail.lastIndexOf("@") <= 1))
    bValid = false;
  else if (Occurs('@', strEmail) > 1) // check if @ occurs more than once
    bValid = false
  else {  // check if any invalid characters present
    for (i = 0; i < strEmail.length; i++) {
      if (strInvalid.indexOf(strEmail.charAt(i)) >= 0) {
        bValid = false;
        break;
      }
    }
  }
  
  if (!bValid) {
    if (showAlert) {
      alert("Please enter a valid email address     ");
      //objFld.value = "";
      objFld.focus();
    }
    return bValid;
  }
  if (bAliasedEmail)
    objFld.value = strAliasedEmail;
  else
    objFld.value = strEmail;

  return bValid;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateFormat
//
// Validate the format to make sure it matches the given format string and length
//
//   Valid values  a | A => Alphabetical character
//                 #     => Number
//                 *     => Either a alphabetical character or a number
//
// Parameters:  objFld - Field reference
//              formatStr - Format string (a|#) Example "aa##"
//              showAlert - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateFormat(objFld,format,showAlert) {

  var alphaValid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var numValid = "0123456789";
  var str = new String(RemoveSpaces(objFld.value));
  var strLength = str.length;
  var formatStr = new String(format);
  var formatLength = formatStr.length;
  var i = 0, bValid = true;
  var alphaOk, numOk;

  if (IsEmpty(str))
    return true;

  if (strLength != formatLength) {
    if (showAlert) {
      alert("Value must be in the following format '" + formatStr + "'     ");
      //objFld.value = "";
      objFld.focus();
    }
    return false;
  }

  for (i = 0; i < strLength; i++) {
    if (formatStr.charAt(i) == 'a' || formatStr.charAt(i) == 'A') {
      if (alphaValid.indexOf(str.charAt(i)) < 0) {
        bValid = false;
        break;
      }
    } else if (formatStr.charAt(i) == '#') {
      if (numValid.indexOf(str.charAt(i)) < 0) {
        bValid = false;
        break;
      }
    } else {
      alphaOk = false;
      numOk = false;
      if (alphaValid.indexOf(str.charAt(i)) >= 0)
        alphaOk = true;
      if (numValid.indexOf(str.charAt(i)) >= 0)
        numOk = true;
      if (!alphaOk && !numOk) {
        bValid = false;
        break;
      }
    }
  }

  if (!bValid) {
    if (showAlert) {
      alert("Value must be in the following format '" + formatStr + "'     ");
      //objFld.value = "";
      objFld.focus();
    }
    return false;
  }

  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateCharacters
//
// Validate the string to make sure it matches the given character formats
//
//   Valid values  a | A => All alphabetical characters
//                 #     => All Numbers
//                 *     => Any specific character
//
// Parameters:  objFld - Field reference
//              validChars - Valid characters: Example "a#_"
//              showAlert - true | false (Show alert message)
//
///////////////////////////////////////////////////////////////////////////////

function ValidateCharacters(objFld,validChars,showAlert) {

  var alphaValid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var numValid = "0123456789";
  var str = new String(RemoveSpaces(objFld.value));
  var strLength = str.length;
  var validStr = new String(validChars);
  var validLength = validStr.length;
  var i = 0, valid = true;
  var alphaOk = false, numOk = false;

  if (IsEmpty(str))
    return true;

  if (validStr.indexOf("a") >= 0 || validStr.indexOf("A") >= 0)
    alphaOk = true;

  if (validStr.indexOf("#") >= 0)
    numOk = true;

  for (i = 0; i < strLength; i++) {
    if (!((alphaOk && alphaValid.indexOf(str.charAt(i)) >= 0) ||
          (numOk && numValid.indexOf(str.charAt(i)) >= 0) ||
          (validStr.indexOf(str.charAt(i)) >= 0))) {
        valid = false;   
        break;
    }
  }

  if (!valid) {
    if (showAlert) {
      alert("Value can only be following characters '" + validStr + "'     ");
      objFld.focus();
    }
    return false;
  }

  objFld.value = str;
  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ValidateInputType
//
//   Validate input types
//
// Parameters:  objField   - Field reference
//              inputType  - "Text" | "Select" | "Radio"
//              showAlert  - true | false (Show alert message)
//
// Return:      true or false
//
///////////////////////////////////////////////////////////////////////////////

function ValidateInputType(objField,inputType,desc,showAlert) {
  var strVal;
  strVal = "";

  if (inputType == "Text") {
    strVal = objField.value;
  }
  else if (inputType == "Radio") {
    var iLen = objField.length;
    for (var iEle = 0; iEle < iLen; iEle++)
      if (objField[iEle].checked) {
        strVal = objField[iEle].value;						
        break;					
      }
  }
  else if (inputType == "Select") {
    var iIdx = objField.selectedIndex;
    if (iIdx > -1)
      strVal = objField[iIdx].value;
    else
      strVal = "";
  }

  strVal = RemoveSpaces(strVal);

  if (strVal == "") {
    if (showAlert) {
      alert("Please enter a value for " + desc + "     ");
      if (inputType == "Radio")
        objField[0].focus();
      else
        objField.focus();
    }
    return false;
  }

  return true;
}

///////////////////////////////////////////////////////////////////////////////
//
// ProcessErrorMessages
//
//   Show alert box with error messages
//
// Parameters:  errors   - Array of error strings
//
// Return:      true or false based on whether the error array has values
//
///////////////////////////////////////////////////////////////////////////////

function ProcessErrorMessages(errors) {
  var errorMsg = "";
  var errorCount = 0;

  for (i = 0; i < errors.length; i++) {
    if (!IsEmpty(errors[i])) {
      errorCount++;
      errorMsg += "*  " + errors[i] + "      \n";
    }
  }

  if (errorCount > 0) {
    alert(errorMsg);
  } else {
    return true;
  }
}

// End the hiding here. -->
