<!-- Hide script

function ShowHideElement (elementID, showhide) {
  // showhide: 1 = visible, 0 = hidden
  var obj = document.layers ? document.layers[elementID] :
  document.getElementById ? document.getElementById(elementID).style : document.all[elementID].style;
  document.getElementById ? document.getElementById(elementID).display : document.all[elementID].display;
  obj.visibility = document.layers ? (showhide ? "show" : "hide") : (showhide ? "visible" : "hidden");
  obj.display = document.layers ? (showhide ? "" : "none") : (showhide ? "" : "none");
}


// Removes leading and trailing spaces from the passed string. Also removes
// consecutive spaces and replaces it with one space. If something besides
// a string is passed in (null, custom object, etc.) then return the input.
function trim(inputString) {
  if (typeof inputString != "string") { return inputString; }
  var retValue = inputString;
  var ch = retValue.substring(0, 1);
  while (ch == " ") { // Check for spaces at the beginning of the string
    retValue = retValue.substring(1, retValue.length);
    ch = retValue.substring(0, 1);
  }
  ch = retValue.substring(retValue.length-1, retValue.length);
  while (ch == " ") { // Check for spaces at the end of the string
    retValue = retValue.substring(0, retValue.length-1);
    ch = retValue.substring(retValue.length-1, retValue.length);
  }
  while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
    retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
  }
  return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


// set the value of a form SELECT input type by value
function setFormIndexbyValue(elementName, inValue) {
  // alert ("elementName = " + elementName + ", inValue = " + inValue);
  var count = elementName.length, ndx;
  for (ndx = 0; ndx < count; ++ndx) {
    if (inValue == elementName.options[ndx].value) {
      // Found a match
      elementName.options[ndx].selected = true;
      elementName.selectedIndex = ndx;  // Needed for Netscape but not IE
      // alert ("true for " + elementName + " matching value " + inValue);
      return true;
    }
  }
  return false;
}


// populate the form's tags by text value
function setFormValue(elementName, inValue) {
  document.getElementById(elementName).value = inValue;
}


// Returns true if a digit else returns false
function isDigit(c) {
  return ((c >= "0") && (c <= "9"))
}


//////////////////////////////////////////////////////////
// Checks whether a string contains a double byte character
// target = the string to be checked
//
// Return true if target contains a double byte char; false otherwise
//////////////////////////////////////////////////////////
function containsDoubleByte (target) {
     var str = new String(target);
     var oneByteMax = 0x007F;

     for (var i=0; i < str.length; i++){
        chr = str.charCodeAt(i);
        if (chr > oneByteMax) {return true;}
     }
     return false;
}


//////////////////////////////////////////////////////////
// A simple function to validate an email address
// It does not allow double byte characters
// strEmail = the email address string to be validated
//
// Return true if the email address is valid; false otherwise
//////////////////////////////////////////////////////////
function isValidEmail(strEmail) {
  // check if email contains dbcs chars
  if (containsDoubleByte(strEmail)){
    return false;
  }

  if (strEmail.length == 0) {
    // This function allows for empty email values
    // Add logic in the original validation function to check for no value and disallow there if required
    return true;
  } else if (strEmail.length < 5) {
    return false;
  } else {
    if (strEmail.indexOf(" ") > 0) {
      return false;
    } else {
      if (strEmail.indexOf("@") < 1) {
        return false;
      } else {
        if (strEmail.lastIndexOf(".") < (strEmail.indexOf("@") + 2)) {
          return false;
        } else {
          if (strEmail.lastIndexOf(".") >= strEmail.length - 2) {
            return false;
          }
        }
      }
    }
  }
  return true;
}


// end hide -->
