// JavaScript Document
function ChkCartFields(form){

var error_cnt = "0";
var alerts = "";
var error = 1;
var s = "S";
var t = "these";
var f = "fields";

if(form.country.options[form.country.selectedIndex].value == 0){
error_cnt++;
alerts += error_cnt+".Shipping to Country is a required field. Please select a shipping country from the list.\n\n";
error = 0;
}

if(form.shipping_cost.value == '') {
error_cnt++;
alerts += error_cnt+".Shipping cost is a required field. Please select a shipping country to determine the shipping cost.\n\n";
error = 0;
}

if(form.billing_country.options[form.billing_country.selectedIndex].value == 0){
error_cnt++;
alerts += error_cnt+".A Billing Country is a required field. Please select a billing country from the list.\n\n";
error = 0;
}

if(error){
form.submit();
} else {
if(error_cnt<2){s = "";t = "this";f = "field";}
alerts = error_cnt+" ERROR"+s+"\n\n"+alerts+"\nPlease return to Request Page and fill in "+t+" "+error_cnt+" required "+f+"\nThank You.";
alert(alerts);
}
}
/////////////////////////////////////////////
function ChkForm(form){
var error_cnt = "0";
var alerts = "";
var error = 1;
var s = "S";
var t = "these";
var f = "fields";

form.telephone.value = form.telephone.value.replace(/[^0-9]/g,'');

if(form.name.value == ""){error_cnt++;alerts += error_cnt+".Name is a required field\n";error = 0;}
if(form.telephone.value == ""){error_cnt++;alerts += error_cnt+".Telephone is a required field\n";error = 0;}
if(form.telephone.value &&  !form.telephone.value.match(/(\d+)/)){error_cnt++;alerts += error_cnt+". Incorrect telephone format, use digits only, e.g. 015555555\n";error = 0;}
if(form.email.value == ""){error_cnt++;alerts += error_cnt+".Email is a required field\n";error = 0;}
if(form.email.value &&  !form.email.value.match(/(\w+).*\@(\w+)\.(\w+)/)){error_cnt++;alerts += error_cnt+". Incorrect email format, e.g. johnsmith@yahoo.com\n";error = 0;}
if(form.address1.value == ""){error_cnt++;alerts += error_cnt+".Address line one is a required field\n";error = 0;}
if(form.recip_name.value == ""){error_cnt++;alerts += error_cnt+".Recipient name is a required field\n";error = 0;}
if(!form.agreeTCs.checked){error_cnt++;alerts += error_cnt+".You must agree to the Terms & Conditions\n";error = 0;}

if(error){
form.submit();
} else {
if(error_cnt<2){s = "";t = "this";f = "field";}
alerts = error_cnt+" ERROR"+s+"\n\n"+alerts+"\nPlease return to Request Page and fill in "+t+" "+error_cnt+" required "+f+"\nThank You.";
alert(alerts);
}
}
////////////////////////////////////////////////////////

function DuplicateInput(a){
a.recip_name.value = a.name.value;
a.recip_address1.value = a.address1.value;
a.recip_address2.value = a.address2.value;
a.recip_postalcode.value = a.postalcode.value;
a.recip_phone.value = a.telephone.value;
}
///////////////////////////////////////////////////////