/************************************************
DESCRIPTION: Validates required fields for order forms

PARAMETERS:
   form to validate

RETURNS:
   True if valid, alert window with errors if false.
*************************************************/


/************************************************
DESCRIPTION: Validates that a string is a United
  States zip code in 5 digit format or zip+4
  format. The following are acceptable:
    12345
    12345-1234
    12345+1234
    12345 1234
    123451234

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.
*************************************************/
function validateUSZip(strValue) {
    if (strValue.search(/(^\d{5}$)|(^\d{5}-\d{4}$)|(^\d{5}\+\d{4}$)|(^\d{5}\W+\d{4}$)|(^\d{9}$)/) == -1) return false;
    return true;
}

/************************************************
DESCRIPTION: Checks if a string is empty

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid (empty), otherwise false (not empty).
*************************************************/
function validateIsEmpty(strValue) {
    if (strValue == undefined) return false;
    strValue = strValue.trim();
    if(strValue.length > 0) return false;
    return true;
}

/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
function trimString (strValue) {
    strValue = this != window? this : strValue;
    return strValue.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

// Added as a method to the String.prototype
String.prototype.trim = trimString;
