function FormValidation(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"Your Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Address.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.State.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.State.focus();
    return (false);
  }

  if (theForm.Zip.value == "")
  {
    alert("Please enter a value for the \"Zip Code\" field.");
    theForm.Zip.focus();
    return (false);
  }

  if (theForm.Country.value == "")
  {
    alert("Please enter a value for the \"Country\" field.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }
  return (true);
}

///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

var bsubmit = false;
var digits = "0123456789";

var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"

var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

var specialchar = "_*"
//var specialchar = "_"
var strSearch="0123456789/-"
var sErrors=""
var sErrorsBegin="<ul>"
var sErrorsEnd="</ul>"

// whitespace characters
var whitespace = " \t\n\r";


// decimal point character differs by language and culture
var decimalPointDelimiter = "."


// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";


// characters which are allowed in US phone numbers
var validUSPhoneChars = digits + phoneNumberDelimiters;


// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";


// non-digit characters which are allowed in 
// Social Security Numbers
var SSNDelimiters = "- ";



// characters which are allowed in Social Security Numbers
var validSSNChars = digits + SSNDelimiters;



// U.S. Social Security Numbers have 9 digits.
// They are formatted as 123-45-6789.
var digitsInSocialSecurityNumber = 9;


// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;



// non-digit characters which are allowed in ZIP Codes
var ZIPCodeDelimiters = "-";



// our preferred delimiter for reformatting ZIP Codes
var ZIPCodeDelimeter = "-"


// characters which are allowed in Social Security Numbers
var validZIPCodeChars = digits + ZIPCodeDelimiters



// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9


// non-digit characters which are allowed in credit card numbers
var creditCardDelimiters = " "


// CONSTANT STRING DECLARATIONS
// (grouped for ease of translation and localization)

// m is an abbreviation for "missing"

var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."

// s is an abbreviation for "string"

var sAccntNum = "Bill Account Number"
var sPayeeName = "Payee Name"
var sPayeeNickName = "Payee Nickname"
var sNameOnAccount = "Name on the Account"
 sUSLastName = "Last Name"
 sUSFirstName = "First Name"
var sAppName = "Applicant's Name"
var sWorldLastName = "Family Name"
var sWorldFirstName = "Given Name"
var sTitle = "Title"
var sCompanyName = "Company Name"
var sUSAddress = "Street Address"
var sWorldAddress = "Address"
var sCity = "City"
var sStateCode = "State Code"
var sWorldState = "State, Province, or Prefecture"
var sCountry = "Country"
var sZIPCode = "ZIP Code"
var sWorldPostalCode = "Postal Code"
var sPhone = "Phone Number"
var sFax = "Fax Number"
var sDateOfBirth = "Date of Birth"
var sExpirationDate = "Expiration Date"
var sEmail = "Email"
var sSSN = "Social Security Number"



// i is an abbreviation for "invalid"

var iStateCode = "The State field must be a valid two character U.S. state abbreviation (like CA for California)."
var iZIPCode = "The Zip Code field must be a 5 or 9 digit U.S. ZIP Code (like 94043)."
var iUSPhone = "The phone field must be a 10 digit U.S. phone number (like 415 555 1212)."
var iWorldPhone = "This field must be a valid international phone number."
var iSSN = "The SSN field must be a 9 digit U.S. social security number (like 123 45 6789)."
var iEmail = "The E-mail field must be a valid email address (like name@service.com)."
var iCreditCardPrefix = "This is not a valid "
var iCreditCardSuffix = " credit card number. (Click the link on this form to see a list of sample numbers.)"
var iDay = "This field must be a day number between 1 and 31."
var iMonth = "This field must be a month number between 1 and 12."
var iYear = "This field must be a 2 or 4 digit year number."
var iDatePrefix = "The Day, Month, and Year for "
var iDateSuffix = " do not form a valid date."

var iUSAccount = "The Account Number field must be in digit only."

var iBDateYear="This field must be a 4 digit year number."
var iInvalidMonth="This field must be between 1(January) and 12(December)."

var iFirstName="The First Name field is empty."
var iLastName="The Last name field is empty."
var iAddress="The Address field is empty."
var iCity="The City field is empty."
var iEmailADD = "The primary E-mail field is empty."
var iEmailADD2 = "The verification E-mail field is empty."
var iEmailEqual="The primary and verification E-mail fields do not match."
var iAggreement="Please read and check the Online Banking Agreement Box!"
var iMaiden="The Mother's Maiden name field is empty"
// p is an abbreviation for "prompt"

var pEntryPrompt = "Please enter "
var pStateCode = "a 2 character code (like CA)."
var pZIPCode = "a 5 or 9 digit U.S. ZIP Code (like 94043)."
var pUSPhone = "a 10 digit U.S. phone number (like 415 555 1212)."
var pWorldPhone = "an international phone number."
var pSSN = "a 9 digit U.S. social security number (like 123 45 6789)."
var pEmail = "a valid email address (like name@service.com)."
var pCreditCard = "a valid credit card number."
var pDay = "a day number between 1 and 31."
var pMonth = "a month number between 1 and 12."
var pYear = "a 2 or 4 digit year number."
var pState = "Please select a State"
var pMotherName = "Please enter your Mother's Maiden Name"
var pBlank= " "
var pBirthDate="a Birth Date (like 01 02 1952)."

var defaultEmptyOK = false


// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}




// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function isUIDChar (s)
{	
	var i;
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (UIDChar.indexOf(c) == -1) return false;
	}
	return true;
}

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}



