var country_code;function handleDivTag(divtag){   var divtag;   return divtag;}function createRequestObject() {	var req;	if(window.XMLHttpRequest){		req = new XMLHttpRequest();	} else if(window.ActiveXObject) {		req = new ActiveXObject("Microsoft.XMLHTTP");	} else {		alert("There was a problem creating the XMLHttpRequest object");	}	return req;}var http_ship = createRequestObject();var divhandler_ship = new handleDivTag(null);function sendRequest_ship(zip, ship, divtag) {	if (divtag == "small_cart") {		document.getElementById(divtag).innerHTML = "<div style='padding-left: 80px'>Recalculating...</div>";		if (zip == "") var more = "shipping="+ship;		if (ship=="") var more = "zip="+zip; 		setTimeout("handleResponse_ship('"+more+"','"+divtag+"')",100);	}}function handleResponse_ship(more, divtag) {	var url = "ship_checkout.php?"+more;	var xml = new JKL.ParseXML(url);	var data = xml.parse();	if(data) {		document.getElementById(divtag).innerHTML = data.instance.cart;		document.getElementById("s_zip").disabled = false;		action_cert("update", "");				//UPDATE BUTTON AREA		if (data.instance.noShip == 1 && data.instance.button) {			alert('Sorry, but none of the products in your cart are available to be shipped to this location.');			if (document.getElementById('buttonArea')) {				document.getElementById('buttonArea').innerHTML = data.instance.button;						}		} else if (data.instance.button) {			if (document.getElementById('buttonArea')) {				document.getElementById('buttonArea').innerHTML = data.instance.button;						}				}	}}function ship_zip(zip, event) {	var objRegExp  = /(^-?\d\d*$)/;	var int_go = false;	//alert(event);	if (event) {		if (event.keyCode) {			code = event.keyCode;			if ((code > 47 && code < 58) || (code > 95 && code < 106)) int_go = true;		}	}	else {		int_go = true;		}	var country_code = "";	if (document.getElementById("s_country")) country_code = document.getElementById("s_country").value;	if (country_code == "US" || country_code == "CA") {		if (objRegExp.test(zip) && zip.length == 5 && int_go) {			//alert(zip);			//document.write("Zip: "+zip);			document.getElementById("s_zip").disabled = true;			var more = "zip="+zip;			//			var url = "filebin/xml/ship_option_xml.php?zip="+zip+"&country_code="+country_code;			//alert(url);			var xml = new JKL.ParseXML(url);			var data = xml.parse();			// pass country			if (data) {				if (data["ship_options"]) {					if (document.getElementById("shipping_checkout_div")) document.getElementById("shipping_checkout_div").innerHTML = data["ship_options"];					sendRequest_ship(zip+"&country_code="+country_code, "", 'small_cart');				}			}			//let's check state:			check_state_zip(zip);			document.getElementById("s_phone_0").focus();		}		else if (zip.replace(/\s+/g,'').length == 6) {			//CA			document.getElementById("s_zip").disabled = true;			var more = "zip="+zip+"&country_code="+country_code;			//we need to get Canada Province for tax			if (document.getElementById("s_state")) {				var canada_province = document.getElementById("s_state").value;				more += "&canada_province="+canada_province;			}			var url = "filebin/xml/ship_option_xml.php?"+more;			var xml = new JKL.ParseXML(url);			var data = xml.parse();			if (data) {				if (data["ship_options"]) {					if (document.getElementById("shipping_checkout_div")) document.getElementById("shipping_checkout_div").innerHTML = data["ship_options"];					sendRequest_ship(zip+"&canada_province="+canada_province+"&country_code="+country_code, "", 'small_cart');				}			}					//sendRequest_ship(zip, "", 'small_cart');			//let's check state			check_state_zip(zip);			document.getElementById("s_phone_0").focus();		}	}}//Addition for pastefunction ship_zip_prep() {	setTimeout("ship_zip_mod()",100);}function ship_zip_mod() {	var country_code = "";	if (document.getElementById("s_country")) country_code = document.getElementById("s_country").value;	var objRegExp  = /(^-?\d\d*$)/;	if (document.getElementById('s_zip')) {		var zip = document.getElementById('s_zip').value;	}		if (country_code == "US" || country_code == "CA") {		if (objRegExp.test(zip) && zip.length == 5 && country_code == "US") {			//alert(zip);			//document.write("Zip: "+zip);			document.getElementById("s_zip").disabled = true;			var more = "zip="+zip;			//			var url = "filebin/xml/ship_option_xml.php?zip="+zip+"&country_code="+country_code;			//alert(url);			var xml = new JKL.ParseXML(url);			var data = xml.parse();			// pass country			if (data) {				if (data["ship_options"]) {					if (document.getElementById("shipping_checkout_div")) document.getElementById("shipping_checkout_div").innerHTML = data["ship_options"];					sendRequest_ship(zip+"&country_code="+country_code, "", 'small_cart');				}			}			//let's check state:			check_state_zip(zip);			document.getElementById("s_phone_0").focus();		} else if (zip.replace(/\s+/g,'').length == 6) {			//CA			document.getElementById("s_zip").disabled = true;			var more = "zip="+zip+"&country_code="+country_code;			//we need to get Canada Province for tax			if (document.getElementById("s_state")) {				var canada_province = document.getElementById("s_state").value;				more += "&canada_province="+canada_province;			}			var url = "filebin/xml/ship_option_xml.php?"+more;			var xml = new JKL.ParseXML(url);			var data = xml.parse();			if (data) {				if (data["ship_options"]) {					if (document.getElementById("shipping_checkout_div")) document.getElementById("shipping_checkout_div").innerHTML = data["ship_options"];					sendRequest_ship(zip+"&canada_province="+canada_province+"&country_code="+country_code, "", 'small_cart');				}			}					//sendRequest_ship(zip, "", 'small_cart');			//let's check state			check_state_zip(zip);			document.getElementById("s_phone_0").focus();		}	}}//function select_state_checkout(obj) {	//get country code through attribute country	if (obj.options[obj.selectedIndex].getAttribute("country")) country_code = obj.options[obj.selectedIndex].getAttribute("country");	else country_code = "";	if (document.getElementById("s_zip")) {		var s_zip = document.getElementById("s_zip");		//alert(country_code+" "+s_zip.value.length);		if ((s_zip.value.length == 5 || s_zip.value.replace(/\s+/g,'').length == 6) && country_code != "") {			//Validate			if (s_zip.value.length == 5 && country_code == "CA") alert("State/Province doesn't match zip/postal code");			if (s_zip.value.replace(/\s+/g,'').length == 6 && country_code == "US") alert("State/Province doesn't match zip/postal code");			//If canada province selected and postal code is not empty			if (s_zip.value.replace(/\s+/g,'').length == 6 && country_code == "CA") {				var more = "zip="+s_zip.value.replace(/\s+/g,'');				//we need to get Canada Province for tax				//if (document.getElementById("s_state")) {				var canada_province = document.getElementById("s_state").value;				more += "&canada_province="+canada_province;				//}				var url = "filebin/xml/ship_option_xml.php?"+more;				var xml = new JKL.ParseXML(url);				var data = xml.parse();				if (data) {					if (data["ship_options"]) {						if (document.getElementById("shipping_checkout_div")) document.getElementById("shipping_checkout_div").innerHTML = data["ship_options"];						sendRequest_ship(s_zip.value.replace(/\s+/g,'')+"&canada_province="+canada_province, "", 'small_cart');					}				}			}		}	}	//alert(country_code);	//change country based on country_code	}function check_state_zip(zip) {	if (country_code != "") {		if (zip.length == 5 && country_code == "CA") alert("State/Province doesn't match zip/postal code");		if (zip.replace(/\s+/g,'').length == 6 && country_code == "US") alert("State/Province doesn't match zip/postal code");	}}function select_country_checkout(obj) {		}function set_country_code() {	if (document.getElementById("s_state")) {		obj = document.getElementById("s_state");		if (obj.options[obj.selectedIndex].getAttribute("country")) country_code = obj.options[obj.selectedIndex].getAttribute("country");		else country_code = "";	}	else {		country_code = "";	}}function ship_country(zip, country_code) {	if (country_code != "") {		//alert(zip);		//document.write("Zip: "+zip);		//document.getElementById("s_zip").disabled = true;		//var more = "zip="+zip;		//		// new Alex L.		//var zip = document.getElementById("s_zip").value;		//end new		var url = "filebin/xml/ship_option_xml.php?country_code="+country_code+"&zip="+zip;		var xml = new JKL.ParseXML(url);		var data = xml.parse();		if (data) {			if (data["ship_options"]) {				if (document.getElementById("shipping_checkout_div")) document.getElementById("shipping_checkout_div").innerHTML = data["ship_options"];				//sendRequest_ship(country_code, "", 'small_cart');				sendRequest_ship(zip+"&country_code="+country_code, "", 'small_cart');			}		}	}}function newShippingFunc() {	if (document.getElementById('s_zip')) {		//alert("Zip");		var ship_zip_element = document.getElementById('s_zip');		if (ship_zip_element.addEventListener){			ship_zip_element.addEventListener('paste',ship_zip_prep,false);			//alert("paste");		} else if (ship_zip_element.attachEvent){			ship_zip_element.attachEvent('onpaste', ship_zip_prep);			//alert("onpaste");		}	}}addOnloadEvent(newShippingFunc);