
function getFormErrors(form) {
   var errors = new Array();
      
   // loop thru all form elements
   for (var elementIndex = 0; elementIndex < form.elements.length; elementIndex++) {
      var element = form.elements[elementIndex];
     
      // text and textarea types
      if (element.type == "text" || element.type == "textarea") {
         element.value = trimWhitespace(element.value)
         
         // required element
         if (element.required  && element.value == '') {
            errors[errors.length] = element.requiredError;
         }
         
         // maximum length
         else if (element.maxlength && isValidLength(element.value, 0, element.maxlength) == false) {
            errors[errors.length] = element.maxlengthError;
         }

         // minimum length
         else if (element.minlength && isValidLength(element.value, element.minlength, Number.MAX_VALUE) == false) {
            errors[errors.length] = element.minlengthError;
         }
         
         // pattern (credit card number, email address, zip or postal code, alphanumeric, numeric)
         else if (element.pattern) 
		 	{
            if ( ( (element.pattern.toLowerCase() == 'visa' || element.pattern.toLowerCase() == 'mastercard' || 
					element.pattern.toLowerCase() == 'american express' || element.pattern.toLowerCase() == 'diners club' || 
					element.pattern.toLowerCase() == 'discover' || element.pattern.toLowerCase() == 'enroute' || element.pattern.toLowerCase() == 'jcb' || 
					element.pattern.toLowerCase() == 'credit card') && isValidCreditCard(element.value, element.pattern) == false) ||
					(element.pattern.toLowerCase() == 'email' && isValidEmailStrict(element.value) == false) ||
					(element.pattern.toLowerCase() == 'zip or postal code' && isValidZipcode(element.value) == false && 
					isValidPostalcode(element.value) == false) || (element.pattern.toLowerCase() == 'zipcode' && isValidZipcode(element.value) == false) ||
					(element.pattern.toLowerCase() == 'postal code' && isValidPostalcode(element.value) == false) ||
					(element.pattern.toLowerCase() == 'us phone number' && ((element.prefix && element.suffix && isValidUSPhoneNumber(element.value, form[element.prefix].value, 
					form[element.suffix].value) == false) ||(!element.prefix && !element.suffix && isValidUSPhoneNumber(element.value) == false) ) ) ||
					(element.pattern.toLowerCase() == 'alphanumeric' && isAlphanumeric(element.value, true) == false) ||
					(element.pattern.toLowerCase() == 'numeric' && isNumeric(element.value, true) == false) ||
					(element.pattern.toLowerCase() == 'alphabetic' && isAlphabetic(element.value, true) == false)) 
						{
							errors[errors.length] = element.patternError;
						}
        	}
      }
      
      // password 
      else if (element.type == "password") {
         
         // required element
         if (element.required  && element.value == '') {
            errors[errors.length] = element.requiredError;
         }
         
         // maximum length
         else if (element.maxlength && isValidLength(element.value, 0, element.maxlength) == false) {
            errors[errors.length] = element.maxLengthError;
         }

         // minimum length
         else if (element.minlength && isValidLength(element.value, element.minlength, Number.MAX_VALUE) == false) {
            errors[errors.length] = element.minLengthError;
         }
		
      }
      
      // file upload
      if (element.type == "file") {
         
         // required element
         if (element.required  && element.value == '') {
            errors[errors.length] = element.requiredError;
         }
      }
      
      // select
      else if (element.type == "select-one" || element.type == "select-multiple" || element.type == "select" || element.type == "DropDownList") {

         // required element
         if (element.required && element.selectedIndex == -1) {
            errors[errors.length] = element.requiredError;
         }
         
		 // disallow empty value selection
         else if (element.disallowEmptyValue && element.options[element.selectedIndex].value == '') {
            errors[errors.length] = element.disallowEmptyValueError;
         }

      }
      
      // radio buttons
      else if (element.type == "radio") {
         var radiogroup = form.elements[element.name];
         
         // required element
         if (radiogroup.required && radiogroup.length) {
            var checkedRadioButton = -1;
            for (var radioIndex = 0; radioIndex < radiogroup.length; radioIndex++) {
               if (radiogroup[radioIndex].checked == true) {
                  checkedRadioButton = radioIndex;
                  break;
               }
            }
            if (checkedRadioButton == -1 && !radiogroup.tested) {
               errors[errors.length] = radiogroup.requiredError;
               radiogroup.tested = true;
            }
         }
         
         radiogroup = null;
      }
   }
   
	return errors;
}

