//                                                                                           ADD ITEM TO CART

function AddItem(Product) {
// check request for errors
pname=parent.header.eval('Tiara.'+Product+'.name');
ErrorFound=false;
gold    =eval("document.UserArea.metal[0].checked")?1:0;    //1 if  gold  is selected
silver  =eval("document.UserArea.metal[1].checked")?1:0;    //1 if silver is selected
quantity=eval("document.UserArea.quantity.value");
if (quantity=="") { quantity="0"; }


if(!ErrorFound) { if (quantity<1) { LowQuantityError(Product,quantity); } }
if(!ErrorFound) { if (quantity==parseInt(quantity)) { null; } else { LowQuantityError(Product,quantity); } }
if(!ErrorFound) { if (!gold) { if (!silver) {  MetalError(Product); } } }
if(!ErrorFound) { HighQuantityCheck(Product,quantity); }
if(!ErrorFound) {  parent.header.eval('UpdateDatabase("'+Product+'","'+gold+'","'+silver+'","'+quantity+'");'); 
alert("You have added "+quantity+" "+pname+" Tiaras to your Shopping Basket\nTo view it's contents, click My Shopping Basket at the top of your screen.");
 }
}

//                                                                                           ERROR MESSAGES


function MetalError(Product) {
alert("Please select your choice of Gold or Silver\ncoloured wire for the "+Product+" Tiara.");
ErrorFound=true;
}

function LowQuantityError(Product,num) {
alert("Sorry, you have chosen to order "+num+" "+pname+" Tiaras.\nPlease enter a valid number.");
ErrorFound=true;
}

function HighQuantityCheck(Product,num) {
if (quantity>8) {
if(!confirm("Are you SURE you wish to order "+num+" "+Product+" Tiaras?")) {ErrorFound=true; } } }

