function stopRKey(evt) { 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;} 
} 

function data_copy()
{
if(document.ship_info.copy.checked){
	document.ship_info.billname.value=document.ship_info.shipname.value;
	document.ship_info.bill_lastname.value=document.ship_info.ship_lastname.value;
	document.ship_info.billcompany.value=document.ship_info.shipcompany.value;
	document.ship_info.billadr1.value=document.ship_info.shipadr1.value;
	document.ship_info.billadr2.value=document.ship_info.shipadr2.value;
	document.ship_info.billcity.value=document.ship_info.shipcity.value;
	document.ship_info.billstate.value=document.ship_info.shipstate.value;
	document.ship_info.billzip.value=document.ship_info.shipzip.value;
	document.ship_info.billcountry.value=document.ship_info.shipcountry.value;
}
else{
	document.ship_info.billname.value="";
	document.ship_info.bill_lastname.value="";
	document.ship_info.billcompany.value="";
	document.ship_info.billadr1.value="";
	document.ship_info.billadr2.value="";
	document.ship_info.billcity.value="";
	document.ship_info.billstate.value="";
	document.ship_info.billzip.value="";
	document.ship_info.billcountry.value="";
	}
}


function validate_required(field,alerttxt)
{
	with (field)
	{
	if (value==null||value=="")
  	{alert(alerttxt);return false;}
	else {return true}
	}
}

function validate_form(ship_info)
{
with (ship_info)
{
if (validate_required(shipname,"Please enter a name at the shipping address")==false)
  {shipname.focus();return false;}
if (validate_required(shipadr1,"Please enter your shipping address")==false)
  {shipadr1.focus();return false;}
if (validate_required(shipcity,"Please enter your ship to City")==false)
  {shipcity.focus();return false;}
if (validate_required(shipstate,"Please select your State or Province in the shipping address. If not USA or Canada please select: Outside USA and Canada")==false)
  {shipstate.focus();return false;}
if (validate_required(billname,"Please enter your name in the billing address.")==false)
  {billname.focus();return false;}
if (validate_required(billadr1,"Please enter your billing address")==false)
  {billadr1.focus();return false;}
if (validate_required(billcity,"Please enter your Billing City")==false)
  {billcity.focus();return false;}
if (validate_required(billstate,"Please select your State or Province in the billing address. If not USA or Canada please select: Outside USA and Canada")==false)
  {billstate.focus();return false;}
if (validate_required(email,"Please enter your email address")==false)
  {email.focus();return false;}
if (validate_required(phone,"Please enter your telephone number so we can contact you quickly if there is a problem")==false)
  {phone.focus();return false;} 
 
}
}


function cardval(s) {
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
}
j = w.length / 2;
if (j < 6.5 || j > 8 || j == 7) return false;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i<k; i++) {
a = w.charAt(i*2+m) * 2;
c += a > 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
return (c%10 == 0);
}


function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}

function validate_form(customer_info)
{
with (customer_info)
{
if (validate_required(shiptype,"Please select the shipping method you prefer.")==false)
  {shiptype.focus();return false;}
if (validate_required(payment_method,"Please select your method of payment.")==false)
  {payment_method.focus();return false;}
}
}


function stopRKey(evt) { 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;} 
} 
document.onkeypress = stopRKey; 


function checkTotal()
{
  if(window.check_total >= 1)
  {
  return true;
  }
  else
  {
  
   alert('It does not appear that you have anything in your cart.');
	 return false;
   } 
 
}