// Check that the number of characters in a string is between a max and a min
function isValidLength(string, min, max) {
	if (string.length < min || string.length > max) return false;
	else return true;
}

// Check that a credit card number is valid based using the LUHN formula (mod10 is 0)
function isValidCreditCard(number) {
	number = '' + number;
	
	if (number.length > 16 || number.length < 13 ) return false;
	else if (getMod10(number) != 0) return false;
	else if (arguments[1]) {
		var type = arguments[1];
		var first2digits = number.substring(0, 2);
		var first4digits = number.substring(0, 4);
		
		if (type.toLowerCase() == 'visa' && number.substring(0, 1) == 4 &&
			(number.length == 16 || number.length == 13 )) return true;
		else if (type.toLowerCase() == 'mastercard' && number.length == 16 &&
			(first2digits == '51' || first2digits == '52' || first2digits == '53' || first2digits == '54' || 

first2digits == '55')) return true;
		else if (type.toLowerCase() == 'american express' && number.length == 15 && 
			(first2digits == '34' || first2digits == '37')) return true;
		else if (type.toLowerCase() == 'diners club' && number.length == 14 && 
			(first2digits == '30' || first2digits == '36' || first2digits == '38')) return true;
		else if (type.toLowerCase() == 'discover' && number.length == 16 && first4digits == '6011') return true;
		else if (type.toLowerCase() == 'enroute' && number.length == 15 && 
			(first4digits == '2014' || first4digits == '2149')) return true;
		else if (type.toLowerCase() == 'jcb' && number.length == 16 &&
			(first4digits == '3088' || first4digits == '3096' || first4digits == '3112' || first4digits == '3158' 

|| first4digits == '3337' || first4digits == '3528')) return true;
		
    // if the above card types are all the ones that the site accepts, change the line below to 'else return false'
    else return true;
	}
	else return true;
}

// Check that an email address is valid based on RFC 821 (?)
function isValidEmail(address) {
	if (address != '' && address.search) {
      if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
      else return false;
	}
	
   // allow empty strings to return true - screen these with either a 'required' test or a 'length' test
   else return true;
}

// Check that an email address has the form something@something.something
// This is a stricter standard than RFC 821 (?) which allows addresses like postmaster@localhost
function isValidEmailStrict(address) {
	if (isValidEmail(address) == false) return false;
	var domain = address.substring(address.indexOf('@') + 1);
	if (domain.indexOf('.') == -1) return false;
	if (domain.indexOf('.') == 0 || domain.indexOf('.') == domain.length - 1) return false;
	return true;
}

// Check that a US zip code is valid
function isValidZipcode(zipcode) {
	zipcode = removeSpaces(zipcode);
	if (!(zipcode.length == 5)) return false;
	//if (!(zipcode.length == 5 || zipcode.length == 9 || zipcode.length == 10)) return false;
   if ((zipcode.length == 5 || zipcode.length == 9) && !isNumeric(zipcode)) return false;
   if (zipcode.length == 10 && zipcode.search && zipcode.search(/^\d{5}-\d{4}$/) == -1) return false;
   return true;
}
function isValidZipcodeothers(zipcode) {
	zipcode = removeSpaces(zipcode);
	if (!isNumeric(zipcode)) return false;
   return true;
}
//*************************************************************************************
//Author		: Piyush Jain
//Create Date	: 26/May/2004
//Purpose		: To validate the zip code for UK and Canada
//*************************************************************************************/
function isValidZipCode4UKCanada(zipCode)
{
	var state = true;
	var ch;
	for( i=0;i<zipCode.length;i++)
	{
		ch = zipCode.charAt(i);
		if((ch>="a" && ch<="z") || (ch>="A" && ch<="Z")||(ch>="0" && ch<="9")||(ch=="-"))
			continue;
		else return false;
	}
	return true;
}

// Check that a Canadian postal code is valid
function isValidPostalcode(postalcode) {
	if (postalcode.search) {
		postalcode = removeSpaces(postalcode);
		if (postalcode.length == 6 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1) return true;
		else if (postalcode.length == 7 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]-\d[a-zA-Z]\d$/) != -1) return true;
		else return false;
	}
	return true;
}
//

