// FormChek1.js
//-----------------------------------------------------------------
//Modifications:
//
//09/30/99 B.Hubbard removed the formatting for checkZIPCode and checkUSPhone
//
//-----------------------------------------------------------------
// FormChek1.js is the stripped down version of FormChek.js.  If you want
// to see documentation, go to FormChek.js.
// VARIABLE DECLARATIONS

var digits = "0123456789";

var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"

var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


// 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;

// 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 = "-"

// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9


// 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 sUSLastName = "Last Name"
var sUSFirstName = "First 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 sOtherInfo = "Other Information"

// i is an abbreviation for "invalid"

var iStateCode = "This field must be a valid two character U.S. state abbreviation (like CA for California). Please reenter it now."
var iZIPCode = "This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please reenter it now."
var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415 555 1212). Please reenter it now."
var iEmail = "This field must be a valid email address (like foo@bar.com). Please reenter it now."
var iDay = "This field must be a day number between 1 and 31.  Please reenter it now."
var iMonth = "This field must be a month number between 1 and 12.  Please reenter it now."
var iYear = "This field must be a 2 or 4 digit year number.  Please reenter it now."
var iDatePrefix = "The Day, Month, and Year for "
var iDateSuffix = " do not form a valid date.  Please reenter them now."

// p is an abbreviation for "prompt"

var pEntryPrompt = "Please enter a "
var pStateCode = "2 character code (like CA)."
var pZIPCode = "5 or 9 digit U.S. ZIP Code (like 94043)."
var pUSPhone = "10 digit U.S. phone number (like 415 555 1212)."
var pEmail = "valid email address (like foo@bar.com)."
var pDay = "day number between 1 and 31."
var pMonth = "month number between 1 and 12."
var pYear = "2 or 4 digit year number."



var defaultEmptyOK = false

function makeArray(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;

// Valid U.S. Postal Codes for states, territories, armed forces, etc.
// See http://www.usps.gov/ncsc/lookups/abbr_state.txt.

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"

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) 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;
}

// 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;
}

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;
}

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}

function stripTailWhitespace (s)

{   var i = 0;
    while ((i < s.length) && charInString (s.charAt(s.length-1-i), whitespace))
       i++;
    return s.substring (0, s.length-i);
}

function trim(s)
{ return stripTailWhitespace(stripInitialWhitespace (s));
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}

function isInteger(s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == 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;
}

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s, 10) > 0) ) );
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s,10) >= 0) ) );
}

function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s,10) < 0) ) );
}

function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s,10) <= 0) ) );
}

function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}

function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == 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;
}

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == 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;
}

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 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)))
}


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) )
}


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;
    
    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;
}


function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}


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;

    var num = parseInt (s, 10);
	
    return ((num >= a) && (num <= b));
}

function isMonth (s)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);

    return isIntegerInRange (s, 1, 12);
}

function isDay (s)
{   if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}

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 );
}

//function isDate (year, month, day)
function isDate (month, day,year)
{   // 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;

    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;
}

function prompt (s)
{   window.status = s
}

// Display data entry prompt string s in status bar.

function promptEntry (s)
{   window.status = pEntryPrompt + s
}

function warnEmpty (theField, s)
{   theField.focus()
    alert(s)
    return false
}

function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}

/* FUNCTIONS TO INTERACTIVELY CHECK VARIOUS FIELDS. */

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 (theField, s);
    else return true;
}


function checkStateCode (theField, emptyOK)
{   if (checkStateCode.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  theField.value = theField.value.toUpperCase();
       if (!isStateCode(theField.value, false)) 
          return warnInvalid (theField, iStateCode);
       else return true;
    }
}

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

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;
      }
    }
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}

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;
       }
    }
}

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;
}

function checkYear (theField, emptyOK)
{   if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isYear(theField.value, false)) 
       return warnInvalid (theField, iYear);
    else return true;
}

function checkMonth (theField, emptyOK)
{   if (checkMonth.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isMonth(theField.value, false)) 
       return warnInvalid (theField, iMonth);
    else return true;
}

function checkDay (theField, emptyOK)
{   if (checkDay.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isDay(theField.value, false)) 
       return warnInvalid (theField, iDay);
    else return true;
}

function checkDate (yearField, monthField, dayField, labelString, OKtoOmitDay)
{   // Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
    if (checkDate.arguments.length == 4) OKtoOmitDay = false;
    if (!isYear(yearField.value)) return warnInvalid (yearField, iYear);
    if (!isMonth(monthField.value)) return warnInvalid (monthField, iMonth);
    if ( (OKtoOmitDay == true) && isEmpty(dayField.value) ) return true;
    else if (!isDay(dayField.value)) 
       return warnInvalid (dayField, iDay);
    if (isDate (yearField.value, monthField.value, dayField.value))
       return true;
    alert (iDatePrefix + labelString + iDateSuffix)
    return false
}

function getRadioButtonValue (radio)
{   for (var i = 0; i < radio.length; i++)
    {   if (radio[i].checked) { break }
    }
    return radio[i].value
}



