// BOI, followed by one or more digits, followed by EOI.
var reInteger = /^\d+$/;

// BOI, followed by one or more characters, followed by @,
// followed by one or more characters, followed by ., 
// followed by one or more characters, followed by EOI.
var reEmail = /^.+\@.+\..+$/;


// BOI, followed by one or more characters,
// followed by ., 
// followed by one or more characters, followed by EOI.
var reWebAddress = /^.+\..+$/;

// BOI, followed by an optional + or -, followed by one or more digits, 
// followed by EOI.
//var reSignedInteger = /^(+|-)?\d+$/
var reSignedInteger = /^(\+|\-)?\d+$/;

var defaultEmptyOK = false;

var iEmployer = "Employer ID code is required";

var iUserName = "UserName is required";
var iLastName = "Last Name is required";
var iFirstName = "First Name is required";
var iPassword = "Password is a required field and cannot be blank";

var iEEID  = "Employee ID is required field.";
var iEmail = "Email Address is required";
var iEmail1 = "Not a valid Email Address";

var iFromEmail = "From Email Address is required";
var iFromEmail1 = "Not a valid From Email Address";

var iToEmail = "To Email Address is required";
var iToEmail1 = "Not a valid From Email Address";

var iInitials = "You are required to include your initials.";

var iAddress1 = "Address Line 1 is a required field and cannot be blank";
var iCity = "City is a required field and cannot be blank";
var iState = "State is a required field and cannot be blank";
var iZip_Code = "Zip Code is a required field and cannot be blank";
var iPhone = "Not a valid Phone no.";

var iSTID = "ID is a required field and cannot be blank";
var iServiceTypeName = "Service Type Name is a required field and cannot be blank";


var iStateID = "State Name (Abbreviated) is a required field and cannot be blank";
var iStateName = "State Name is a required field and cannot be blank";

var iEID = "Employer ID code is required";
var iEmployerName = "Employer Name is a required field and cannot be blank";
var iASSIGN_AT_PI = "ASSIGN_AT_PI is a required field and cannot be blank";

var iBankName = "Bank Name is a required field and cannot be blank";
var iBANK_ACCT_NUMBER = "Bank Account Number is a required field and should be a number.";
var iRouting_Number = "Routing Number is a required field and should be a 9 digit no.";
var iBankInitials = "Initials is a required field and cannot be blank";

var iPageTitle = "Page Title is a required field and cannot be blank";

var iOldPassword = "Old Password is a required field and cannot be blank";
var iNewPassword = "New Password is a required field and cannot be blank";
var iNewPassword1 = "Re-enter New Password is a required field and cannot be blank";
var iNewPassword2 = "New Password and Re-enter New Password must be same.";


// Attempting to make this library run on Navigator 2.0,
// so I'm supplying this array creation routine as per
// JavaScript 1.0 documentation.  If you're using 
// Navigator 3.0 or later, you don't need to do this;
// you can use the Array constructor instead.

function makeArray(n) {
//*** BUG: If I put this line in, I get two error messages:
//(1) Window.length can't be set by assignment
//(2) daysInMonth has no property indexed by 4
//If I leave it out, the code works fine.
//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}


var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// isInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating 
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true), 
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true 
// isInteger ("")             defaultEmptyOK
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true

function isInteger (s, emptyOK)
{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
}

// isSignedInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters are numbers; 
// first character is allowed to be + or - as well.
//
// Does not accept floating point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// EXAMPLE FUNCTION CALL:          RESULT:
// isSignedInteger ("5")           true 
// isSignedInteger ("")            defaultEmptyOK
// isSignedInteger ("-5")          true
// isSignedInteger ("+5")          true
// isSignedInteger ("", false)     false
// isSignedInteger ("", true)      true

function isSignedInteger (s, emptyOK)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);
    else {
       return reSignedInteger.test(s)
    }
}

// isNonnegativeInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer >= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNonnegativeInteger (s, emptyOK)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s, 10) >= 0) ) );
}

// 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, emptyOK)

{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
    
    else {
           return reEmail.test(s)
    }
}


function isWebAddress (s, emptyOK)

{   if (isEmpty(s)) 
       if (isWebAddress.arguments.length == 1) return defaultEmptyOK;
       else return (isWebAddress.arguments[1] == true);
    
    else {
           return reWebAddress.test(s)
    }
}