// Check that a US or Canadian phone number is valid
function isValidUSPhoneNumber(areaCode, prefixNumber, suffixNumber) {
   if (arguments.length == 1) {
      var phoneNumber = arguments[0];
      phoneNumber = phoneNumber.replace(/\D+/g, '');
      var length = phoneNumber.length;
      if (phoneNumber.length >= 7) {
         var areaCode = phoneNumber.substring(0, length-7);
         var prefixNumber = phoneNumber.substring(length-7, length-4);
         var suffixNumber = phoneNumber.substring(length-4);
      }
      else return false;
   }
   else if (arguments.length == 3) {
      var areaCode = arguments[0];
      var prefixNumber = arguments[1];
      var suffixNumber = arguments[2];
   }
   else return true;

   if (areaCode.length != 3 || !isNumeric(areaCode) || prefixNumber.length != 3 || !isNumeric(prefixNumber) || 

suffixNumber.length != 4 || !isNumeric(suffixNumber)) return false;
   return true;
}
function isValidPhoneNumber(areaCode, prefixNumber, suffixNumber) {
  
      var areaCode = arguments[0];
      var prefixNumber = arguments[1];
      var suffixNumber = arguments[2];
     

   if (areaCode.length != 3 || !isNumeric(areaCode) ||  prefixNumber.length <3 || prefixNumber.length >4 || !isNumeric(prefixNumber) || 

suffixNumber.length <4 || suffixNumber.length >8 || !isNumeric(suffixNumber)) return false;
   return true;
}


// Check that a string contains only letters , numbers and some special characters
//function isAlphanumericspecial(string, ignoreWhiteSpace,ignoredot,ignorehypen,ignoreunderscore) {
	//if (string.search) {
		//if ((ignoreWhiteSpace && ignoredot && ignorehypen && ignoreunderscore && string.search(/\.\_\-\w\s/) != -1) || 
//		(!ignoreWhiteSpace && !ignoredot && !ignorehypen && !ignoreunderscore && string.search(/\W/) != -1) ||
	//	(ignoreWhiteSpace && !ignoredot && !ignorehypen && !ignoreunderscore && string.search(/\w\s/) != -1) ||
		//(ignoreWhiteSpace && ignoredot && !ignorehypen && !ignoreunderscore && string.search(/\.\w\s/) !=  -1) ||
///		(ignoreWhiteSpace && ignoredot && ignorehypen && !ignoreunderscore && string.search(/\.\-\w\s/) != -1) ||
	//	(!ignoreWhiteSpace && ignoredot && !ignorehypen && !ignoreunderscore && string.search(/\.\W/) !=  -1) ||
		//(!ignoreWhiteSpace && ignoredot && ignorehypen && !ignoreunderscore && string.search(/\-\.\W/) !=  -1) ||
//		(!ignoreWhiteSpace && ignoredot && ignorehypen && ignoreunderscore && string.search(/\-\.\_\w/) !=  -1) ||
//		(ignoreWhiteSpace && ignoredot && !ignorehypen && ignoreunderscore && string.search(/\.\_\w\s/) !=  -1) ||
//		(ignoreWhiteSpace && !ignoredot && ignorehypen && ignoreunderscore && string.search(/\-\_\w\s/) !=  -1) ||
//		(ignoreWhiteSpace && !ignoredot && ignorehypen && !ignoreunderscore && string.search(/\-\w\s/) !=  -1) ||
//		(ignoreWhiteSpace && !ignoredot && !ignorehypen && ignoreunderscore && string.search(/\_\w\s/) !=  -1) ||
//		(!ignoreWhiteSpace && ignoredot && !ignorehypen && ignoreunderscore && string.search(/\_\.\W/) !=  -1) ||
//		(!ignoreWhiteSpace && !ignoredot && ignorehypen && ignoreunderscore && string.search(/\-\_\W/) != -1) ||
//		(!ignoreWhiteSpace && !ignoredot && !ignorehypen && ignoreunderscore && string.search(/\_\W/) !=  -1) ||
//		(!ignoreWhiteSpace && !ignoredot && ignorehypen && !ignoreunderscore && string.search(/\-\W/) !=  -1)	) 
//return false;
//	}
//	return true;
//}


// Check that a string contains only letters , numbers and some special characters
function isAlphanumericspecial(string,spec_char,spec_char1)
{
var state = true;
var ch;
  for( i=0;i<string.length;i++)
  {
 ch = string.charAt(i);
  if((ch == spec_char) || (ch == spec_char) ||(ch>="a" && ch<="z") || (ch>="A" && ch<="Z")||(ch>="0" && ch<="9")||(ch==" "))
	 continue;
   else return false;
 }
 return true;
}


