function AddToCart(a){

if(parent.window.name != 'SHOP'){
parent.window.resizeTo(190,190);
parent.window.moveTo(2,2);
}

WindowOpen('');
a.target="SHOP";
a.submit();

}

////////////////////////////////////////////////////////////////////////
function UpDateForm(a,b,c,d,e,f,g,h,i,j){
var test = isNaN(e);
if(test){e=1;} // Not A Number, Reset e to 1

e = parseInt(e);
g = parseInt(g);

if(e<g){
alert("The quantity you have selected ["+e+"] for the product ["+i+"] is actually less then the allowed minimum order amount for that product.\n\nThe quantity for ["+i+"] will now be set to the minimum order amount.\n\nMinimum Order Amount for ["+i+"] is "+g+".\n\nThank You.\n\nBaseball Ireland.");
e = g;
}

if(e == 0 || e.length == 0){
if(confirm("Inadequate quantity entered\nWould you like to have the product removed from the cart?\nClick OK to remove product\nClick cancel to reset product quantity to 1")){
window.location = a+"?cmd=4&s="+c+"&rid="+d+"&size="+f+"&colour="+j; // Remove From Cart
} else {
e = "1"; // Set Value of e to 1
//alert(a+"\n"+b+"\n"+c+"\n"+d+"\n"+e+"\n"+f+"\n"+j);
window.location = a+"?cmd="+b+"&s="+c+"&id="+d+"&qty="+e+"&size="+f+"&add=1&colour="+j;
}
} else {
window.location = a+"?cmd="+b+"&s="+c+"&id="+d+"&qty="+e+"&size="+f+"&add=1&colour="+j;
}
}
////////////////////////////////////////////////////////////////////////
function GetVarCost(a,b,c,d,e,f){
var doc = document;

if(doc.getElementById){

// DECLARE VARS //////////////

var other_var_type = c.colour;
var x = 'colour';
var thisValue_cost = parseFloat(e);
var thisValue = d+"_"+b+"_"+a;
var extra_cost = doc.getElementById(thisValue).value;
var new_cost;
//////////////////////////////


// GET OTHER SELECT LIST VALUES ///////////
if(b == 'colour'){other_var_type = c.size;x = 'size';}

if(other_var_type){

other_select = other_var_type.options[other_var_type.selectedIndex].value;
var thisOtherValue = d+"_"+x+"_"+other_select;
var other_extra_cost = doc.getElementById(thisOtherValue).value;
var other_thisValue_cost = parseFloat(other_extra_cost);

extra_cost = parseFloat(extra_cost);
other_extra_cost = parseFloat(other_extra_cost);
new_cost = (e+extra_cost+other_extra_cost);

} else {

extra_cost = parseFloat(extra_cost);
new_cost = (e+extra_cost);

}

///////////////////////////////////////////

var re2digit=/^\d{2}$/;
var re2float=/^\d{2}\.\d{1}$/;

new_cost = new_cost.toString();
if(new_cost.match(re2digit)){new_cost = new_cost+".00";};

if(new_cost.match(re2float)){new_cost = new_cost+"0";};

// CHANGE INNER HTML TEXT ///////////////////////////
doc.getElementById("item_cost"+d).innerHTML = new_cost;

if(c.colour && c.size){
doc.getElementById("size_item_extra"+d).innerHTML = "[+"+extra_cost+"]"+a;
doc.getElementById("colour_item_extra"+d).innerHTML = "[+"+other_extra_cost+"]"+ other_select;
}

if(!c.colour && c.size){
doc.getElementById("size_item_extra"+d).innerHTML = "[+"+extra_cost+"]"+a;
}

if(c.colour && !c.size){
doc.getElementById("colour_item_extra"+d).innerHTML = "[+"+extra_cost+"]"+a;
}

if(!c.colour && !c.size){
doc.getElementById("size_item_extra"+d).innerHTML = "";
doc.getElementById("colour_item_extra"+d).innerHTML = "";
}
/////////////////////////////////////////////////////
}
}
////////////////////////////////////////////////////////////////////////
function WindowOpen(url){

window.open(url,'SHOP','width=740,height=640,scrollbars=yes,resizable=yes,location=yes,status=yes,menubar=yes,toolbar=yes');

}

////////////////////////////////////////////////////////////////////////
function ChkForm(form){
var error_cnt = "0";
var alerts = "";
var error = 1;
var s = "S";
var t = "these";
var f = "fields";

if(form.email.value == ""){error_cnt++;alerts += error_cnt+". An email is required\n";error = 0;}
if(form.first_name.value == ""){error_cnt++;alerts += error_cnt+". A first name is required\n";error = 0;}
if(form.last_name.value == ""){error_cnt++;alerts += error_cnt+". A last name is required\n";error = 0;}
if(form.address1.value == ""){error_cnt++;alerts += error_cnt+". Address line one is required\n";error = 0;}
if(form.address2.value == ""){error_cnt++;alerts += error_cnt+". Address line two is required\n";error = 0;}
if(form.city.value == ""){error_cnt++;alerts += error_cnt+". City is required\n";error = 0;}
if(form.state.value == ""){error_cnt++;alerts += error_cnt+". State of County is required\n";error = 0;}
if(form.zip.value == ""){error_cnt++;alerts += error_cnt+". A Zip or Postal code is required\n";error = 0;}
if(form.day_phone_a.value == ""){error_cnt++;alerts += error_cnt+". A day phone prefix is required\n";error = 0;}
if(form.day_phone_b.value == ""){error_cnt++;alerts += error_cnt+". A day phone is required\n";error = 0;}
if(form.email.value && !form.email.value.match(/(\w+).*\@(\w+)\.(\w+)/)){error_cnt++;alerts += error_cnt+". Incorrect email format, try this structure: accountname@domain.suffix\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);
}
}
