  // Statusbar Clock //////////////////
  function runClock() {
      theTime = window.setTimeout("runClock()", 1000);
      var today = new Date();
      var display = today.toLocaleString();
      status = display;
  }
  runClock();
  /////////////////////////////////////
  
  // Select By Value //////////////////
  function selectByValue() {
    var a = selectByValue.arguments;
    for (var x=0;x<a.length;x+=2) {
      for (var i=0;i<document.thisForm.elements[a[x]].options.length;i++) {
        if (document.thisForm.elements[a[x]].options[i].value == a[x+1] ) {
          document.thisForm.elements[a[x]].selectedIndex = i;
          break;  
        }
      }
    }
  }
  /////////////////////////////////////

/*------------------------------------------------------------
  ** validateForm(form) - v1.2.1 *****************************
  ------------------------------------------------------------
  Description:
    Loops through all elements within a form and validates
    each element with the specified validation type.
    Validation types are dervived from the CLASS of the
    element in the form. See below for valid classes.
  -------------------------------
  Valid Classes (NOTE: Classes are case insensitive):
    - Required
    - IPAddress
    - CreditCard
    - URL
    - Stringthen 
    - eMail
    - Zip
    - Number
  ---------------------------------------------------------*/
 function validateForm(strForm) {
  /******************************
  ** Begin User Customization
  ******************************/
  // --- Options: Define various preferences below ---
  var arrOptions = new Array();
  arrOptions["ErrorStyle"] = "Error"; // Default style to add to field when in error state (NOTE: Value is Case Sensitive)
  arrOptions["Prefix"] = 0; // Default number of places to remove from the prefix of each field name. Used to remove any coding styles such as "tUserName" or "txtUserName"

  // --- Language: Define your error messages below ---
  var arrLanguage = new Array();
  arrLanguage["header"] = "The following error(s) occured:";
  arrLanguage["start"] = "  · The field ";
  arrLanguage["required"] = " is a required field";
  arrLanguage["ip"] = " must contain a valid IP address. Example: 127.0.0.1";
  arrLanguage["creditcard"] = " must contain a valid credit card number";
  arrLanguage["url"] = " must contain a valid URL with its prefix. Example: http://www.xyzcompany.com";
  arrLanguage["string"] = " contains invalid characters";
  arrLanguage["email"] = " must contain a valid e-mail address";
  arrLanguage["zip"] = " must contain a valid zip code";
  arrLanguage["number"] = " must contain a numeric value";
  /******************************
  ** End User Customization
  ******************************/
  var strErrors = "";
  // --- Update 'ErrorStyle' if values were passed with the form ---
  if (strForm.elements["_ErrorStyle"]) {
    arrOptions["ErrorStyle"] = strForm.elements["_ErrorStyle"].value;
  }
  // --- Update 'Prefix' if values were passed with the form ---
  if (strForm.elements["_Prefix"]) {
    arrOptions["Prefix"] = strForm.elements["_Prefix"].value;
  }

  // --- Validate form elements ---
  for (i=0; i<strForm.length; i++) {
    var strObj = strForm.elements[i];
    var blnVerified = false;
    // --- Check required fields ---
    if (strObj.className.toLowerCase().indexOf("required") != -1 && blnVerified == false) {
      if (IsEmpty(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['required'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true; }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check for a valid IP ---
    if (strObj.className.toLowerCase().indexOf("ipaddress") != -1 && blnVerified == false) {
      if (!IsIpAddressValid(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['ip'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check for a valid Credit Card Number ---
    if (strObj.className.toLowerCase().indexOf("creditcard") != -1 && blnVerified == false) {
      if (!IsCreditCardNumberValid(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['creditcard'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check if URL is valid ---
    if (strObj.className.toLowerCase().indexOf("url") != -1 && blnVerified == false) {
      if (!IsURLValid(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['url'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check for invalid characters in the string ---
    if (strObj.className.toLowerCase().indexOf("string") != -1 && blnVerified == false) {
      if (!IsStringValid(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['string'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check for valid e-mail address ---
    if (strObj.className.toLowerCase().indexOf("email") != -1 && blnVerified == false) {
      if (!IsEmailValid(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['email'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check for valid Zip code ---
    if (strObj.className.toLowerCase().indexOf("zip") != -1 && blnVerified == false) {
      if (!IsZipCodeValid(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['zip'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
    // --- Check for numeric value ---
    if (strObj.className.toLowerCase().indexOf("number") != -1 && blnVerified == false) {
      if (isNaN(strObj.value)) { strErrors += arrLanguage['start'] + '\"' + strObj.name.substring(arrOptions["Prefix"],strObj.name.length).toUpperCase() + '\"' + arrLanguage['number'] + "\n"; strObj.className += " " + arrOptions["ErrorStyle"]; blnVerified = true }
      else { removeClassName(strObj,arrOptions["ErrorStyle"]); }
    }
  }
  if (strErrors) {
    alert(arrLanguage["header"].concat("\n" + strErrors));
    strErrors = "";
    return false;
  } else {  
    return true;
  }
}
// ------------------------------------------------------------

// ------------------------------------------------------------
// Validate GUID (eg.{C0763051-A67E-4b18-AD02-2DDA9FA2AD03})
// ------------------------------------------------------------
function IsGuidValid (strGuid) {
   if (strGuid.length > 38)
      return false;

   return (Boolean)
   (/\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}?/.test
   (strGuid));
}

// ------------------------------------------------------------
// Validate zip code. The proper format is xxxxx or xxxxx-xxxx
// ------------------------------------------------------------
function IsZipCodeValid (strZip) {
  if (StringTrim(strZip)) {
    return (Boolean) (/^\d{5}$|^\d{5}-\d{4}$/.test (strZip));
  } else {
    return true;
  }
}

// ------------------------------------------------------------
// Validate e-mail. The proper format is xxxx@xxxx.xxx or
// xxxx@xxxx.xxxxx.xxx, or xxxx.xxxx@xxxx.xxxx.xxx, etc
// ------------------------------------------------------------
function IsEmailValid (strEmail) {
  if (StringTrim(strEmail)) {
    return (Boolean) (/^[\w-\.]+@[\w-\.]+\.(\w+)$/.test (strEmail));
  } else {
    return true;
  }
}

// ------------------------------------------------------------
// Validate data. See if data contains any invalid characters.
// ------------------------------------------------------------
function IsStringValid (strData) {
  //if (StringTrim(strData)) {
  //  return (Boolean) (!(/[^\w\-\s\u00C0-\u0259\u0388-\u04E9\u1E80-\u1EF9']/.test (strData)));
  //} else {
    return true;
  //}
}

// ------------------------------------------------------------
// Validate URL.
// ------------------------------------------------------------
function IsURLValid (strURL) {
  if (StringTrim(strURL)) {
    return (Boolean) (/^(http|ftp):\/\/(www\.)?.+\.(\w+)(\/)?$/.test (strURL));
  } else {
    return true;
  }
}

// ------------------------------------------------------------
// Trim leading and tralining spaces
// ------------------------------------------------------------
function StringTrim (strStr) {
  if (strStr == null)
      return "";

  strStr = strStr.replace (/^\s+/, "");
  strStr = strStr.replace (/\s+\$/, "");
  return strStr;
}

// ------------------------------------------------------------
// Validate credit card number
// ------------------------------------------------------------
function IsCreditCardNumberValid (strNum) {
  if (StringTrim(strNum)) {
    return (Boolean) (/^\d{4}[\s]*\d{4}[\s]*\d{4}[\s]*\d{4}$/.test (strNum));
  } else {
    return true;
  }
}

// ------------------------------------------------------------
// Validate IP address
// ------------------------------------------------------------
function IsIpAddressValid (strIp) {
  if (StringTrim(strIp)) {
    var arrMatch, i;
    arrMatch = /(\d+)\.(\d+)\.(\d+)\.(\d+)/.exec (strIp);

    // --- If there is no match, just leave ---
    if (arrMatch == null)
        return false;

    // --- Make sure every octet is not larger than 255 ---
    for (i=1; i<=arrMatch[i]; i++) {
      if ((Number) (arrMatch[i]) > 255)
        return false;
    }
  }
  return true;
}

// ------------------------------------------------------------
// Check if a string is empty
// ------------------------------------------------------------
function IsEmpty (strStr) {
  return (Boolean) (strStr == null || (String) (StringTrim (strStr)).length == 0);
}

// ------------------------------------------------------------
// Remove the given class name from the element's className property
// ------------------------------------------------------------
function removeClassName(el, name) {
  var i, curList, newList;
  if (el.className == null)
    return;
  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}