function isAlphanumericspecial1(string,spec_char,spec_char1)
{
var state = true;
var ch;
  for( i=0;i<string.length;i++)
  {
 ch = string.charAt(i);
  if((ch == spec_char) || (ch == spec_char1) ||(ch>="a" && ch<="z") || (ch>="A" && ch<="Z")||(ch>="0" && ch<="9")||(ch==" ") || (ch=="'"))
	 continue;
   else return false;
 }
 return true;
}
/*
*************************************************************************************
Function Name	:isValidName()
Purpose			:This function is check for the valid Customer or employee name.
				Any name is a valid name if it does not contains '<' and '>' 
				character in it.
Author			:Piyush Jain
Create Date		:19/May/2004
*************************************************************************************
*/
function isValidName(string)
{
	
	var state = true;
	var ch;
	for( i=0;i<string.length;i++)
	{
		ch = string.charAt(i);
		if((ch == "<") || (ch == ">"))
		return false;
	}
	return true;
}
/*
*************************************************************************************
Function Name	:isVAlidCompanyName()
Purpose			:This function is check for the valid Customer's or employee's company name.
				Any name is a valid name if it does not contains '<' and '>' 
				character in it.
Author			:Piyush Jain
Create Date		:19/May/2004
*************************************************************************************
*/
function isVAlidCompanyName(string)
{
	var state = true;
	var ch;
	for( i=0;i<string.length;i++)
	{
		ch = string.charAt(i);
		if((ch == "<") || (ch == ">"))
		return false;
	}
	return true;
}

// Check that a string contains only letters and numbers
function isAlphanumeric(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^\w\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\W/) != -1)) 

return false;
	}
	return true;
}

// Check that a string contains only letters
function isAlphabetic(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^a-zA-Z\s]/) != -1) || (!ignoreWhiteSpace && string.search(/[^a-zA-Z]/) != -1)) return false;
	}
	return true;
}

// Check that a string contains only numbers
function isNumeric(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) 

return false;
	}
	return true;
}