////////////////////////////////////////////////////////////
//******  // JAVA SCRIPT BY SHEKHAR PATIDAR // **********//
/////////////////////////////////////////////////////////// 


 
  
 //used for date 
 function validateDate(fld)
   {
    
    
   //var RegExPattern ='(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}'
   
  var RegExPattern ='(0[1-9]|[1-9]|[1][0-9]|2[0-9]|3[01])[- /.](0[1-9]|[1-9]|1[012])[- /.](19|20)[0-9]{2}'
              
                               
    //var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 2-30-2000 would not be accepted.\nFormat mm/dd/yyyy.';
    if ((fld.match(RegExPattern)) && (fld!=''))
     {
       return true; 
     }
    else
     {
       return false;
     } 
  }


// Function for rounding the no

function RoundNumber(rnum, rlength)
 { // Arguments: number to round, number of decimal places
  var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
  return newnumber;
}



function chkLength(value,len)
{
  
    if( value.length> len)
         {
           return false;
         }
        else
          {
            return true;
          } 
}




//Javascript function to check valid decimal value with specified digits after decimal point


function CheckDecimalAfter(value, dec)
{      
      var indx=value.indexOf('.');
        
       if (indx != -1) 
       {
        var count=0;
       
        for (i = indx+1; i < value.length; i++)
        {
          count=count+1;
        }
        
        
        if( count > dec)
           {
             return false;
           }
        else
          {
            return true;
          } 
          
       }
       else 
       {
       return true;     
       }
}



// ***************************************** %%%%%%%%%%%%% *****************************//

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isMyInteger(s) 
{
 //debugger;
 var valid = "0123456789+()-"
 var ok = "yes";
 var temp;
 for (var i=0; i<s.length; i++)
	{ temp = "" + s.substring(i, i+1);
	  if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
	  return false;
	}
	return true;
}

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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

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 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function MyisDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	
return true
}

//function ValidateForm(){
//	var dt=document.frmSample.txtDate
//	if (MyisDate(dt.value)==false){
//		dt.focus()
//		return false
//	}
//    return true
// }

// ***************************************** %%%%%%%%%%%%% *****************************//




 //used for Image Upload for checking valid image file
 function validateImage(MyImage)
   {
    var RegExPattern =' ^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.jpg|.jpeg|.gif|.bmp|.png)$'
   
    if ((MyImage.match(RegExPattern)) && (fld!=''))
     {
       return true; 
     }
    else
     {
       return false;
     } 
  }



//=========================== for find out ASCII value

binary_numbers = new Array("0000", "0001", "0010", "0011", "0100", "0101", 
"0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111");
function toBinary(High, Low) {
var hiHex = "ABCDEF";
if (Low < 10 ) {
LowNib = Low;
}
else {
LowNib = 10 + hiHex.indexOf(Low); 
}
if (High  < 10 ) {
HighNib = High;
}
else {
HighNib = 10 + hiHex.indexOf(High);
}
eight_bits = binary_numbers[HighNib] + " " + binary_numbers[LowNib];
return eight_bits;
}
function Dec2Hex(Decimal) {
var hexChars = "0123456789ABCDEF";
var a = Decimal % 16;
var b = (Decimal - a)/16;
hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
L = hexChars.charAt(a);
H = hexChars.charAt(b);
return hex;
}

var symbols = " !\"#$%&'()*+'-./0123456789:;<=>?@";

function toAscii(aa) 
 {
  var loAZ = "abcdefghijklmnopqrstuvwxyz";
  symbols+= loAZ.toUpperCase();
  symbols+= "[\\]^_`";
  symbols+= loAZ;
  symbols+= "{|}~";
  var loc;
  loc = symbols.indexOf(aa);
  if (loc >-1)
   { 
    Ascii_Decimal = 32 + loc;
    return (32 + loc);
   }
 return(0);  // If not in range 32-126 return ZERO
}

function getAscii(some_value) {
document.asciiform.toDec.value = toAscii();
document.asciiform.toHex.value = Dec2Hex(toAscii()); 
document.asciiform.binary.value = toBinary(H, L); 
}

//==========================


//function Password_Checking(Pass)
//{  
//    var i;
//    var ch_digit=false;
//    var ch_Lchar=false;
//    var ch_Uchar=false;
//      
//    for (i = 0; i < Pass.length; i++)
//      {   
//        // getting current value
//        var c = Pass.charAt(i);

//        if (isDigit(c))
//         {
//          ch_digit=true;
//         }
//        else if(isLetter(c))
//         {
//           var Asc_value=toAscii(c);
//          
//          
//           if((Asc_value >= 65) && (Asc_value <= 90))
//            {
//            ch_Uchar=true;
//            }
//           else if((Asc_value >= 97) && (Asc_value <= 122))
//            {
//            ch_Lchar=true;
//            }
//         } 
//      }

//    if((ch_digit==true) && (ch_Uchar==true) && (ch_Lchar==true))
//     {
//      return true;
//      }
//    else
//      {
//      return false;  
//      }
//      
//}

