function opencart(rows)
{

	var len=document.frm_cart.ONE.length;
	   if(rows == 1)
	   {
			quantity = document.frm_cart.ONE.value;
			stockvalue = document.frm_cart.STOCK.value;
			original = document.frm_cart.STOCK1.value;
				if( (quantity == ""))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
						return false;
				}
				else if((quantity == 0))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
						return false;
				}
				
				else if(isNaN(quantity))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity.indexOf("-") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity.indexOf(".") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity > 65535))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.frm_cart.ONE.focus();
					document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
						return false;
				}		 
	   }
		   else
		   {
			   var flag=0;
		  	for(var index=0;index<rows;index++)
			{
			quantity = document.frm_cart.ONE[index].value;
			stockvalue = document.frm_cart.STOCK[index].value;
			original = document.frm_cart.STOCK1[index].value;
				if( (quantity == ""))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
				else if((quantity == 0))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
				
				else if(isNaN(quantity))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
							return false;
				}
				else if((quantity.indexOf("-") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
							return false;
				}
				else if((quantity.indexOf(".") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
							return false;
				}
				else if((quantity > 65535))
				{
						alert("Type the valid quantity");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
			/*	if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}*/
						
			}
		   }
}
function checkout_validation()
{

	if(document.checkout_frm.varEmail.value == "")
	{
		alert("Please enter the Email Address");
		document.checkout_frm.varEmail.focus();
		return false;
	}
	if (!validateEmail(document.checkout_frm.varEmail.value,1,1)) 
	 {
	 document.checkout_frm.varEmail.focus();
	 return false;
	 }
	if(document.checkout_frm.ConfirmEmail.value == "")
	{
		alert("Please enter the Confirm - Email Address");
		document.checkout_frm.ConfirmEmail.focus();
		return false;
	}
	if(document.checkout_frm.varEmail.value!= document.checkout_frm.ConfirmEmail.value)
	{
		alert("Please enter correct Confirm - Email Address");
		document.checkout_frm.ConfirmEmail.focus();
		return false;
	}
//------script for billing address --------------------------//
	if(document.checkout_frm.varFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.checkout_frm.varFirstName.focus();
		return false;
	}
 	 	if(document.checkout_frm.CompanyName.value == "")
 	{
 		alert("Please enter the Company Name");
 		document.checkout_frm.CompanyName.focus();
 		return false;
 	}
	if(document.checkout_frm.varAddress.value == "")
	{
		alert("Please enter the Shipping Address");
		document.checkout_frm.varAddress.focus();
		return false;
	}
	if(document.checkout_frm.varCity.value == "")
	{
		alert("Please enter the City");
		document.checkout_frm.varCity.focus();
		return false;
	}
	if(document.checkout_frm.varState.value == "")
	{
		alert("Please enter the State");
		document.checkout_frm.varState.focus();
		return false;
	}
	if(document.checkout_frm.varCountry.value =="")
	{
		alert("Please enter the Country");
		document.checkout_frm.varCountry.focus();
		return false;
	}
	
	if(document.checkout_frm.varPostcode.value =="")
	{
		alert("Please enter the Post code");
		document.checkout_frm.varPostcode.focus();
		return false;
	}	
	if(isNaN(document.checkout_frm.varPostcode.value))
	{
		alert("Post Code Must be Numeric");
		document.checkout_frm.varPostcode.focus();
		return false;
	}
	if(document.checkout_frm.varPhoneNo.value == "")
	{
		alert("Please enter the Phone Number");
		document.checkout_frm.varPhoneNo.focus();
		return false;
	}
// 	if(isNaN(document.checkout_frm.varPhoneNo.value))
// 	{
// 		alert("Phone Number Must ber Numeric");
// 		document.checkout_frm.varPhoneNo.focus();
// 		return false;
// 	}
//--------------Code for shipping address section-------------------//
	if(document.checkout_frm.varShipFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.checkout_frm.varShipFirstName.focus();
		return false;
	}
	
 	 	if(document.checkout_frm.varShipCompanyName.value == "")
 	{
 		alert("Please enter the company Name");
 		document.checkout_frm.varShipCompanyName.focus();
 		return false;
 	}
	if(document.checkout_frm.varShipAddress.value == "")
	{
		alert("Please enter the Shipping Address");
		document.checkout_frm.varShipAddress.focus();
		return false;
	}
	if(document.checkout_frm.varShipCity.value == "")
	{
		alert("Please enter the City");
		document.checkout_frm.varShipCity.focus();
		return false;
	}
	if(document.checkout_frm.varShipState.value == "")
	{
		alert("Please enter the State");
		document.checkout_frm.varShipState.focus();
		return false;
	}
	if(document.checkout_frm.varShipCountry.value =="")
	{
		alert("Please enter the Country");
		document.checkout_frm.varShipCountry.focus();
		return false;
	}
	
	if(document.checkout_frm.varShipZip.value =="")
	{
		alert("Please enter the Post code");
		document.checkout_frm.varShipZip.focus();
		return false;
	}	
	if(isNaN(document.checkout_frm.varShipZip.value))
	{
		alert("Post Code Must be Numeric");
		document.checkout_frm.varShipZip.focus();
		return false;
	}
	if(document.checkout_frm.varShipPhone.value == "")
	{
		alert("Please enter the Phone Number");
		document.checkout_frm.varShipPhone.focus();
		return false;
	}
// 	if(isNaN(document.checkout_frm.varShipPhone.value))
// 	{
// 		alert("Phone Number Must ber Numeric");
// 		document.checkout_frm.varShipPhone.focus();
// 		return false;
// 	}
}

function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}
function subscriberfront_validation() {
	 if (document.Customersform.txt_name.value== "" )
		 { 
			 alert ("Please Enter your Name");
			 document.Customersform.txt_name.focus();
			 return false;
		 }
		 if (document.Customersform.txt_email.value== "" )
		 { 
			 alert ("Please Enter Your E-mail Address");
			 document.Customersform.txt_email.focus();
			 return false;
		 }
		  if (!validateEmail(document.Customersform.txt_email.value,1,1)) 
		 {
		 document.Customersform.txt_email.focus();
		 return false;
		 }
	
}