// Remove characters that might cause security problems from a string 
function removeBadCharacters(string) {
	if (string.replace) {
		string.replace(/[<>\"\'%;\)\(&\+]/, '');
	}
	return string;
}

// Remove all spaces from a string
function removeSpaces(string) {
	var newString = '';
	for (var i = 0; i < string.length; i++) {
		if (string.charAt(i) != ' ') newString += string.charAt(i);
	}
	return newString;
}

// Remove leading and trailing whitespace from a string
function trimWhitespace(string) {
	var newString  = '';
	var substring  = '';
	beginningFound = false;
	
	// copy characters over to a new string
	// retain whitespace characters if they are between other characters
	for (var i = 0; i < string.length; i++) {
		
		// copy non-whitespace characters
		if (string.charAt(i) != ' ' && string.charCodeAt(i) != 9) {
			
			// if the temporary string contains some whitespace characters, copy them first
			if (substring != '') {
				newString += substring;
				substring = '';
			}
			newString += string.charAt(i);
			if (beginningFound == false) beginningFound = true;
		}
		
		// hold whitespace characters in a temporary string if they follow a non-whitespace character
		else if (beginningFound == true) substring += string.charAt(i);
	}
	return newString;
}

// Returns a checksum digit for a number using mod 10
function getMod10(number) {
	
	// convert number to a string and check that it contains only digits
	// return -1 for illegal input
	number = '' + number;
	number = removeSpaces(number);
	if (!isNumeric(number)) return -1;
	
	// calculate checksum using mod10
	var checksum = 0;
	for (var i = number.length - 1; i >= 0; i--) {
		var isOdd = ((number.length - i) % 2 != 0) ? true : false;
		digit = number.charAt(i);
		
		if (isOdd) checksum += parseInt(digit);
		else {
			var evenDigit = parseInt(digit) * 2;
			if (evenDigit >= 10) checksum += 1 + (evenDigit - 10);
			else checksum += evenDigit;
		}
	}
	return (checksum % 10);
}



function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}

//for validating the price
function validPrice(name,spec_char)
	{
	
		var ch;
		var count=0;
		var decval=""
		var zeroCount=0;
		var zeroCount1=0;
		var intval=""

		  for(i=0;i<name.length;i++) {
				 ch = name.charAt(i);
			  if((ch == spec_char) ||(ch>="0" && ch<="9")){
			  		if(ch==spec_char) count=count+1;
			  		if (count==1) decval=decval + ch;
			  		if (count==0) intval=intval + ch;
					 continue;
				}
			 else
			 	 return false;
		 }

		 //alert(intval)
		 for(i=0;i<intval.length;i++){
		  	if(intval.charAt(i)=="0") zeroCount1=zeroCount1+1;
		 	}

		 //alert(decval)
		 for(i=0;i<decval.length;i++){
		 	if(decval.charAt(i)=="0") zeroCount=zeroCount+1;
		 	}

		  //if ((zeroCount1==intval.length) && (zeroCount1!=1)) return false
		if ((zeroCount==decval.length-1) && (zeroCount1==intval.length)) return false;

		 if(count>1) return false;
		 if (ch==".") return false;
 return true;
}
//*************************************************************************************
//this function is for checkign valid date format
//Author		: Piyush Jain
//Create Date	: 22/Dec/2003
//*************************************************************************************
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    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 isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=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 (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		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 (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function isValidDate(dateValue){
	var dt = dateValue
	if (isDate(dt)==false){
		//dt.focus()
		return false
	}
    return true
 }
//*************************************************************************************
// Functijon ends here
//*************************************************************************************

//*************************************************************************************
//Author		: Piyush Jain
//Create Date	: 22/Dec/2003
//11/12/2003
//Purpose		: To check entered Date is greater than Todays date
//*************************************************************************************
function isGreaterThanToday(dateValue){
	var dateString = dateValue
	// Create date object using entered date str 
	//var date = new Date(dt); 
	var now1 = new Date();
	var Today_date=now1.getDate()
	var Today_month=now1.getMonth()
	var Today_year=now1.getYear()
    //var today = new Date(now.getYear(),now.getMonth(),now.getDate());
   
    var bufArray = dateString.split("/"); 
	
	var date = new Date(bufArray[2],bufArray[0]-1,bufArray[1]);
	var today = new Date(Today_year,Today_month,Today_date);
	
	if (date <= today)
	{
		return false;
	}
	
    return true
 }

/** ***********************************************************************************
// Functijon ends her
************************************************************************************ */
/*************************************************************************************
//Author		: Piyush Jain
//Create Date	: 22/Dec/2003
//11/12/2003
//Purpose		: To check entered Date is greater than Todays date
//*************************************************************************************/
function isLessThanToday(dateValue){
	var dateString = dateValue
	// Create date object using entered date str 
	//var date = new Date(dt); 
	var now1 = new Date();
	var Today_date=now1.getDate()
	var Today_month=now1.getMonth()
	var Today_year=now1.getYear()
    //var today = new Date(now.getYear(),now.getMonth(),now.getDate());
   
    var bufArray = dateString.split("/"); 
	
	var date = new Date(bufArray[2],bufArray[0]-1,bufArray[1]);
	var today = new Date(Today_year,Today_month,Today_date);
	
	if (date < today)
	{
		return true;
	}
	else
	{
		return false;
	}
	
    
 }

//*************************************************************************************
//Author		: Piyush Jain
//Create Date	: 29/Dec/2003
//Purpose		: To convert date entered by user in mm/dd/yyyy formate to date object
//*************************************************************************************
function getDateObject(dateValue){
	var dateString = dateValue
	// Create date object using entered date str 
	       
    var bufArray = dateString.split("/"); 
	var date = new Date(bufArray[2],bufArray[0]-1,bufArray[1]);
	return date
 }

/** ***********************************************************************************
// Functijon ends her
************************************************************************************ */



// ==================================================================================

//Fucntion for checking loginid
//Author Name G.premkumar
//Created Date:06/02/2004
//Modified By:
//Modified Date:

function validLogin(name){
	var ch
	for( i=0;i<name.length;i++){
		ch = name.charAt(i);
		if((ch>="a" && ch<="z") || (ch>="A" && ch<="Z") || (ch>="0" && ch<="9") ||  (ch =="_") )
		continue;
		else return false;
	} //end for
	
	return true;
} //end function

// ==================================================================================			

//*************************************************************************************
//Function Name	:validCurrency()
//Purpose		:this function checks for the proce entered is valid or not
//Author		: Piyush Jain
//Create Date	: 25/Mar/2004
//*************************************************************************************

function validCurrency(priceVal)
{
	var decCount=0
	
	for(i=0;i<priceVal.length;i++)
	{
		ch=priceVal.charAt(i);
		if((ch==".")||(ch >="0" && ch <="9"))
		{
			if(ch==".")
			{
				decCount += 1;
			}
			//continue;
		}
		else
		{
			return false;
		}
		
	}
	if (decCount > 1)
	{
		return false;
	}
	return true;
}