// Removes all characters which do NOT appear in string bag 
// from string s.

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}



// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}




// WORKAROUND FUNCTION FOR NAVIGATOR 2.0.2 COMPATIBILITY.
//
// The below function *should* be unnecessary.  In general,
// avoid using it.  Use the standard method indexOf instead.
//
// However, because of an apparent bug in indexOf on 
// Navigator 2.0.2, the below loop does not work as the
// body of stripInitialWhitespace:
//
// while ((i < s.length) && (whitespace.indexOf(s.charAt(i)) != -1))
//   i++;
//
// ... so we provide this workaround function charInString
// instead.
//
// charInString (CHARACTER c, STRING s)
//
// Returns true if single character c (actually a string)
// is contained within string s.

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}



// Removes initial (leading) whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}







// Returns true if character c is an English letter 
// (A .. Z, a..z).
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}



// Returns true if character c is a digit 
// (0 .. 9).

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}



// Returns true if character c is a letter or digit.

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}



// isAlphabetic (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is English letters 
// (A .. Z, a..z) only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}




// isAlphanumeric (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is English letters 
// (A .. Z, a..z) and numbers only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphanumeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}





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;
}




// isSSN (STRING s [, BOOLEAN emptyOK])
// 
// isSSN returns true if string s is a valid U.S. Social
// Security Number.  Must be 9 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isSSN (s)
{   if (isEmpty(s)) 
       if (isSSN.arguments.length == 1) return defaultEmptyOK;
       else return (isSSN.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInSocialSecurityNumber)
}

function isAcctNum(fld)
{
  return(isInteger(fld) && fld.length==16);     
}


// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
// 
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}



function isUSAccount(s)
{	if (isEmpty(s))
		if (isUSAccount.arguments.length == 1) return defaultEmptyOK;
		else return (isUSAccount.arguments[1] == true);
	return isInteger(s)
}



// isZIPCode (STRING s [, BOOLEAN emptyOK])
// 
// isZIPCode returns true if string s is a valid 
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.  
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isZIPCode (s)
{  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}





// isUserNameNew (STRING s [, BOOLEAN emptyOK])
// isUserNameNew returns true if string s is a valid User-ID
// Must be 8-20 characters long.
//
// For explanation of optional argument emptyOK,
// see comments of function isAlphanumeric.





// isStateCode (STRING s [, BOOLEAN emptyOK])
// 
// Return true if s is a valid U.S. Postal Code 
// (abbreviation for state).
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isStateCode(s)
{   if (isEmpty(s)) 
       if (isStateCode.arguments.length == 1) return defaultEmptyOK;
       else return (isStateCode.arguments[1] == true);
    return ( (USStateCodes.indexOf(s) != -1) &&
             (s.indexOf(USStateCodeDelimiter) == -1) )
}






// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * 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
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}


// isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK])
// 
// isIntegerInRange returns true if string s is an integer 
// within the range of integer arguments a and b, inclusive.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.


function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s,10);
    return ((num >= a) && (num <= b));
}







/* FUNCTIONS TO NOTIFY USER OF INPUT REQUIREMENTS OR MISTAKES. */


// Display prompt string s in status bar.

function prompt (s)
{   window.status = s
}



// Display data entry prompt string s in status bar.

function promptEntry (s)
{   window.status = pEntryPrompt + s
}




// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   alert(mPrefix + s + mSuffix)
	if (!bsubmit){
	theField.focus();
	theField.select();}
	window.event.returnValue = 0;
    return false
}



// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.

function warnInvalid (theField, s)
{   alert(s)
	if (!bsubmit){
	theField.select();
	theField.focus();}
	window.event.returnValue = 0;
    return false
}

function resetfocus(ofield)
{
	ofield.focus()
	return true
}


/* FUNCTIONS TO INTERACTIVELY CHECK VARIOUS FIELDS. */

// checkString (TEXTFIELD theField, STRING s, [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is not all whitespace.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkString (theField, s, emptyOK)
{   // Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
    if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (isWhitespace(theField.value)) 
       return warnEmpty (s);
    else return true;
}





// takes ZIPString, a string of 5 or 9 digits;
// if 9 digits, inserts separator hyphen

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}




// checkZIPCode (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid ZIP code.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkZIPCode (theField, emptyOK)
{   if (checkZIPCode.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    { var normalizedZIP = stripCharsInBag(theField.value, ZIPCodeDelimiters)
      if (!isZIPCode(normalizedZIP, false)) 
         return warnInvalid (theField, iZIPCode);
      else 
      {  // if you don't want to insert a hyphen, comment next line out
         theField.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    }
}



// takes USPhone, a string of 10 digits
// and reformats as (123) 456-789

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ")", 3, "-", 4))

}



// checkUSPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid US Phone.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK; 
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    { var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
        if (!isUSPhoneNumber(normalizedPhone, false)) 
         return warnInvalid (theField, iUSPhone);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}






// checkEmail (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid Email.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkEmail (theField, emptyOK)
{   if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isEmail(theField.value, false)) 
       return warnInvalid (theField, iEmail);
    else return true;
}





// takes SSN, a string of 9 digits
// and reformats as 123-45-6789

function reformatSSN (SSN)
{   return (reformat (SSN, "", 3, "-", 2, "-", 4))
}


// Check that string theField.value is a valid SSN.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkSSN (theField, emptyOK)
{   if (checkSSN.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedSSN = stripCharsInBag(theField.value, SSNDelimiters)
       if (!isSSN(normalizedSSN, false)) 
          return warnInvalid (theField, iSSN);
       else 
       {  // if you don't want to reformats as 123-46-7890, comment next line out
          theField.value = reformatSSN(normalizedSSN)
          return true;
       }
    }
}







// *********************************************************************************************************
// Check that string theField.value is a valid User-ID.



// Merges string USFirstName and USLastName into AppName.

function createAppName ()
{
	var firstname = document.regapp.AppNameFirst.value 
	var lastname = document.regapp.AppNameLast.value
	lastnamelen = lastname.length;
 	document.regapp.AppName.value = firstname.substring(0,(19-lastnamelen))+" "+lastname.substring(0,19);
	return true;
	
}


function ValidNumbers (theField)
{	
		var c = String.fromCharCode(window.event.keyCode)
		if (strSearch.indexOf(c) == -1)
		{ window.event.returnValue = 0;}
	
	
}

/*function ValidNumbers(theField)
{
	if(document.all){
	var c = String.fromCharCode(window.event.keyCode)
		
		if (strSearch.search(c) == -1) {
			window.event.keyCode=0;
			window.event.returnValue = 0;
		}
	}
}
*/
function checkdate(objName)
 { 
	var datefield = objName;
	if (chkdate(objName) == false)
	 {
		datefield.select();
		alert("That date is invalid.  Please try again.");
		datefield.focus();
		return false;
	}
	else
	 {
		return true;
   	}
}