// 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, emptyOK)
{   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));
}


// isYear (STRING s [, BOOLEAN emptyOK])
// 
// isYear returns true if string s is a valid 
// Year number.  Must be 2 or 4 digits only.
// 
// For Year 2000 compliance, you are advised
// to use 4-digit year numbers everywhere.
//
// And yes, this function is not Year 10000 compliant, but 
// because I am giving you 8003 years of advance notice,
// I don't feel very guilty about this ...
//
// For B.C. compliance, write your own function. ;->
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isYear (s, emptyOK)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
		
	   return isIntegerInRange (s, 1, 9999);
    //if (!isNonnegativeInteger(s)) return false;
    //return ((s.length == 2) || (s.length == 4));
}


// isMonth (STRING s [, BOOLEAN emptyOK])
// 
// isMonth returns true if string s is a valid 
// month number between 1 and 12.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isMonth (s, emptyOK)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}



// isDay (STRING s [, BOOLEAN emptyOK])
// 
// isDay returns true if string s is a valid 
// day number between 1 and 31.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isDay (s, emptyOK)
{   if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}



// daysInFebruary (INTEGER year)
// 
// Given integer argument year,
// returns number of days in February of that year.

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

// isDate (STRING year, STRING month, STRING day)
//
// isDate returns true if string arguments year, month, and day 
// form a valid date.
// 

function isDate (year, month, day)
{   // catch invalid years (not 2- or 4-digit) and invalid months and days.
    if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;

    // Explicitly change type to integer to make code work in both
    // JavaScript 1.1 and JavaScript 1.2.
    var intYear = parseInt(year, 10);
    var intMonth = parseInt(month, 10);
    var intDay = parseInt(day, 10);

    // catch invalid days, except for February
    if (intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    return true;
}

// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, put focus in it, and return false.

function warnInvalid (theField, s)
{   theField.focus();
    theField.select();
    alert(s);
    return false;
}

function warnInvalid1 (s)
{   alert(s);
    return false;
}

// checkInteger (TEXTFIELD theField [, BOOLEAN emptyOK])
// 
// Check that string theField.value is an integer.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkInteger (theField, emptyOK)
{   if (checkInteger.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isInteger (theField.value, false))
       return false
    else return true;
}
    

// checkEmail (FormField form [, 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);
       //return warnInvalid1 (iEmail);
    else return true;
}


// checkWebAddress (FormField form [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid Email.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function checkWebAddress (theField, emptyOK)
{   
	
	if (checkWebAddress.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isWebAddress(theField.value, false)) 
       return warnInvalid (theField, iWebAddress);
       //return warnInvalid1 (iWebAddress);
    else return true;

}

// checkDate (String year, String month, String day, STRING labelString [, OKtoOmitDay==false])
//	
// Check that year, month, and day 
// form a valid date.
//
// If they don't, labelString (the name of the date, like "Birth Date")
// is displayed to tell the user which date field is invalid.
//
// If it is OK for the day field to be empty, set optional argument
// OKtoOmitDay to true.  It defaults to false.

function checkJoinedDate (year, month, day, labelString, OKtoOmitDay) {

    // Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
	    
    if (checkJoinedDate.arguments.length == 4) {
		OKtoOmitDay = false;
	}
    
    if (!isYear(year.value)) {
		return warnInvalid1 (iJoinedYear);
	}    
	
    if (!isMonth(month.value)) return warnInvalid1 (iJoinedMonth);
    if ( (OKtoOmitDay == true) && isEmpty(day.value) ) return true;
    else if (!isDay(day.value)) 
       return warnInvalid1 (iJoinedDay);
    
    if (isDate (year.value, month.value, day.value)) {
       return true;
    }      
    
    alert (labelString);
    //alert (iDatePrefix + labelString + iDateSuffix)
    return false;

}
function IsEmpId(strString)
   //  check for valid numeric strings	
   {
   //0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-
   
      var strValidChars = "~`'\":;<>,.\\=| ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
		
      strChar = strString.charAt(i);
     
      if (strValidChars.indexOf(strChar) == -1)
         {
         //blnResult = false;
         blnResult = true;
         }
       else
       {
		 blnResult = false;
		 
       }
      }
      
   return blnResult;
   }

//<!-- Script by hscripts.com -->
function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}
//<!-- Script by hscripts.com -->