function tellfriendvalidate(){
	
	 if (document.frm_tell.fromname.value== "" )
		 { 
			 alert ("Please Enter your Name");
			 document.frm_tell.fromname.focus();
			 return false;
		 }
		 
		  if (document.frm_tell.frommail.value== "" )
		 { 
			 alert ("Please Enter Your E-mail Address");
			 document.frm_tell.frommail.focus();
			 return false;
		 }
		  if (!validateEmail(document.frm_tell.frommail.value,1,1)) 
		 {
		 document.frm_tell.frommail.focus();
		 return false;
		 }
		 
		 
	 if (document.frm_tell.name1.value== "" )
		 { 
			 alert ("Please Enter To Name");
			 document.frm_tell.name1.focus();
			 return false;
		 }
		 
		  if (document.frm_tell.email1.value== "" )
		 { 
			 alert ("Please Enter To E-mail Address");
			 document.frm_tell.email1.focus();
			 return false;
		 }
		  if (!validateEmail(document.frm_tell.email1.value,1,1)) 
		 {
		 document.frm_tell.email1.focus();
		 return false;
		 }
		 
		   if (document.frm_tell.Comments.value== "" )
		 { 
			 alert ("Please Enter Your Comments");
			 document.frm_tell.Comments.focus();
			 return false;
		 }
}