function validatenumber(Inputnumber,AllowedChar)
{
 var valid = "1234567890" + AllowedChar 
 var ok = "yes";
 var temp;
 for (var i=0; i<Inputnumber.length; i++)
	{ temp = "" + Inputnumber.substring(i, i+1);
	  if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
	  return false;
	}
	return true;
}

function chkUsername(username)
 {
if (username.length < 6)
    {
        return false
    }
 if (username.length >20)
    {
        return false
    }
 return true;   
    }
 
function chkpwd(pwd)
{
    var cap = false
    var smll = false
    var dig = false
    if (pwd.length < 6)
    {
        return false
    }

    for(var i=0;i<pwd.length;i++)
    {
        if (toAscii(pwd.substring(i,i+1)) > 64 && toAscii(pwd.substring(i,i+1)) < 91)
        {
            cap = true
        }
        
        if (toAscii(pwd.substring(i,i+1)) > 96 && toAscii(pwd.substring(i,i+1)) < 123)
        {
            smll = true
        }
        
        if (toAscii(pwd.substring(i,i+1)) > 47 && toAscii(pwd.substring(i,i+1)) < 58)
        {
            dig = true
        }
    }

    if (cap == false || smll == false || dig == false)
    {
        return false
    }
    return true
}

//used for textbox input

function validateText(field,allowchar) 
{
 //debugger;
 var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" + allowchar
 var ok = "yes";
 var temp;
 for (var i=0; i<field.length; i++)
	{ temp = "" + field.substring(i, i+1);
	  if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
	  return false;
	}
	return true;
}

  function funcGridPrint()
{

if(gridPrint.PrintHelperIframe==null)
    {
    
     var browserName=navigator.appName; 
     if (browserName == "Opera")
     {
        
         var printWindow = window.open("","Print","scrollbars=0,left=0,top=0,width=10,height=10");
        if (printWindow != null)
        {
            printWindow.document.write("<html>");
  
            printWindow.document.write("<head>");
            for(var c=document.getElementsByTagName("link"),b=0;b<c.length;b++)
                    printWindow.document.write('<link rel="'+c[b].rel+'" type="'+c[b].type+'" href="'+c[b].href+'">');

            printWindow.document.write("</head>");
  
   
            printWindow.document.write(  "<body onload='print();close();'>" );  
                                                              
                                                               
            var printContent = gridPrint.getOuterHTML(gridPrint.GridMainContainer);
            printWindow.document.write(printContent);
            printWindow.document.write("</html>");
   
            printWindow.document.close();
        }
        else
        {
            alert("You pop has been blocked,for printing enable your pop up blocker");
        }
     }
     
     else
     {

        gridPrint.PrintHelperIframe=document.createElement("IFRAME");
        gridPrint.PrintHelperIframe.id="ob_"+gridPrint.ID+"PrintHelperIframe";
        gridPrint.PrintHelperIframe.name="ob_"+gridPrint.ID+"PrintHelperIframe";
        gridPrint.PrintHelperIframe.width=0;gridPrint.PrintHelperIframe.height=0;
        gridPrint.PrintHelperIframe.frameBorder=0;gridPrint.PrintHelperIframe.src="javascript:false;";
            document.body.appendChild(gridPrint.PrintHelperIframe)
       
        
         var a=document.all?gridPrint.PrintHelperIframe.Document:gridPrint.PrintHelperIframe.contentDocument;
        try{
            a.open();
            a.clear();
            a.write("<html><head>");
             a.write("<html>");
            for(var c=document.getElementsByTagName("link"),b=0;b<c.length;b++)
                a.write('<link rel="'+c[b].rel+'" type="'+c[b].type+'" href="'+c[b].href+'">');

            a.write("</head>");
            a.write("<body>");


            a.write(gridPrint.getOuterHTML(gridPrint.GridMainContainer));


            a.write("</body>");
            a.write("</html>");
            a.close();

            eval("ob_"+gridPrint.ID+"PrintHelperIframe.focus();");
//                ob_gridPrintPrintHelperIframe.print();

          window.setTimeout("ob_" + gridPrint.ID + "PrintHelperIframe.print()", 4000);

            }


            catch(d)
            {
                alert(d.Message)
             }
           }
 }

}

function funcPrintGridInOpera()
{
    debugger;
    var printWindow = window.open("","Print","scrollbars=0,left=0,top=0,width=10,height=10");
  printWindow.document.write("<html>");
  
   printWindow.document.write("<head>");
  for(var c=document.getElementsByTagName("link"),b=0;b<c.length;b++)
                printWindow.document.write('<link rel="'+c[b].rel+'" type="'+c[b].type+'" href="'+c[b].href+'">');

    printWindow.document.write("</head>");
  
   
   printWindow.document.write(  "<body onload='print();close();'>" );  
                                                              
                                                               
   var printContent = gridPrint.getOuterHTML(gridPrint.GridMainContainer);
   printWindow.document.write(printContent);
   printWindow.document.write("</html>");
   
   printWindow.document.close();


   
}