function chkdate(objName)
 {
	var strDatestyle = "US"; //United States date style
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var intMonth;
	var intYear;
	var booFound = false;
	var datefield = objName;
	var oname=datefield.name;
	
	
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array(12);
	strMonthArray[0] = "Jan";
	strMonthArray[1] = "Feb";
	strMonthArray[2] = "Mar";
	strMonthArray[3] = "Apr";
	strMonthArray[4] = "May";
	strMonthArray[5] = "Jun";
	strMonthArray[6] = "Jul";
	strMonthArray[7] = "Aug";
	strMonthArray[8] = "Sep";
	strMonthArray[9] = "Oct";
	strMonthArray[10] = "Nov";
	strMonthArray[11] = "Dec";
	strDate = datefield.value;
	if (strDate.length==0){
	  return true;
	}  
	if (strDate.length < 8)
	 {
		return false;
	}
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) 
	{
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
		{
		strDateArray = strDate.split(strSeparatorArray[intElementNr]);
		if (strDateArray.length != 3)
		 {
			err = 1;
			return false;
		}
		else 
		{
			strDay = strDateArray[0];
			strMonth = strDateArray[1];
			strYear = strDateArray[2];
		}
		booFound = true;
   		}
	}
	if (booFound == false)
	 {
		if (strDate.length>5)
	 	{
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
   		}
	}
	if (strYear.length < 4)
	{
		return false;
		//strYear = '20' + strYear;
	}
	
	var dtcurr=new Date();
	var yrcurr=dtcurr.getYear();
	if (yrcurr<1000) yrcurr+=1900;//netscape is stupid
	
	
	
	
	
	if (strDay.length < 2)
	{
		strDay="0" + strDay;
		//strYear = '20' + strYear;
	}
	if (strMonth.length < 2)
	{
		strMonth="0" + strMonth;
		//strYear = '20' + strYear;
	}
	
	
	if (strDatestyle == "US") 
	{
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}
	intday = parseInt(strDay, 10);
	if (isNaN(intday)) 
	{
		err = 2;
		return false;
	}
	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth)) 
	{
		for (i = 0;i<12;i++) 
		{
			if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) 
			{
				intMonth = i+1;
				strMonth = strMonthArray[i];
				i = 12;
   			}
		}
		if (isNaN(intMonth)) 
		{
			err = 3;
			return false;
   		}
	}	
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear)) 
	{
		err = 4;
		return false;
	}
	
	if ((oname=='COAPPDLEXPIRES') || (oname=='APPDLEXPIRES')){
	   if (intYear>=2500){
	     err = 4;
		return false;
	   }
	}
	else{
		
	if ((oname!='COAPPDLEXPIRES') || (oname!='APPDLEXPIRES')){
	   if (intYear>=yrcurr){
	     err = 4;
		return false;
	   }
	}
	}
	
	
	if (intMonth>12 || intMonth<1) 
	{
		err = 5;
		return false;
	}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) 
	{
		err = 6;
		return false;
	}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) 	
	{
		err = 7;
		return false;
	}
	if (intMonth == 2) 
	{
		if (intday < 1) 
		{
			err = 8;
			return false;
		}
		if (LeapYear(intYear) == true)
		 {
			if (intday > 29)
			 {
				err = 9;
				return false;
			}
		}
		else 
		{
			if (intday > 28) 
			{
				err = 10;
				return false;
			}
		}
	}
	/*if (strDatestyle == "US") 
	{
		datefield.value = strMonth + "-" + strDay+ "-" + strYear;
	}
	else 
	{
		datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
	}*/
	datefield.value = strMonth + "-" + strDay+ "-" + strYear;
	
return true;
}

function LeapYear(intYear)
{
	if (intYear % 100 == 0) 
	{
		if (intYear % 400 == 0) { return true; }
	}
	else 
	{
	if ((intYear % 4) == 0) { return true; }
	}
return false;
}


/* function ShowSubMenu(theField)
{	//alert(window.event.screenX)
	//sLeft=parseInt(theField.style.left,10)+10
	//sLeft=window.event.x
	//sTop=parseInt(theField.style.top,10)+10
	//sTop=window.event.y+10
	sLeft= window.event.clientX
	sTop=window.event.clientY+document.body.scrollTop 
	targetID=document.all("MESSAGE")
	targetID.style.left=sLeft
	targetID.style.top=sTop
	targetID.style.display=""
	document.all("MESSAGE1").innerHTML=iUserNameNew

}

  function HideSubMenu(theField)
{
	targetID=document.all("MESSAGE")
	
	targetID.style.display="none"
}
*/


