function isNumeric(value) {
  if (value != null && !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
}



function checkb(id)
{
	var v;
	var a=document.productsinfo['checkes[]'];
	
	v=eval("document.productsinfo.qty"+id+".value");
	if(v==0 || isNumeric(v)==false)
		{
		alert('Please enter valid quantity');
		return false;
		}
	else
	{
		for(i=0;i<a.length;i++){
			if(a[i].value==id)
			a[i].checked=true;
		}
	}
}

function checkdb1(id)
{
	var v;
	var productcount=document.productsinfo.countproduct.value;
	if(productcount==1)
	{
		var b=document.productsinfo['checkes_one'];	
	v=eval("document.productsinfo.qty"+b.value+".value");
		if(v==0 || isNumeric(v)==false)
		{
		alert('Please enter valid quantity');
		return false;
		}
	else
	{
			if(b.value==id)
			b.checked=true;
	}
	}
}

function validatess()
{
	

	var p=0;
	var q=0;
	var v;
	var Char;
	var productcount=document.productsinfo.countproduct.value;
	if(productcount==1)
	{
		var b=document.productsinfo['checkes_one'];	
if(b.checked){		
 	v=eval("document.productsinfo.qty"+b.value+".value");
		if(v==0 || isNumeric(v)==false)
		{
		alert('Please enter valid quantity');
		return false;
		}
	q=q+1;	
}
	if(q==0)
	{alert('Please select check box');
	return false;}
	
	}
	else
	{
	var a=document.productsinfo['checkes[]'];

	for(i=0;i<a.length;i++){
		if(a[i].checked){
		v=eval("document.productsinfo.qty"+a[i].value+".value");
		if(v==0 || isNumeric(v)==false)
		{
		alert('Please enter valid quantity');
		return false;
		}
		/*else
		{
		for (i = 0; i < v.length; i++)
{
Char = v.charAt(i);
if ((i == 0) && (Char == "-"))
alert('Please enter valid quantity');
		return false;
}
		}*/
		
		p=p+1;
		}
		
		document.productsinfo.totalcount.value=p;
	}
	if (p==0){
		alert('Please select at least one check box');
		return false;
	}
	return true;
	}
}

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}




function validating()
{
	if(document.form1.name.value=='')
	{
		alert("Please enter name in the Billing info");
		document.form1.name.focus();
		return false;
	}
	
		if(document.form1.company.value=='')
	{
		alert("Please enter company in the Billing info");
		document.form1.company.focus();
		return false;
	}
	
	
		if(document.form1.address1.value=='')
	{
		alert("Please enter address in the Billing info");
		document.form1.address1.focus();
		return false;
	}
			if(document.form1.city.value=='')
	{
		alert("Please enter city in the Billing info");
		document.form1.city.focus();
		return false;
	}
	
				if(document.form1.state.value=='')
	{
		alert("Please enter state in the Billing info");
		document.form1.state.focus();
		return false;
	}
	
	
				if(document.form1.zip.value=='')
	{
		alert("Please enter zip in the Billing info");
		document.form1.zip.focus();
		return false;
	}
	else if (validateZIP(document.form1.zip.value)==false)
	{
	document.form1.zip.focus();	
	return false;
	}
	
	
	
	if(document.form1.country.value=='')
	{
		alert("Please enter country in the Billing info");
		document.form1.country.focus();
		return false;
	}
	
	if(document.form1.phone.value=='')
	{
		alert("Please enter phone in the Billing info");
		document.form1.phone.focus();
		return false;
	}
   if(document.form1.email.value=='')
	{
		alert("Please enter email in the Billing info");
		document.form1.email.focus();
		return false;
	}
	else if (echeck(document.form1.email.value)==false){

		document.form1.email.value=""

		document.form1.email.focus()

		return false

	}
	
	
							if(document.form1.sname.value=='')
	{
		alert("Please enter Shippin name in the Shipping info");
		document.form1.sname.focus();
		return false;
	}
	
								if(document.form1.saddress1.value=='')
	{
		alert("Please enter shipping address in the Shipping info");
		document.form1.saddress1.focus();
		return false;
	}
	
									if(document.form1.scity.value=='')
	{
		alert("Please enter shipping city in the Shipping info");
		document.form1.scity.focus();
		return false;
	}
									if(document.form1.sstate.value=='')
	{
		alert("Please enter shipping state in the Shipping info");
		document.form1.sstate.focus();
		return false;
	}
	
									if(document.form1.szip.value=='')
	{
		alert("Please enter shipping zipcode in the Shipping info");
		document.form1.szip.focus();
		return false;
	}
	else if (validateZIP(document.form1.szip.value)==false)
	{
	document.form1.szip.focus();	
	return false;
	}
	
									if(document.form1.scountry.value=='')
	{
		alert("Please enter shipping country in the Shipping info");
		document.form1.scountry.focus();
		return false;
	}

	return true;
}

function ch(thisform)
{
if(thisform.freeshipping.value=='free')
{}
else
{
myOption = -1;
for (i=thisform.fedex.length-1; i > -1; i--) {
if (thisform.fedex[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button");
return false;
}
}

   
if(document.form1.cardnumber.value=='')
{
	alert("Please enter Card Number");
	document.form1.cardnumber.focus();
	return false;
}

if(document.form1.cvmvalue.value=='')
{
	alert("Please enter CVV ");
	document.form1.cvmvalue.focus();
	return false;
}
return true;
}