function checkoutformout_validation()
{

if(document.checkoutformout_frm.varEmail.value == "")
	{
		alert("Please enter the Email Address");
		document.checkoutformout_frm.varEmail.focus();
		return false;
	}
	if (!validateEmail(document.checkoutformout_frm.varEmail.value,1,1)) 
	 {
	 document.checkoutformout_frm.varEmail.focus();
	 return false;
	 }
	if(document.checkoutformout_frm.ConfirmEmail.value == "")
	{
		alert("Please enter the Confirm - Email Address");
		document.checkoutformout_frm.ConfirmEmail.focus();
		return false;
	}
	if(document.checkoutformout_frm.varEmail.value!= document.checkoutformout_frm.ConfirmEmail.value)
	{
		alert("Please enter correct Confirm - Email Address");
		document.checkoutformout_frm.ConfirmEmail.focus();
		return false;
	}
//------script for billing address --------------------------//
	if(document.checkoutformout_frm.varFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.checkoutformout_frm.varFirstName.focus();
		return false;
	}
	
	if(document.checkoutformout_frm.varAddress.value == "")
	{
		alert("Please enter the  Address");
		document.checkoutformout_frm.varAddress.focus();
		return false;
	}
	if(document.checkoutformout_frm.varCity.value == "")
	{
		alert("Please enter the City");
		document.checkoutformout_frm.varCity.focus();
		return false;
	}
	
	if(document.checkoutformout_frm.varCountry.value =="")
	{
		alert("Please Select your country");
		document.checkoutformout_frm.varCountry.focus();
		return false;
	}	
	if(document.checkoutformout_frm.varState.value == "")
	{
		alert("Please select the State");
		document.checkoutformout_frm.varState.focus();
		return false;
	}
	
	if(document.checkoutformout_frm.varPostcode.value =="")
	{
		alert("Please enter the Zip Code");
		document.checkoutformout_frm.varPostcode.focus();
		return false;
	}	
	
	
	if(document.checkoutformout_frm.varPhoneNo.value == "")
	{
		alert("Please enter the Phone Number");
		document.checkoutformout_frm.varPhoneNo.focus();
		return false;
	}
	if(isNaN(document.checkoutformout_frm.varPhoneNo.value))
	{
		alert("Phone Number Must ber Numeric");
		document.checkoutformout_frm.varPhoneNo.focus();
		return false;
	}
	
	
	//--------------Code for shipping address section-------------------//
	if(document.checkoutformout_frm.varShipFirstName.value == "")
	{
		alert("Please enter the Shipping First Name");
		document.checkoutformout_frm.varShipFirstName.focus();
		return false;
	}
	
	
	if(document.checkoutformout_frm.varShipAddress.value == "")
	{
		alert("Please enter the Shipping Address");
		document.checkoutformout_frm.varShipAddress.focus();
		return false;
	}
	if(document.checkoutformout_frm.varShipCity.value == "")
	{
		alert("Please enter the Shipping City");
		document.checkoutformout_frm.varShipCity.focus();
		return false;
	}
	
	if(document.checkoutformout_frm.varCountry.value =="")
	{
		alert("Please Select your Shipping country");
		document.checkoutformout_frm.varCountry.focus();
		return false;
	}	
	if(document.checkoutformout_frm.varShipState.value == "Choose")
	{
		alert("Please enter the Shipping State");
		document.checkoutformout_frm.varShipState.focus();
		return false;
	}
	
	if(document.checkoutformout_frm.varShipZip.value =="")
	{
		alert("Please enter the Shipping Zip Code");
		document.checkoutformout_frm.varShipZip.focus();
		return false;
	}	
	
	if(document.checkoutformout_frm.varShipPhone.value == "")
	{
		alert("Please enter the Shipping Phone Number");
		document.checkoutformout_frm.varShipPhone.focus();
		return false;
	}
	if(isNaN(document.checkoutformout_frm.varShipPhone.value))
	{
		alert("Shipping Phone Number Must ber Numeric");
		document.checkoutformout_frm.varShipPhone.focus();
		return false;
	}
	//--------------Code for Credit Card Information section-------------------//
	
	/*if(document.checkoutformout_frm.card_type.value == "")
	{
		alert("Please choose the card type");
		document.checkoutformout_frm.card_type.focus();
		return false;
	}
	if(document.checkoutformout_frm.card_name.value == "")
	{
		alert("Please enter the name on card");
		document.checkoutformout_frm.card_name.focus();
		return false;
	}
	
	if(document.checkoutformout_frm.card_no.value == "")
	{
		alert("Please enter the card number");
		document.checkoutformout_frm.card_no.focus();
		return false;
	}
	if(isNaN(document.checkoutformout_frm.card_no.value))
	{
		alert("Card Number Must ber Numeric");
		document.checkoutformout_frm.card_no.focus();
		return false;
	}
	if(document.checkoutformout_frm.expiremnth.value == "")
	{
		alert("Please select the month");
		document.checkoutformout_frm.expiremnth.focus();
		return false;
	}
	if(document.checkoutformout_frm.expireyear.value == "")
	{
		alert("Please select the expiry year");
		document.checkoutformout_frm.expireyear.focus();
		return false;
	}
	if(document.checkoutformout_frm.cvv_code.value == "")
	{
		alert("Please enter the CVV Number");
		document.checkoutformout_frm.cvv_code.focus();
		return false;
	}
	if(isNaN(document.checkoutformout_frm.cvv_code.value))
	{
		alert("CVV Number Must ber Numeric");
		document.checkoutformout_frm.cvv_code.focus();
		return false;
	}*/
	
	


}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