function UIDField(theField)
{
	if (document.all)
	{
	//alert(String.fromCharCode(window.event.keyCode));
	var c = String.fromCharCode(window.event.keyCode)
	if (UIDChars.indexOf(c) == - 1) 
		window.event.returnValue = 0;
	}
}

function NumberOnly(theField)
{
	
	
	if(document.all){
	var c = String.fromCharCode(window.event.keyCode)
		if (!isDigit(c)) 
			window.event.returnValue = 0;
	}
	
	
}

function Field_onfocus(theField, imax, idim, pPrompt)
{
	var items = theField.value
	promptEntry(pPrompt)
	if (items.length == imax)
	{
		theField.value = unformat(items)
		theField.maxLength = idim
	}
}
function BDField_onfocus(theField, imax, idim, pPrompt)
{
	var items = theField.value
	promptEntry(pPrompt)
	
}


function CardNumCheck(theField){
 var fld=""+theField.value;
  if (fld.length>0){
      if (isInteger(fld)==false || fld.length!=16)
      warnInvalid(theField,'Invalid Card Number');
  }
  else 
   return(true);
}


function MoneyCheck(theField){
 var fld=""+theField.value;
 var sz=fld.length;
 var ep=sz-1;
 var decloc=fld.indexOf('.');
 var strippedNumber=""
 if (sz>0){
 for(x=0;x<sz;x++){
    if (fld.substring(x,x+1)!=',')
      strippedNumber+=fld.substring(x,x+1);
 }
 ep=strippedNumber.length-1;
  decloc=strippedNumber.indexOf("."); 
 
  if (decloc>=0){
    if (ep-2!=decloc){
      
      return false;
    }
    decpart=strippedNumber.substring(decloc+1,sz);
    if (isInteger(decpart)==false)
        return false;
        
   if(decloc>0){
    wp=strippedNumber.substring(0,decloc);
        if (isInteger(wp)==false)
           return false;
   }
        
 }
 
 if (decloc==-1){
 
  if (isInteger(strippedNumber)==false) return false;
 }
 }
 return true;
}
/////////////////////////////////////////////////////////////////////////////
function ValidateMoney(theField){
  if (MoneyCheck(theField)==false)
     warnInvalid(theField,'Invalid Amount')
  else
     return true;   
}

function AcctNumCheck(theField){
 var fld=""+theField.value;
  if (fld.length>0){
      if (isInteger(fld)==false || fld.length!=10)
      warnInvalid(theField,'Invalid Account Number');
  }
  else 
   return(true);
}


function SSNcheck (theField, emptyOK)
{   if (SSNcheck.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedSSN = unformat(theField.value)
       if (!isSSN(normalizedSSN, false)) 
	   {  theField.value = normalizedSSN
          return warnInvalid (theField, iSSN);
	   }
       else 
       {  // if you don't want to reformats as 123-46-7890, comment next line out
	   	  theField.maxLength = 9
          theField.value = reformatSSN(normalizedSSN)
          return true;
       }
    }
}

function SSNblur (theField)
{
	var sitem = theField.value
	if (sitem.length == 9 )
	{
		theField.maxLength = 11
		theField.value = reformatSSN(sitem)
		return true;
	}
}
function BDateYearblur (theField)
{
	var sitem = theField.value
	if (sitem.length < 4)
	{
		alert(iBDateYear);
		theField.select();
		theField.focus()
		
	}
}
function ValidMonth (theField,theDayField)
{
	var sitem = theField.value
	
	if (!inRange(sitem,1,12))
	{
		alert(iInvalidMonth);
		theField.select();
		theField.focus();
	}else if(!CompareMonthDays(theDayField,theField)) {
		alert("You have entered an invalid day for the chosed month. Please reenter now.");
		theDayField.select();
		theDayField.focus();	
	
	}
}
function inRange(inputStr, lo, hi) {

var num = parseInt(inputStr,10);

if (num < lo || num > hi) {
return false;
}
return true;
}
function ValidateDay (theField,iMonthField)
{	var dDay=theField.value
	
if (!isNaN(parseInt(dDay,10)))
 {
	if (!isNaN(parseInt(iMonthField.value,10)))
	{	if(!CompareMonthDays(theField,iMonthField))
			{alert("You have entered an invalid day for the chosed month. Please reenter now.");
				theField.select();
				theField.focus();	
			}	
	}
 }
}

