function submitt()
{
var str = false; 
str = libraryrequestvalidation();
if (str) {
 if (document.domain.toLowerCase().indexOf("ge.com")==-1)
	document.forms['library'].action = "http://store.gedigitalenergy.com/processlitreq.asp";
 document.forms['library'].submit();}

}

function libraryrequestvalidation(){
	
	//Validations for Most Common field for all the Forms Start Here
	
	if (document.forms['library'].relationship.selectedIndex == 0) {
			alert("Please select your relationship with GE Digital Energy");
			document.forms['library'].relationship.focus();
			return false;
	}
	
	//Validations for First Name start here 
	
	/*  Steps and Content of what has been validated
	1.) The value is being trimmed so that it does not contain any blank spaces.
	2.) It is being validated for null value as it is a compusary field
	3.) Then it is Being checked that the length is greater than one 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contaians only alphabetic character.
	6.) The first Character Is being Converted to Upper Case
	*/

	// step 1 as described above	
	if (textvalidation(document.forms['library'].first_name,"Please enter a valid First Name")==false) 
	{
	document.forms['library'].first_name.focus();
	return false;
	}
	
	// step 2 as described above
	if(document.forms['library'].first_name.value != "")
	document.forms['library'].first_name.value = trimStr(document.forms['library'].first_name); 

	// step 3 as Described above
	var tempfname = document.forms['library'].first_name.value
	
	if(tempfname.length < 2)
	{
	alert("Please Enter a valid First Name");
	document.forms['library'].first_name.focus();
	document.forms['library'].first_name.select();
	return false;
	}
	//Step 4 as Described above
	if(blankvalidation(document.forms['library'].first_name,"Please enter a valid First Name")==false)
	{
	document.forms['library'].first_name.focus();
	document.forms['library'].first_name.select();
	return false;
	};
	//Step 5 as described above
	if(charvalidation(document.forms['library'].first_name.value,"Please enter a valid First Name")==false){
	document.forms['library'].first_name.focus();
	document.forms['library'].first_name.select();
	return false;
	};
	//Step 6 as Described above
	var con = document.forms['library'].first_name.value;
	document.forms['library'].first_name.value = (con.charAt(0)).toUpperCase()+ con.substring(1,con.length);
	/* validations of First name end in above line */

	//Validations for Last Name Begin here
	
	/*  Steps and Content of what has been validated
	1.) The value is being trimmed so that it does not contain any blank spaces.
	2.) It is being validated for null value as it is a compusary field
	3.) Then it is Being checked that the length is greater than one 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contaians only alphabetic character.
	6.) The first Character Is being Converted to Upper Case
	*/
	
	// Step 1 as Described above
	document.forms['library'].last_name.value = trimStr(document.forms['library'].last_name);
	// Step 2 as Described above
	if (textvalidation(document.forms['library'].last_name,"Please enter a valid Last Name")==false)
	{
	document.forms['library'].last_name.focus();	
	return false;
	};
	// Step 3 as Described above
	var templname = document.forms['library'].last_name.value;
	if(templname.length < 2)
	{
	alert("Please Enter a valid Last Name");
	document.forms['library'].last_name.focus();
	document.forms['library'].last_name.select();
	return false;
	}
	//Step 4 as Described above
	if(blankvalidation(document.forms['library'].last_name,"Please enter a valid Last Name")==false)
	{
	document.forms['library'].last_name.focus();
	document.forms['library'].last_name.select();
	return false;
	};
	//Step 5 as Described above
	if(charvalidation(document.forms['library'].last_name.value,"Please enter a valid Last Name")==false){
	document.forms['library'].last_name.focus();
	document.forms['library'].last_name.select();
	return false;
	};
	//Step 6 as Described above
	var con = document.forms['library'].last_name.value;
	document.forms['library'].last_name.value = (con.charAt(0)).toUpperCase()+ con.substring(1,con.length);
	
	/* Validations for Last Name End in above line */

	//Validations For Middle Name Start Here
	
	/*  Steps and Content of what has been validated
	1.) The value is being trimmed so that it does not contain any blank spaces.
	2.) It is Being validated for blank spaces if it contains total blank spaces.
	3.) Next it is being validated for character so that it contaians only alphabetic character.
	4.) All Characters are Converted to Upper Case
	*/

	/*if(document.forms['library'].middle_name.value!="")
	{
	//Step 1 as described above
	document.forms['library'].middle_name.value = trimStr(document.forms['library'].middle_name);
	//Step 2 as described above
	if(blankvalidation(document.forms['library'].middle_name,"Please enter a valid Middle Name")==false)
	{
	document.forms['library'].middle_name.focus();
	document.forms['library'].middle_name.select();
	return false;
	};
	//step 3 as described above
	if(charvalidation(document.forms['library'].middle_name.value,"Please enter a valid Middle Name")==false){
	document.forms['library'].middle_name.focus();
	document.forms['library'].middle_name.select();
	return false;
	};
	//Step 4 as Described above
	var con = document.forms['library'].middle_name.value;
	document.forms['library'].middle_name.value = con.toUpperCase(); 
	}*/
	
	/* Validations For Middle Name End here */
	
	//Validations For E-mail Start Here
	
	/*  Steps and Content of what has been validated
	if Communication Mode Is selected as email then this becomes a compulsary field otherwise Phone Number becomes compulsary field 
	1.) It is Being Validated for not null
	2.) It is Being checked whether the address contains one '@' Symbol and atleast one '.'.
	3.) Next it is checking whether after the dot there are either two or three characters only. 
	4.) all spaces enetered by user are being truncated.
	*/
	//Step 1 As Described Above
	
	
	document.forms['library'].email_address.value = trimStr(document.forms['library'].email_address);
	//Steps 2 and 3 as Described Above
	if (emailvalidation(document.forms['library'].email_address,"Please Enter a valid E-mail Address")==false){
	document.forms['library'].email_address.focus();
	document.forms['library'].email_address.select();
	return false;
	};
	
	
	/* Validations For E-mail end here */
	
	//Validations For Phone Number Start Here

	/*  Steps and Content of what has been validated
	if Communication Mode Is selected as phone then this becomes a compulsary field otherwise email becomes compulsary field 
	1.) It is Being Validated for not null
	2.) It is Also Being checked so that user cannot enter only blank spaces
	3.) It Is being Checked to Accept Only numerals and some special Characters Such as '(',')','-' 
	4.) All spaces enetered by user are being truncated.
	*/
	
	//Step 1 Starts Here
	//if(document.forms['library'].phonenumber.value!="")
	//{
	//Step 4 as desscribed above
	document.forms['library'].phonenumber.value = trimStr1(document.forms['library'].phonenumber);
	//Step 2 as Described Above
	if(blankvalidation(document.forms['library'].phonenumber,"Please Enter a valid Phone Number")==false)
	{
	document.forms['library'].phonenumber.focus();
	document.forms['library'].phonenumber.select();
	return false;
	};
	//Step 3 as described above
	if (phonenumbervalidation(document.forms['library'].phonenumber,"Please Enter a Valid Phone Number")==false)
	{
	document.forms['library'].phonenumber.focus();
	document.forms['library'].phonenumber.select();
	return false;
	}
	//}
	
	/* Validations for phoneNumber End Here */
	
	//Company Validation Start Here
	
	/*  Steps and Content of what has been validated
	1.) It is Being Validated for not null as it is a compulsary field
	2.) It is Also Being checked so that user cannot enter only blank spaces
	3.) All unnecessary spaces entered by user are being truncated and replaced by a single space.
	*/
	
	//if(document.forms['library'].company.value != "")
	//{
		document.forms['library'].company.value = trimStr1(document.forms['library'].company);
		if(blankvalidation(document.forms['library'].company,"Please enter a company Name")==false)
		{
		document.forms['library'].company.focus();
		document.forms['library'].company.select();
		return false;
		};
	//}
	/* Company Validation ends here */
	
	//Address1 Validation Start Here
	
	/*  Steps and Content of what has been validated
	1.) It is Being Validated for not null as it is a compulsary field
	2.) It is Also Being checked so that user cannot enter only blank spaces
	3.) All unnecessary spaces entered by user are being truncated and replaced by a single space.
	*/
	//if(document.forms['library'].address1.value != "")
	//{
		document.forms['library'].address1.value = trimStr1(document.forms['library'].address1);
		if(blankvalidation(document.forms['library'].address1,"please enter the Address")==false)
		{
		document.forms['library'].address1.focus();
		document.forms['library'].address1.select();
		return false;
		};
		if(document.forms['library'].address1.value!="")
		{
		var stripped = document.forms['library'].address1.value.replace(/[\d\.]+/g,""); //to remove periods
		stripped = stripped.replace(/ /g,"");  //to remove spaces
		stripped = stripped.replace(/#/g,""); 
		stripped = stripped.toLowerCase();
		
		if((stripped == "pobox") || (stripped == "box") || (stripped == "po") ) {
		alert("Please provide a street address for shipping. PO Box is not allowed.");
		document.forms['library'].address1.focus();
		return false;
		}
		}
	//}
	/* Address1 Validation ends here */

	//Address2 Validation Start Here
	
	/*  Steps and Content of what has been validated
	1.) It is Being checked so that user cannot enter only blank spaces
	2.) All unnecessary spaces entered by user are being truncated and replaced by a single space.
	*/

	if(document.forms['library'].address2.value!="")
	{
		if(blankvalidation(document.forms['library'].address2,"please enter the Address")==false)
		{
		document.forms['library'].address2.focus();
		document.forms['library'].address2.select();
		return false;
		};
		var stripped = document.forms['library'].address2.value.replace(/[\d\.]+/g,""); //to remove periods
		stripped = stripped.replace(/ /g,"");  //to remove spaces
		stripped = stripped.replace(/#/g,""); 
		stripped = stripped.toLowerCase();
		
		if((stripped == "pobox") || (stripped == "box") || (stripped == "po") ) {
		alert("Please provide a street address for shipping. PO Box is not allowed.");
		document.forms['library'].address2.focus();
		return false;
		}
		document.forms['library'].address2.value = trimStr1(document.forms['library'].address2);
	}
	
	/* Address 2 Validation ends Here */

	//City validation starts here
	
	/*  Steps and Content of what has been validated
	1.) It is being validated for null value as it is a compusary field
	2.) The value is being trimmed so that it does not contain any extra blank spaces.
	3.) Then it is Being checked that the length is greater than two 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contains only alphabetic character and single spaces are allowed.
	6.) The first Character Is being Converted to Upper Case
	*/
	
	//if(document.forms['library'].city.value != "")
	//{
		// Step 2 as Described Above
		document.forms['library'].city.value = trimStr1(document.forms['library'].city);
		//Step 3 as Described Above
		var tempCity = document.forms['library'].city.value;
		if( tempCity.length < 2)
		{
		alert("Please Enter a Valid City Name");
		document.forms['library'].city.focus();
		document.forms['library'].city.select();
		return false;
		} 
		//Step 4 as described above
		if(blankvalidation(document.forms['library'].city,"Please enter a valid City Name")==false)
		{
		document.forms['library'].city.focus();
		document.forms['library'].city.select();
		return false;
		};
		//Step 5 as described above
		if(charspacevalidation(document.forms['library'].city.value,"Please enter a valid City Name")==false){
		document.forms['library'].city.focus();
		document.forms['library'].city.select();
		return false;
		};//Step 6 as Described Above
		var con = document.forms['library'].city.value;
		document.forms['library'].city.value = (con.charAt(0)).toUpperCase()+ con.substring(1,con.length);
	//}
	/* Validation of City Field Ends Here */

	//Country Field validation starts here
	
	/*  Steps and Content of what has been validated
	1.) It is being validated for null value as it is a compusary field
	2.) The value is being trimmed so that it does not contain any extra blank spaces.
	3.) Then it is Being checked that the length is greater than one 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contains only alphabetic character and single spaces are allowed.
	6.) The first Character Is being Converted to Upper Case
	*/

	var strCountry;
	if (document.library.country.selectedIndex==0) {
		alert("Please select Country");
		document.library.country.focus();
		return false;
	} else {
		strCountry = document.library.country[document.library.country.selectedIndex].value;
		if (strCountry=="US" || strCountry=="CA") {
			if (document.library.state.value=="") {
				alert("Province/State is required for USA or Canada");
				document.library.state.focus();
				return false;
			}
			if (document.library.zip_code.value=="") {	
				alert("Postal Code/ZIP is required for USA or Canada");
				document.library.zip_code.focus();
				return false;
			}
		}
	} 

	/* Validation for Country Ends Here */
		
	//State Field validation starts here
	
	/*  Steps and Content of what has been validated
	1.) It is being validated for null value as it is a compusary field
	2.) The value is being trimmed so that it does not contain any extra blank spaces.
	3.) Then it is Being checked that the length is greater than one 
	4.) It is Being validated for blank spaces if it contains total blank spaces.
	5.) Next it is being validated for character so that it contains only alphabetic character and single spaces are allowed.
	6.) The first Character Is being Converted to Upper Case
	*/

	if(document.forms['library'].state.value != "")
	{
	//Step 2 as Described above
	document.forms['library'].state.value = trimStr1(document.forms['library'].state);
	//Step 3 as Described Above
	var tempState = document.forms['library'].state.value;
	if( tempState.length < 2)
	{
	alert("Please Enter a Valid State Name");
	document.forms['library'].state.focus();
	document.forms['library'].state.select();
	return false;
	}
	//Step 4 as Described Above
	if(blankvalidation(document.forms['library'].state,"Please enter a valid State Name")==false)
	{
	document.forms['library'].state.focus();
	document.forms['library'].state.select();
	return false;
	};
	//Step 5 as Described Above
	if(charspacevalidation(document.forms['library'].state.value,"Please enter a valid State Name")==false)
	{
	document.forms['library'].state.focus();
	document.forms['library'].state.select();
	return false;
	};
	//Step 6 as described above
	var con = document.forms['library'].state.value;
	document.forms['library'].state.value = (con.charAt(0)).toUpperCase()+ con.substring(1,con.length);
	}
	/* State Field Validation Ends Here */


	//Zip code field validation starts here
	
	/*  Steps and Content of what has been validated
	1.) It is being validated for null value as it is a compusary field
	2.) It is Being validated for blank spaces if it contains total blank spaces.
	3.) Next it is being validated for numbers and spaces 
	*/
	
	if(document.forms['library'].zip_code.value != "")
	{
		//Step 2 as described above
		if(blankvalidation(document.forms['library'].zip_code,"Please enter a valid Zip Code")==false)
		{
		document.forms['library'].zip_code.focus();
		document.forms['library'].zip_code.select();
		return false;
		};
		TrimUpr(document.library.zip_code);	// trim and uppercase zip code field
		//Step 3 as described above
		if (zipcodevalidation(document.forms['library'].zip_code,strCountry,"Please enter a valid Zip Code")==false)
		{
		document.forms['library'].zip_code.focus();
		document.forms['library'].zip_code.select();
		return false;
		};
	}
	/* zip code Validation Ends Here */	
	
	// Validate for repeated characters
	
	if(document.forms['library'].CourierAcct.value!="")
	{
		var stripped = document.forms['library'].CourierAcct.value.replace(/[\d\.]+/g,""); //to remove periods
		//stripped = stripped.replace(/ /g,"");  //to remove spaces
		//stripped = stripped.replace(/#/g,""); 
		stripped = stripped.toLowerCase();
		
		if(repeat(stripped))
		{
			alert("Repeated characters in Courier Account is not allowed.");
			document.forms['library'].CourierAcct.focus();
			return false;
		}
		
		document.forms['library'].CourierAcct.value = trimStr1(document.forms['library'].CourierAcct);
	}
	
	function repeat(val){
  		return /(.)\1\1\1/.test(val)
	}
	// Validate requested ship date, if entered
	
	if (document.library.ReqDate.value != '') {
		var msg = reqdatevalidation(document.library.ReqDate.value);
		if (msg != '') {
			alert("Requested ship date "+msg);
			document.library.ReqDate.focus();
			return false;
		}
	}
	

	// Validate publication quantities
	var frm = document.forms['library'];
	var bHasValue=false;
	if (typeof(aPubs)=='undefined' || !aPubs) aPubs = [{maxqty:5}]
	for (p=0; p<aPubs.length; p++)
	{
		if (frm['pubqty'+(p+1)].type == 'select-one') {bHasValue=1;continue;}
		if (frm['pubqty'+(p+1)].value != '') bHasValue=true
		frm['pubqty'+(p+1)].value = trimStr(frm['pubqty'+(p+1)]);
		if (frm['pubqty'+(p+1)].value != '')
			if (pubvalidation(frm['pubqty'+(p+1)], aPubs[p].maxqty, "Please enter a valid quantity") == false)
			{
				with(frm['pubqty'+(p+1)]){focus(); select();}
				return false;
			}
	}
	if (!bHasValue)
	{
		alert("Please enter publication quantity or quantities next to the one(s) you wish to order");
		frm.pubqty1.focus();
		return false
	}

	
return true;
}
// function for trimming values
function trimStr(txtbox) {
var txtVal = txtbox.value;
var outstr = "";
	for( i=0;i<txtVal.length;i++) {
		if(txtVal.charAt(i) == ' ')
			continue;
		else{
			outstr +=txtVal.charAt(i);
		}
	}

	return outstr;
}
//end of triming function

// function for trimming blanks in between
function trimStr1(txtbox) {
var txtVal = txtbox.value;
var outstr = "";
var outstr1 = "";	
	for( i=0;i<txtVal.length;i++) {
		if((txtVal.charAt(i) == ' ' && txtVal.charAt(i+1) == ' ' ))
			continue;
		else{
			outstr +=txtVal.charAt(i);
		}
	}
	templen=outstr.length;
	if(outstr.charAt(0) == ' ')
	outstr1 = outstr.slice(1,templen)
	else
	{
	if(outstr.charAt(templen-1) == ' ')
	outstr1 = outstr.slice(0,templen-1);
	else
	outstr1 = outstr;
	}
	return outstr1;
}
//end of triming function

//Trim blanks at front and end of a text field
function TrimUpr(fld) {
	fld.value = fld.value.replace(/^ +/,'').replace(/\b +$/,'').toUpperCase();
}

//text validation starts here
function textvalidation(entered,alertbox)
{
	with (entered)
	{
		if (entered.value==null || entered.value==""){
			if (alertbox!=""){
			alert(alertbox);}
		entered.focus();
		return false;
		}
		else
		{ return true; }
}
}//text validation ends here

//digit validation starts here
function digitvalidation(entered, min, max, alertbox, datatype)
{
	with (entered)
	{
	checkvalue=parseFloat(value);
		if (datatype){
		smalldatatype=datatype.toLowerCase();
			if (smalldatatype.charAt(0)=="i"){
			checkvalue=parseInt(value);
				if (value.indexOf(".")!=-1){
				checkvalue=checkvalue+1
				}
			};
		}
		if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue || checkvalue == 0){
			if (alertbox!=""){
			alert(alertbox);
			}
		entered.focus();
		entered.select();
		return false;
		}
		else
		{return true;}
	}
}//digit validation ends here

//New email validation starts here
function emailvalidation(entered,alertbox)
{
	tempEmail = entered.value;
	var lenEmail = tempEmail.length;
	var countEmail = 0;
	var tempFlag = 0;
	for(i=0;i<lenEmail;i++)
	{
		chrEmail = tempEmail.charAt(i);
		if(chrEmail == '@'){
		countEmail++;
		}
		if((chrEmail >= 'a' && chrEmail <= 'z')||(chrEmail >= 'A' && chrEmail <= 'Z') || chrEmail == '.' || chrEmail == '@'){
		tempFlag = 1;
		}
	}
	apos=tempEmail.indexOf("@");
	for(j=0;j<lenEmail;j++)
	 {
	 if(tempEmail.charAt(j) == '.')
	  {
		if(tempEmail.charAt(j+1) == '.')
		{
		alert(alertbox);
	 	return false;
		}
	   }
	 }
	dotpos=tempEmail.lastIndexOf(".");
	lastpos=tempEmail.length-1;
	if (apos < 1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2 || countEmail > 1 || tempFlag == 0){
		if (alertbox)
		{alert(alertbox);} 
		return false;
		entered.focus();
		entered.select();
		}
		else 
		{return true;}
}//New email validations ends here

//Blanks Validation function
function blankvalidation(entered,alertbox)
{
	var found=1;
	str1=entered.value;
	for(var i=0;i<str1.length;i++)
	{
		if(str1.charAt(i) != " ")
		{
		found=0;
		break;
		}
	}
	if(found)
	{
		
		alert(alertbox);
		return false;
	}
	else
	return true; 
}//end of blankvalidation

//charcater validation function starts from next line
function charvalidation(name,alertbox)
{
	var temp=0;
	str=name.length;
	for(i=0;i<str;i++) 
	{
	str1=name.charAt(i)
		if( (str1 >= 'a' && str1 <= 'z')||(str1 >= 'A' && str1 <= 'Z') || (str1 == " ")) {
		temp=1;
		}
		else {
		temp=0;
		break;
		}
	}
	if(temp!=0)
	return true;
	else{
	if (alertbox) alert(alertbox);
	return false;
	}
}// end of character validation

// charcater and Space validation it Takes  Characters From a-z and A-Z and Also Spaces and dashes and periods
function charspacevalidation(name,alertbox)
{
	var temp=0;
	str=name.length;
	for(i=0;i<str;i++) 
	{
	str1=name.charAt(i)
		if( (str1 >= 'a' && str1 <= 'z')||(str1 >= 'A' && str1 <= 'Z') || (str1 == ' ') || (str1 == '-') || str1=='.') {
		temp=1;
		}
		else {
		temp=0;
		break;
		}
	}
	if(temp!=0)
	return true;
	else{
	alert(alertbox);
	return false;
	}
}// end of character With space validation

//Start OF AlphaNumeric Validation
function gealphanumeric(entered,alertbox)
{
	var temp=0;
	str2=entered.value 
	str=str2.length;
	for(i=0;i<str;i++) 
	{
	str1=name.charAt(i)
		if((str1 >= 'a' && str1 <= 'z')||(str1 >= 'A' && str1 <= 'Z') || isFinite(str1)) {
		temp=1;
		}
		else {
		temp=0;
		break;
		}
	}
	if(temp!=0)
	return true;
	else{
	alert(alertbox);
	return false;
	}
}// end of Alpha Numeric validation

//New email validation starts here
/* 1.) Check for one at the rate symbol one dot.
   2.) Accepts either two or three characters after the dot.
*/		
function emailvalidation(entered, alertbox)
{
	tempEmail = entered.value;
	var lenEmail = tempEmail.length;
	var countEmail = 0;
	tempFlag = true;
	for(i=0;i<lenEmail;i++)
	{
		chrEmail = tempEmail.charAt(i);
		if(chrEmail == '@')
		{
		countEmail++;
		}
	}
	if (countEmail > 1)
	{
	alert(alertbox);
	return false;
	entered.focus();
	entered.select()
	} 
	with (entered)
	{
	apos=value.indexOf("@")
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
		{
		if (alertbox){
		alert(alertbox);
		} 
		return false;
		entered.focus();
		entered.select()}
		else {return true;}
		}
}//New email validatios ends here

//phone number validation starts here
function phonenumbervalidation(entered,alertbox)
{
	var temp1=0;
	var phone=entered.value;
	strlen=phone.length;
	for(i=0;i<=strlen;i++) 
	{
	str1=phone.charAt(i)
		if((str1 == "-" )|| (str1 == "+" ) || (str1 =="(" ) || (str1 == ")" ) || (str1 == " " ) || isFinite(str1)) 
		{
		temp1=1;
		}
		else {
		temp1=0;
		break;
		}
	}
	if(temp1!=0)
	return true;
	else{
	alert(alertbox);
	entered.focus();
	return false;
	}
}//end of phone validation function

//Start Of Zip code Validation
function zipcodevalidation(entered,country,alertbox)
{
	var usreg = /^\d{5}(-\d{4})?$/;
	// CDN pc doesn't start with W or Z, and no letter is DFIOQU
	var careg = /^[a-ceghj-npr-tvxy]\d[a-ceghj-npr-tv-z] ?\d[a-ceghj-npr-tv-z]\d$/i;
	var temp1=0;
	var phone=entered.value;
	strlen=phone.length;
	if (country=="US") {
		if (usreg.test(entered.value)) return true;
		else {
			alert("US ZIP code entered incorrectly.");
			return false;
		}
	} else if (country=="CA") {
		if (careg.test(entered.value)) return true;
		else {
			alert("Canadian Postal Code entered incorrectly or is not valid.");
			return false;
		}
	}
	if(strlen > 12)
	{
		alert(alertbox);
		return false;
	}
	for(var i=0;i<=strlen;i++) 
	{
		str1=phone.charAt(i)
		if((str1 == "-" )||(str1 == " " )|| isFinite(str1) || charvalidation(str1)) 
		{
			temp1=1;
		}
		else {
			temp1=0;
			break;
		}
	}
	if(temp1!=0)
		return true;
	else{
		alert(alertbox);
		entered.focus();
		return false;
	}
}//end of Zip code validation function 

//function for publication validation
function pubvalidation(pubqty,maxqty,alertbox){
if(pubqty.value !="")
{
if(blankvalidation(pubqty,"Please Enter valid Quantity")==false)
				{
				pubqty.focus();
				return false;
				}
if (digitvalidation(pubqty,1,6,"Please Enter valid Quantity","I")==false)
				{
				pubqty.focus();
				return false;
				};
	if (eval(pubqty.value)>maxqty) {
		alert("Quantity for this item is limited to " + maxqty + ".");
		pubqty.focus();
		pubqty.select();
		return false;
	}
}
else
	{
	alert(alertbox);
	pubqty.focus();
	return false;
	}

}



//function to validate requested ship date
function reqdatevalidation(dt) {
	var DefaultMsg = "is invalid. Please enter in the form MM/DD/[YY]YY\n";
	var dToday = new Date(); dToday = new Date(dToday.getFullYear(), dToday.getMonth(), dToday.getDate());
	var aParts = dt.split("/", 3);
	if (aParts.length!=3 || aParts[0]=="" || aParts[1]=="" || aParts[2]=="" || isNaN(aParts[0]) || isNaN(aParts[1]) || isNaN(aParts[2])) return DefaultMsg;
	var dYear = eval(aParts[2]);
	if (dYear>=100 && dYear.toString().length!=4) return ("contains an invalid year. Year must be 2 or 4 digits."); else if (dYear<100) {
		xYear = dToday.getYear();
		dYear += xYear<100?1900:2000;
	}
	var testdate = new Date(dYear, eval(aParts[0])-1, eval(aParts[1]));
	if (isNaN(testdate) || !testdate) return DefaultMsg;
	if (testdate.getTime() == dToday.getTime()) return ("is today. Same day shipment is not available.\n");
	if (testdate < dToday) return ("is in the past\n");
	// Check day based on month
	Month = parseInt(aParts[0], 10);
	if (Month < 1 || Month > 12)
		return DefaultMsg;
	else if (Month==9 || Month==4 || Month==6 || Month==11)  // Sep, Apr, Jun, Nov
		maxDay = 30;
	else if (Month != 2)								// Jan, Mar, May, Jul, Aug, Oct, Dec
		maxDay = 31;
	else {												// Feb
		maxDay = 28;
		// it's leap year if year is multiple of 4 or 400, but not 100
		if ((dYear % 400) == 0) maxDay++;
		else if ((dYear % 4) ==0 && (dYear % 100) != 0) maxDay++;
	}
	if (parseInt(aParts[1],10) > maxDay) return DefaultMsg;
	if (isWeekend(dt)) return ("is not a regular business day. \nWe can only ship from Monday to Friday.");
	return "";
}
function isWeekend(dTest) {
	aTest = dTest.split('/');
	if (aTest[2].length <= 2) aTest[2] = 2000 + parseInt(aTest[2], 10);
	dTest = aTest[0]+'/'+aTest[1]+'/'+aTest[2].toString();
	var datestr = (new Date(dTest)).toString();
	if (datestr.substring(0,3)=="Sat" || datestr.substring(0,3)=="Sun") return true;
	return false;
}

