var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var whitespace = " \t\n\r";
var charsInSocialSecurityNumber = 11;
var charsInUSPhoneNumber = 13;
var validDateDelimiters = "/";
var creditCardDelimiters = " ";
var mPrefix = "You did not enter a value into the ";
var mSuffix = " field. This is a required field. Please enter it now.";
var iStateCode = "The state must be a valid two character U.S. state abbreviation (Example: CA for California). Please make the appropriate correction and re-submit.";
var iCanadianStateCode = "The province must be a valid two character Canadian Province abbreviation (Example: AB for Alberta). Please make the appropriate correction and re-submit.";
var iMexicanStateCode = "The state must be a valid two character Mexican state code abbreviation (Example: BJ for Baja California Norte). Please make the appropriate correction and re-submit.";
var iUSZIPCode = "The zip code must be a 5 or 10 character U.S. ZIP Code (for example 93536 or 93536-6702). Please make the appropriate correction and re-submit.";
var iCanadianPostalCode = "The postal code must be a valid Canadian Postal Code (for example K1A OB1). Please make the appropriate correction and re-submit.";
var iMexicanPostalCode = "The postal code must be a valid Mexican Postal Code (for example 23465). Please make the appropriate correction and re-submit.";
var iUSPhone = "The telephone number must be a 12 character U.S./Canadian phone number (for example '415-555-1212'). Please make the appropriate correction and re-submit.";
var iMXPhone = "The telephone number must be a 12 character Mexican phone number (for example '415-555-1212' or '12-1234-1234'). Please make the appropriate correction and re-submit.";
var iUSFax = "The fax number must be a 12 character U.S./Canadian fax number (for example, '415-555-1212'). Please make the appropriate correction and re-submit.";
var iWorldPhone = "The telephone number must be a valid international phone number consisting of an optional '+' followed by numbers. Please make the appropriate correction and re-submit.";
var iWorldFax = "The fax number must be a valid international fax number consisting of an optional '+' followed by numbers. Please make the appropriate correction and re-submit.";
var iSSN = "The social security number must be a 9 digit U.S. social security number (for example 123-45-6789). Please make the appropriate correction and re-submit.";
var iEmail = "The email address must be a valid email address (for example name@company.com). Please make the appropriate correction and re-submit.";
var iCreditCardPrefix = "This is not a valid ";
var iCreditCardSuffix = " credit card number. Please make the appropriate correction and re-submit.";
var iDate = "This value must be a valid date between the years 1900 and 9999 inclusive in MM/DD/YYYY format (for example 04/25/2000). Please make the appropriate correction and re-submit.";
var iDay = "This value must be a day number between 1 and 31.  Please make the appropriate correction and re-submit.";
var iMonth = "This value must be a month number between 1 and 12.  Please make the appropriate correction and re-submit.";
var iYear = "This value must be a 4 digit year number between the years 1900 and 9999 inclusive.  Please make the appropriate correction and re-submit.";
var iDatePrefix = "The Day, Month, and Year for ";
var iDateSuffix = " do not form a valid date.  Please reenter them now.";
var iAlphabetic = " field can only contain alphabetic characters. (Example: a..z, A..Z)";
var iAlphanumeric = " field can only contain alpha-numeric characters. (Example: a..z, A..Z, 0..9)"; 
var iSingleQuote = " field cannot contain single quotes. Please reenter it now!";
var iDoubleQuote = " field cannot contain double quotes. Please reenter it now!";
var iNumeric = " This field must contain a numeric value.";
var iCorrection = " Please make the appropriate correction and re-submit.";
var iUS5DigitZipCode = "This field must contain US Zip codes in 5 digit format (EG: 92660)";
var iSelect = " is a required field. Please select an entry now.";
var iUSFederalTaxID = "This value must be a 10 character U.S. FedTax ID (for example 12-3456789)";
var iURL = "This value must be a valid URL (for example http://www.pipelinesoftware.com/).";
var iContractRefNumber = "This value must be a 15 digit character.(for example ##AAA####A##### (where A is Alphabetic and # is an Integer).Please make the appropriate correction and re-submit.";
var iStringLength = "The length of the data in this field should not be less than ";
var iFloatRange = "This field must contain an integer number between ";
var iFloatLessThan = "This field must contain an integer number less than or equal to ";
var iFloatGreaterThan = "This field must contain an integer number greater than or equal to ";
var daysInMonth = new Array(0,31,29,31,30,31,30,31,31,30,31,30,31);
var USStateCodeDelimiter = "|";
var USStateCodes = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP";
var CanadianStateCodes = "AB|BC|MB|NB|NF|NT|NS|ON|PE|QC|SK|YT";
var MexicanStateCodes = "AG|BJ|BS|CP|CH|CU|CL|CI|DF|DG|GJ|GR|HG|JA|EM|MH|MR|NA|NL|OA|PU|QA|QR|SL|SI|SO|TA|TM|TL|VL|YC|ZT";
function isNull(val){val += "";if(val=="null"||val==""||val=="undefined"){return true;}else{return false;}}
function isEmpty(s){return ((s == null) || (s.length == 0));}
function replaceSubString(theStr, oldSubStr, newSubStr){var buffer = "";var ch = "";for (var i = 0; i < theStr.length; i++){ch = theStr.substring(i, i + oldSubStr.length);if (ch != oldSubStr){buffer += theStr.substring(i, i+1);}else{buffer += newSubStr;i += oldSubStr.length - 1;}}return buffer;}
function isWhitespace (s){var reWhitespace = /^\s+$/
return (isEmpty(s) || reWhitespace.test(s));}
function stripCharsInRE (s, bag){return s.replace(bag, "");}
function stripCharsInBag (s, bag){var i;var returnString = "";for (i = 0; i < s.length; i++){var c = s.charAt(i);if (bag.indexOf(c) == -1){returnString += c;}}return returnString;}
function stripCharsNotInBag (s, bag){var i;var returnString = "";for (i = 0; i < s.length; i++){var c = s.charAt(i);if (bag.indexOf(c) != -1) {returnString += c;}}return returnString;}
function stripWhitespace (s){return stripCharsInBag (s, whitespace);}
function stripInitialWhitespace (s){var i = 0;while ((i < s.length) && (whitespace.indexOf(s.charAt(i)) != -1)){i++;}return s.substring (i, s.length);}
function checkForWhiteSpace(val){if(val.indexOf(' ') == -1)	{return true;}else{return false;}}
function isLetter (c){var reLetter = /^[a-zA-Z]$/
return reLetter.test(c);}
function isDigit (c){var reDigit = /^\d/
return reDigit.test(c);}
function isLetterOrDigit (c){var reLetterOrDigit = /^([a-zA-Z]|\d)$/
return reLetterOrDigit.test(c);}
function isInteger (s, emptyOK){var reInteger = /^\d+$/
if (isEmpty(s)){return (emptyOK == true);}else{return reInteger.test(s);}}
function isSignedInteger (s, emptyOK){var reSignedInteger = /^(\+|-)?\d+$/
if (isEmpty(s)){return (emptyOK == true);}else{return reSignedInteger.test(s);}}
function isPositiveInteger (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return (isSignedInteger(s, emptyOK)&& ((isEmpty(s) && emptyOK)  || (parseInt(s,10) > 0)));}}
function isNonnegativeInteger (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return (isSignedInteger(s, emptyOK)&& ((isEmpty(s) && emptyOK)  || (parseInt(s,10) >= 0)));}}
function isNegativeInteger (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return (isSignedInteger(s, emptyOK)&& ((isEmpty(s) && emptyOK)  || (parseInt(s,10) < 0)));}}
function isNonpositiveInteger (s, emptyOK)
{if (isEmpty(s)){return (emptyOK == true);}else{return (isSignedInteger(s, emptyOK)&& ((isEmpty(s) && emptyOK)  || (parseInt(s,10) <= 0)));}}
function isFloat (s, emptyOK){var reFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/
if (isEmpty(s)){return (emptyOK == true);}else{return reFloat.test(s);}}
function isSignedFloat (s, emptyOK){var reSignedFloat = /^(((\+|-)?\d+(\.\d*)?)|((\+|-)?(\d*\.)?\d+))$/
if (isEmpty(s)){return (emptyOK == true);}else{return reSignedFloat.test(s);}}
function isAlphabetic (s, emptyOK){var reAlphabetic = /^[a-zA-Z]+$/
if (isEmpty(s)){return (emptyOK == true);}else{return reAlphabetic.test(s);}}
function isAlphanumeric (s, emptyOK){var reAlphanumeric = /^[a-zA-Z0-9]+$/
if (isEmpty(s)){return (emptyOK == true);}else{return reAlphanumeric.test(s);}}
function isUSFedTaxID (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return ((s.length == 10)&& isInteger(s.substring(0,2))&& (s.substring(2,3) == "-")&& isInteger(s.substring(3,10)));}}	
function isURL (sURL, emptyOK){var allOK = true;if ((sURL == null) || (sURL == "")){allOK = (emptyOK == true);}else{if((sURL.toLowerCase().substring(0,7) != "http://")&& (sURL.toLowerCase().substring(0,8) != "https://")){allOK = false;}else{var firstPeriod = sURL.indexOf(".");var nextPeriod = sURL.substring(firstPeriod + 1).indexOf(".");var nextSlash = sURL.substring(nextPeriod + 1).indexOf("/");allOK = ((firstPeriod != -1) && (nextPeriod != -1) && (nextSlash != -1));}}return allOK;}
function reformat (s){var arg;var sPos = 0;var resultString = "";for (var i = 1; i < reformat.arguments.length; i++){arg = reformat.arguments[i];if (i % 2 == 1){resultString += arg;}else{resultString += s.substring(sPos, sPos + arg);sPos += arg;}}return resultString;}
function isSSN (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return ((s.length == 11)&& isInteger(s.substring(0,3))&& (s.substring(3,4) == "-")&& isInteger(s.substring(4,6))&& (s.substring(6,7) == "-")&& isInteger(s.substring(7)));}}
function isUSPhoneNumber (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return ((s.length == 12)&& isInteger(s.substring(0,3))&& (s.substring(3,4) == "-")&& isInteger(s.substring(4,7))&& (s.substring(7,8) == "-")&& isInteger(s.substring(8)));}}
function isInternationalPhoneNumber (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return (isPositiveInteger(s));}}
function isUSZIPCode (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{if(s.length == 5){return isInteger(s);}else if(s.length == 10){return (isInteger(s.substring(0,5))&& (s.substring(5,6) == "-")&& isInteger(s.substring(6)));}else{return false;}}}
function isUS5DigitZIPCode (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{if(s.length == 5){return isInteger(s);}else{return false;}}}
function isEmail (s, emptyOK){var reEmail = /^.+\@.+\..+$/
if (isEmpty(s)){ return (emptyOK == true); }else{ if(checkForWhiteSpace(s)){ return reEmail.test(s);}else{ return false;}}}
function isYear (s, emptyOK){if(isEmpty(s)){return (emptyOK == true);}else{if(!isNonnegativeInteger(s)){return false;}else{return((s.length==4)&&isIntegerInRange(s,1900,9999,emptyOK));}}}
function isIntegerInRange (s, a, b, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{if(!isInteger(s, false)){return false;}var num = parseInt(s,10);return ((num >= a) && (num <= b));}}
function isMonth (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return isIntegerInRange (s, 1, 12);}}
function isDay (s, emptyOK){if(isEmpty(s)){return (emptyOK == true);}else{return isIntegerInRange (s, 1, 31);}}
function daysInFebruary (year){return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);}
function isValidDate (year, month, day){if(!(isYear(year, false) && isMonth(month, false) && isDay(day, false))){return false;}var intYear = parseInt(year,10);var intMonth = parseInt(month,10);var intDay = parseInt(day,10);if(intDay > daysInMonth[intMonth]){return false;}if((intMonth == 2) && (intDay > daysInFebruary(intYear))){return false;}return true;}
function isDate (s, emptyOK){if (isEmpty(s)){return (emptyOK == true);}else{return (isValidDate(s.substring(6), s.substring(0,2), s.substring(3,5))&& (validDateDelimiters.indexOf(s.substring(2,3)) != -1)&& (s.substring(2,3) == s.substring(5,6)));}}
function prompt (s){window.status = s;}
function promptEntry (s){window.status = pEntryPrompt + s;}
function warnEmpty (theField, s){theField.focus();alert(mPrefix + s + mSuffix);return false;}
function warnInvalid (theField, s){theField.focus();theField.select();alert(s);return false;}
function checkAlphabetic(theField, s, emptyOK){var tempStr = theField.value;if(isAlphabetic(tempStr, emptyOK)){return true;}else{alert(s + iAlphabetic);theField.focus();return false;}}
function checkAlphanumeric(theField, s, emptyOK){var tempStr = theField.value;if(isAlphanumeric(tempStr, emptyOK)){return true;}else{alert(s + iAlphanumeric );return false;}}
function checkForSingleQuote(theField, s){var tempStr = theField.value;if(tempStr.indexOf("'") == -1){return true;}else{alert( s + iSingleQuote);return false;}}
function checkForDoubleQuote(theField, s){var tempStr = theField.value;if(tempStr.indexOf('"') == -1){return true;}else{alert( s + iDoubleQuote);return false;}}
function checkForAsterisk(theField, s){	var tempStr = theField.value;if(tempStr.indexOf('*') == -1)	{return true;}else{	alert("The " + s + " field cannot contain asterisk. Please reenter it now!");return false;}}
function checkForTilde(theField, s){var tempStr = theField.value;if(tempStr.indexOf('~') == -1)	{return true;}else{	alert("The " + s + " field cannot contain tilde. Please reenter it now!");return false;}}
function checkFloat(theField, emptyOK, min, max){if (isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iNumeric+iCorrection);}}var doCheckMin = false;var doCheckMax = false;if (!isNull(min)){doCheckMin = true;}if (!isNull(max)){doCheckMax = true;}if(!isSignedFloat(theField.value, false)){return warnInvalid (theField, iNumeric+iCorrection);}else{var num = parseFloat(theField.value);var isValid = true;if (doCheckMin){isValid = (num >= min);}if (isValid && doCheckMax){isValid = (num <= max);}if (!isValid){var msg = "";if (doCheckMin && doCheckMax){msg = iFloatRange + min + " - " + max + ". "+iCorrection;}else if (doCheckMax){msg = iFloatLessThan + max  + "."+iCorrection;}else if (doCheckMin){msg = iFloatGreaterThan + min  + "."+iCorrection;}return warnInvalid(theField, msg);}else{return true;}}}
function checkInteger(theField, emptyOK, min, max){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iNumeric+iCorrection);};}var doCheckMin = false;var doCheckMax = false;if(!isNull(min)){doCheckMin = true;}if(!isNull(max)){doCheckMax = true;}if(!isSignedInteger(theField.value, false)){return warnInvalid(theField, iNumeric+iCorrection);}else{var num = parseInt(theField.value,10);var isValid = true;if(doCheckMin){isValid = (num >= min);}if(doCheckMax && isValid){isValid = (num <= max);}if (!isValid){var msg = "";if(doCheckMin && doCheckMax){msg = iFloatRange+ min + " - " + max + ". "+iCorrection;}else if(doCheckMax){msg = iFloatLessThan + max  + "."+iCorrection;}else if(doCheckMin){msg = iFloatGreaterThan + min  + "."+iCorrection;}return warnInvalid(theField, msg);}else{return true;}}}
function checkFloatWithScale(theField, emptyOK, min, max, scale){if (isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, "This field must contain a numeric value. Please reenter it now.");}}if(checkFloat(theField, emptyOK, min, max)){var theValue = parseFloat(theField.value);var roundedValue = Math.round(theValue * Math.pow(10, scale)) / Math.pow(10, scale);if(roundedValue != theValue){return warnInvalid (theField, "This field must contain a numeric value to " + scale + " decimal places. Please reenter it now.");}else{return true;}}}
function checkString(theField, s, emptyOK){if (isEmpty(theField.value)){if(emptyOK){return true;}else{return warnEmpty (theField, s);}}else{if(isWhitespace(theField.value)){return warnEmpty (theField, s);}else{return true;}}}
function checkStringLength(theField, fldName, minLength, emptyOK){ var str = theField.value;if (isEmpty(str)){return emptyOK;}else{if (str.length < minLength){msg = iStringLength + minLength+ ".\n"+iCorrection;warnInvalid(theField, msg);return false;}else{return true;}}}
function checkUSStateCode(theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iStateCode);}}else{theField.value = theField.value.toUpperCase();if(!isStateCode(theField.value, false)){return warnInvalid (theField, iStateCode);}else{return true;}}}
function checkStateCode(theField, country, emptyOK){theField.value=theField.value.toUpperCase();uCountry = country.toUpperCase();var allOK = true;switch (uCountry){case "UNITED STATES OF AMERICA" : if(!isStateCode(theField.value, emptyOK)){warnInvalid (theField, iStateCode);allOK = false;}break;case "CANADA" : if(!isCanadianStateCode(theField.value, emptyOK)){warnInvalid (theField, iCanadianStateCode);allOK = false;}break;	case "MEXICO" : if(!isMexicanStateCode(theField.value, emptyOK)){warnInvalid (theField, iMexicanStateCode);allOK = false;}break;default :if(isEmpty(theField.value) && !emptyOK){alert("This field must contain a valid State code for " + country + ". Please make the appropriate correction and re-submit.");theField.focus();allOK = false;}}return allOK;}
function checkPostalCode(theField, country, emptyOK){uCountry = country.toUpperCase();var allOK = true;switch (uCountry){case "UNITED STATES OF AMERICA" : if(!isUSZIPCode(theField.value, emptyOK)){warnInvalid (theField, iUSZIPCode);allOK = false;}break;case "CANADA" : if(!isCanadianPostalCode(theField.value, emptyOK)){warnInvalid (theField, iCanadianPostalCode);allOK = false;}break;	case "MEXICO" : if(!isMexicanPostalCode(theField.value, emptyOK)){warnInvalid (theField, iMexicanPostalCode);	allOK = false;}break;default :if(isEmpty(theField.value) && !emptyOK){alert("This field must contain a valid postal code for " + country + ". Please make the appropriate correction and re-submit.");theField.focus();allOK = false;}}return allOK;}
function checkUS5DigitZipCode(theField, emptyOK){if(!isUS5DigitZIPCode(theField.value, emptyOK)){warnInvalid (theField, iUS5DigitZipCode);return false;}else{return true;}}
function checkPhone(theField, country, emptyOK){uCountry = country.toUpperCase();var allOK = true;switch (uCountry){case "UNITED STATES OF AMERICA" : if(!isUSPhoneNumber(theField.value, emptyOK)){warnInvalid (theField, iUSPhone);allOK = false;}break; case "CANADA" : if(!isUSPhoneNumber(theField.value, emptyOK)){warnInvalid (theField, iUSPhone);allOK = false;}break; case "MEXICO" :if(!isMXPhoneNumber(theField.value, emptyOK)) {warnInvalid (theField, iMXPhone);allOK = false;}break; default :if(!isInternationalPhoneNumber(theField.value, emptyOK)){warnInvalid (theField, iWorldPhone);allOK = false;}}return allOK;}
function checkFax (theField, country, emptyOK){uCountry = country.toUpperCase();var allOK = true;switch (uCountry){case "UNITED STATES OF AMERICA" : if(!isUSPhoneNumber(theField.value, emptyOK)){warnInvalid (theField, iUSFax);allOK = false;}break;case "CANADA" : if(!isUSPhoneNumber(theField.value, emptyOK)){warnInvalid (theField, iUSFax);allOK = false;}break;default :if(!isInternationalPhoneNumber(theField.value, emptyOK)){warnInvalid (theField, iWorldFax);allOK = false;}}return allOK;}
function checkUSPhone(theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iUSPhone);}}else{if(!isUSPhoneNumber(theField.value, false)){ return warnInvalid (theField, iUSPhone);}else {return true;}}}
function checkInternationalPhone (theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iWorldPhone);}}else{if(!isInternationalPhoneNumber(theField.value, false)){return warnInvalid (theField, iWorldPhone);}else{return true;}}}
function checkEmail (theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iEmail);}}else if (!isEmail(theField.value, false)){return warnInvalid (theField, iEmail);}else{return true;}}
function checkSSN (theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iSSN);}}else{if(!isSSN(theField.value, false)){ return warnInvalid (theField, iSSN);}else {return true;}}}
function checkYear (theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iYear);}}else{if(!isYear(theField.value, false)){ return warnInvalid (theField, iYear);}else{return true;}}}
function checkMonth (theField, emptyOK){if(isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iMonth);}}else{if(!isMonth(theField.value, false)){return warnInvalid (theField, iMonth);}else{return true;}}}
function checkDay (theField, emptyOK){if (isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, iDay);}}else{if(!isDay(theField.value, false)){return warnInvalid (theField, iDay);}else{return true;}}}
function formatDate(dateField){var dateToFormat = new Date(dateField);var tempMonth = "0" + (dateToFormat.getMonth()+1);var tempDate = "0" + dateToFormat.getDate();var newDateString = tempMonth.substring(tempMonth.length-2)+"/"+tempDate.substring(tempDate.length-2)+"/"+dateToFormat.getFullYear();return newDateString;}
function addToDate(dateFieldValue, daysToAdd){var presentDate = new Date(dateFieldValue);var newDate = new Date();var newTime = presentDate.getTime()+(daysToAdd*24*60*60*1000);newDate.setTime(newTime);return formatDate(newDate);}
function checkDate (dateField, emptyOK){if(isEmpty(dateField.value)){if(emptyOK){return true;}else{return warnInvalid (dateField, iDate);}}else {if(!isDate(dateField.value, emptyOK)){return warnInvalid (dateField, iDate);}else{return true;}}}
function checkSelectBox(theField, s, idx){if (theField.selectedIndex >= idx){return true;}else{alert(theField.name+iSelect);return false;}}
function checkFedTaxID (theField, country, emptyOK){uCountry = country.toUpperCase();var allOK = true;switch (uCountry){case "UNITED STATES OF AMERICA" : if(!isUSFedTaxID(theField.value, emptyOK)){warnInvalid (theField, iUSFederalTaxID);allOK = false;}break;default:{allOK = true;}break;}return allOK;}
function checkTextLength(txtElement, fldName, maxLength){var str = txtElement.value;if (str.length > maxLength){msg = "The length of the data in the '" + fldName + "' field exceeds the maximum length of " + maxLength + " characters." + "\nPlease correct this and submit your form again. " + "The following text marks the max length:" + "\n\n\t< ** MAX LENGTH IS HERE **";str = str.substring(0, maxLength) + "< ** MAX LENGTH IS HERE **" + str.substring(maxLength, str.length);txtElement.value = str;warnInvalid(txtElement, msg);return false;}else{return true;}}
function checkURL(theField, emptyOK){var msg = iURL+iCorrection;if (isEmpty(theField.value)){if(emptyOK){return true;}else{return warnInvalid (theField, msg);}}else {if (!isURL(theField.value, emptyOK)){return warnInvalid (theField, msg);}else{return true;}}}
function getPopupWinHandle(loc, width, height, resizable, scrollbars, toolbar, dependent, winName){var win = eval("window.open(loc, '"	+ winName + "','width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",dependent=" + dependent + ",status=no,location=no')");return win;}
function popupWin(loc, width, height, resizable, scrollbars, toolbar, dependent, winName){var newWin = getPopupWinHandle(loc, width, height, resizable, scrollbars, toolbar, dependent, winName);}
function getRadioButtonValue(radio){if(isNull(radio.length)){return radio.value;}else{for(var i=0;i<radio.length;i++){if(radio[i].checked){break;}}return radio[i].value;}}
function checkCreditCard (cardTypeSelectField, cardNumberField){var cardType = cardTypeSelectField.options[cardTypeSelectField.selectedIndex].value;var normalizedCCN = stripCharsInBag(cardNumberField.value, creditCardDelimiters);if(!isCardMatch(cardType, normalizedCCN)){return warnInvalid (cardNumberField, iCreditCardPrefix + cardType + iCreditCardSuffix);}else {cardNumberField.value = normalizedCCN;return true;}}
function isCreditCard(st){if(st.length > 19){return false;}sum = 0;mul = 1;l = st.length;for (i = 0; i < l; i++){digit = st.substring(l-i-1,l-i);tproduct = parseInt(digit,10)*mul;if (tproduct >= 10){sum += (tproduct % 10) + 1;}else{sum += tproduct;}if (mul == 1){mul++;}else{mul--;}}if ((sum % 10) == 0){return (true);}else{return (false);}}
function isVisa(cc){if (((cc.length == 16) || (cc.length == 13)) && (cc.substring(0,1) == "4")){return isCreditCard(cc);}else{return false;}}
function isMasterCard(cc){firstdig = cc.substring(0,1);seconddig = cc.substring(1,2);if ((cc.length == 16) && (firstdig == "5") &&((parseInt(seconddig,10) >= 1) && (parseInt(seconddig,10) <= 5))){return isCreditCard(cc);}else{return false;}}
function isAmericanExpress(cc){firstdig = cc.substring(0,1);seconddig = cc.substring(1,2);if ((cc.length == 15) && (firstdig == "3") &&((seconddig == "4") || (seconddig == "7"))){return isCreditCard(cc);}else{return false;}}
function isDinersClub(cc){firstdig = cc.substring(0,1);seconddig = cc.substring(1,2);if ((cc.length == 14) && (firstdig == "3") &&((seconddig == "0") || (seconddig == "6") || (seconddig == "8"))){return isCreditCard(cc);}else{return false;}}
function isCarteBlanche(cc){return isDinersClub(cc);}
function isDiscover(cc){first4digs = cc.substring(0,4);if ((cc.length == 16) && (first4digs == "6011")){return isCreditCard(cc);}else{return false;}}
function isEnRoute(cc){first4digs = cc.substring(0,4);if ((cc.length == 15) && ((first4digs == "2014") || (first4digs == "2149"))){return isCreditCard(cc);}else{return false;}}
function isJCB(cc){first4digs = cc.substring(0,4);if ((cc.length == 16) &&((first4digs == "3088") ||(first4digs == "3096") ||(first4digs == "3112") ||(first4digs == "3158") ||(first4digs == "3337") ||(first4digs == "3528"))){return isCreditCard(cc);}else{return false;}}
function isAnyCard(cc){if (!isCreditCard(cc)){return false;}if (!isMasterCard(cc) && !isVisa(cc) && !isAmericanExpress(cc) && !isDinersClub(cc) &&!isDiscover(cc) && !isEnRoute(cc) && !isJCB(cc)){return false;}else{return true;}}
function isCardMatch (cardType, cardNumber){cardType = cardType.toUpperCase();var doesMatch = true;if ((cardType == "VISA") && (!isVisa(cardNumber))){doesMatch = false;}if((cardType == "MASTER CARD") && (!isMasterCard(cardNumber))){doesMatch = false;}if(((cardType == "AMERICAN EXPRESS") || (cardType == "AMEX") )&& (!isAmericanExpress(cardNumber))){doesMatch = false;}if((cardType == "DISCOVER") && (!isDiscover(cardNumber))){doesMatch = false;}if((cardType == "JCB") && (!isJCB(cardNumber))){doesMatch = false;}if((cardType == "DINERS") && (!isDinersClub(cardNumber))){doesMatch = false;}if((cardType == "CARTEBLANCHE") && (!isCarteBlanche(cardNumber))){doesMatch = false;}if((cardType == "ENROUTE") && (!isEnRoute(cardNumber))){doesMatch = false;}return doesMatch;}
function checkContractRefNumber(formField, emptyOK){if (!isContractRefNumber(formField.value, emptyOK)){warnInvalid (formField, iContractRefNumber);return false;}else{return true;}}
function isContractRefNumber(s, emptyOK){if (isEmpty(s)){return emptyOK;}else{return((s.length == 15)&& isInteger(s.substring(0,2))&& isAlphabetic(s.substring(2,5))&& isInteger(s.substring(5,9))&& isAlphabetic(s.substring(9,10))&& isInteger(s.substring(10,15)));}}
function checkStringForDoubleQuotes (theField, s, emptyOK){ if (isEmpty(theField.value)){ if(emptyOK){ return true;}	else { return warnEmpty (theField, s);} } else { if (isWhitespace(theField.value)) { return warnEmpty (theField, s);}else { return checkForDoubleQuote(theField, s); }}}
function checkStringForSpecialCharacters (theField, s, emptyOK){if (isEmpty(theField.value)){if(emptyOK){return true;}else{	return warnEmpty (theField, s);	}}else{	if (isWhitespace(theField.value)){ 	return warnEmpty (theField, s);	}else {	return (checkForDoubleQuote(theField, s) && checkForAsterisk(theField, s) && checkForTilde(theField, s));}}}
function isDate1AfterDate2 (startDate, endDate){if(isDate(startDate.value,false) && isDate(endDate.value,false)){if ((new Date(startDate.value)).getTime() > (new Date(endDate.value)).getTime()){return false;}else{return true;}}else{return false;}}
function checkDateSequence(startDateField, endDateField, s){if(isDate1AfterDate2(startDateField, endDateField)){return true;}else{return warnInvalid (startDateField, s);}}
function checkDateInterval(startDateField, endDateField, days, s){var startTime = (new Date(startDateField.value)).getTime();var endTime = (new Date(endDateField.value)).getTime();var interval = Math.round((endTime - startTime)/(1000*60*60*24));if(interval > days){return warnInvalid (startDateField, s);}else{return true;}}
function checkCookie(msg,checkValue){if(checkValue.checked){if (document.cookie == ""){alert(msg);}}}