function CompareMonthDays(theDayField,theMonthField)
{
		var dDay=theDayField.value
	var monthArray=new Array("Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov","Dec")
	
	var dMonth=monthArray[parseInt(theMonthField.value,10)-1]
	
	switch(dMonth){
		case "Jan" :
			
			if(!inRange(dDay,1,31))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.");
				//theField.select();
				//theField.focus();	
				return false;
			}else{return true;}
			break;
		case "Feb" :
			
			if(!inRange(dDay,1,29))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "Mar" :
			
			if(!inRange(dDay,1,31))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "Apr" :
			
			if(!inRange(dDay,1,30))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;		
		case "May" :
			
			if(!inRange(dDay,1,31))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "June" :
			
			if(!inRange(dDay,1,30))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "July" :
			
			if(!inRange(dDay,1,31))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "Aug" :
			
			if(!inRange(dDay,1,31))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "Sep" :
			
			if(!inRange(dDay,1,30))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;
		case "Oct" :
			
			if(!inRange(dDay,1,30))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();	
				return false;
			}else{return true;}
			break;
		case "Nov" :
			
			if(!inRange(dDay,1,30))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();	
				return false;
			}else{return true;}
			break;
		case "Dec" :
			
			if(!inRange(dDay,1,31))
			{
				//alert("You have entered an invalid day for the chosed month. Please reenter now.")
				//theField.select();
				//theField.focus();
				return false;
			}else{return true;}
			break;								
	
	//switch end
	}	
}


function checkZIP (theField, emptyOK)
{   if (checkZIP.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    { var normalizedZIP = unformat(theField.value)
      if (!isZIPCode(normalizedZIP, false)) 
	  {  theField.value = normalizedZIP	 
         return warnInvalid (theField, iZIPCode);
	  }
      else 
      {  // if you don't want to insert a hyphen, comment next line out
	  	 theField.maxLength = 10
         theField.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    }
}

function Zipblur (theField)
{
	var sitem = theField.value
	if (sitem.length == 9 )
	{
		theField.maxLength = 10
		theField.value = reformatZIPCode(sitem)
		return true;
	}
}

function CheckPhone(theField, emptyOK)
{	if (CheckPhone.arguments.length == 1) emptyOK = defaultEmptyOK; 
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
	else
	{ var items = unformat(theField.value) 
		if (!isUSPhoneNumber(items, false))
		{	theField.value = items
			return warnInvalid (theField, iUSPhone);
		}
		else
		{	theField.maxLength = 13
			theField.value = reformatUSPhone(items)
			return true;
		}
	}
}

function USPhoneblur (theField)
{
	var sitem = theField.value
	if (sitem.length == 10 )
	{
		theField.maxLength = 13
		theField.value = reformatUSPhone(sitem)
		return true;
	}
}

function CheckAccount(theField, emptyOK)
{
	if (CheckAccount.arguments.length == 1) emptyOK = defaultEmptyOK;
	if((emptyOK == true) && (isEmpty(theField.value))) return true;
	else
	{
	var items = unformat(theField.value)
		if(!isUSAccount(items, false))
		{
		theField.value = items
		return warnInvalid (theField, iUSAccount);
		}
		else return true;
	}
}

function unformat (str)
{	
	var arg;
	var resultString = "";
	for (var i=0; i < str.length ; i++)
	{
		arg = str.charAt(i)
		if (isDigit(arg)) resultString += arg;

	}
	return resultString;
}

function validateEmail(theField)
{
	if (theField.value != document.all.InternetEMailAddr.value)
			{
			alert("The E-mail Fields does not match. Please try again");
			theField.focus();
			}
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

