US = new Array("GND|Ground","1DA|Next Day Air","2DA|2nd Day Air","3DS|3 Day Select");
CANADA = new Array("STD|Canada Standard");
WORLD = new Array("XPR|Worldwide Express","XDM|Worldwide Express Plus","XPD|Worldwide Expedited","WXS|Worldwide Saver");

function remfromcart(cart_item_id){
	if(confirm("Are you sure you want to remove this?")){location.href="cart_processing.asp?remove="+cart_item_id;}
}

function go_payment(){
	objcartdiv = document.getElementById("shopping_cart_wrap");
	objloadingdiv = document.getElementById("loadingpayment");
	objcartdiv.style.display = "none";
	objloadingdiv.style.display = "block";
	frm = document.forms["cart_frm"];
	frm.submit(frm);		
}

	function ClearBox(BOX){for(i=BOX.length;i>=0;i--){BOX.options[i]=null;}}
 
	function AddOption(BOX,TEXT,VALUE,POS){
		if(!POS)POS=0;
		newoption = new Option(TEXT,VALUE, false, false);
		BOX.options[POS] = newoption;
	}
	
	function AutoFillShipping(shipdata,default_selection){
		FRM = document.forms["shipping_form"];
		//temp = data.split(",");
		BOX = FRM.ship_service;
		ClearBox(BOX);
		for(Z=0;Z<shipdata.length;Z++){
			infostr = shipdata[Z];
			vals = infostr.split("|");
			fldid = vals[0];
			fldval = vals[1];
			AddOption(BOX,fldval,fldid,BOX.length);
			if(default_selection.toLowerCase() == fldid.toLowerCase()){
				BOX.selectedIndex = Z;
			}
		}	
	}
	
	function ShowShippingSelection(default_selection){
		FRM = document.forms["shipping_form"];
		if(FRM.country.type == "hidden"){
			selcountry = FRM.country.value;
		}
		else{
			selcountry = FRM.country.options[FRM.country.options.selectedIndex].value;
		}
		
		selcountry = selcountry.toLowerCase();
		if(selcountry=="us" || selcountry == "pr"){loopfields = US;}
		else if(selcountry=="ca"){loopfields = CANADA;}
		else {loopfields = WORLD;}
		AutoFillShipping(loopfields,default_selection);
	}

	function CheckAddForm(FRM){
		errors = "";
		if(FRM.City.value=="")errors+="Please enter the recipients city in\n";
		if(FRM.Zip.value=="")errors+="Please enter the recipients zip code in\n";
		if(errors=="")FRM.submit(FRM);
		else alert(errors);
	}