function htmlData1(country_i,start,bck,site){	//alert(country_i);	//document.getElementById('country_id').value = country_i;	var url = '';	if ((site == 'size') || (defaultSite == 'size')){		url = '/php/style_cabinet_size.php?parent_id='+country_i;	}else if ((site == 'search') || (defaultSite == 'search')){		url='/php/style_search.php?parent_id='+country_i+'&start='+start+'&bck='+bck;	}else{		url='/php/style_cabinet.php?parent_id='+country_i+'&start='+start+'&bck='+bck;	}	//alert(url);	xmlGet(url, function(){ stateChange(); });	//product_parent=country_i;}function stateChange(){	if (req.readyState == 4){// 4 = "loaded"		if (req.status == 200){// 200 = "OK"			//document.getElementById('txtResult').innerHTML='';		    document.getElementById('txtResult').innerHTML=req.responseText;			//alert(req.responseText);	    }else{		    alert("Problem retrieving data:" + xmlhttp.statusText);	    }	}else{		document.getElementById('txtResult').innerHTML='<table width="120px" align="center"><tr><td><IMG SRC="images/please_wait.gif" WIDTH="104" HEIGHT="104" BORDER="0" ALT=""></td></tr><table>';	}}function paging(country_i,start,sort,site){	//alert(country_i);	//document.getElementById('country_id').value = country_i;	var url = '';	if (site == 'size'){		url='/php/style_cabinet_size.php?parent_id='+country_i+'&start='+start+'&sort_by='+sort;	}else if (site == 'search'){		url='/php/style_search.php?parent_id='+country_i+'&start='+start+'&sort_by='+sort;	}else{		url='/php/style_cabinet.php?parent_id='+country_i+'&start='+start+'&sort_by='+sort;	}	//alert(url);	//product_parent=country_i;	xmlGet(url, function(){ pageChange(); });}function pageChange(){	if (req.readyState == 4){// 4 = "loaded"		if (req.status == 200){// 200 = "OK"			//document.getElementById('txtResult').innerHTML='';			document.getElementById('txtResult').innerHTML=req.responseText;			//alert(xmlhttp.responseText);		}else{			alert("Problem retrieving data:" + xmlhttp.statusText);		}	}else{		document.getElementById('txtResult').innerHTML='<table width="120px" align="center"><tr><td><IMG SRC="images/please_wait.gif" WIDTH="104" HEIGHT="104" BORDER="0" ALT=""></td></tr><table>';	}}function order_by(country_i,sort_by,site){	//alert(country_i);	//document.getElementById('country_id').value = country_i;	var url = '';	if (site == 'size'){		url='/php/style_cabinet_size.php?parent_id='+country_i+'&sort_by='+sort_by;	}else if (site == 'search'){		url='/php/style_search.php?parent_id='+country_i+'&sort_by='+sort_by;	}else{		url='/php/style_cabinet.php?parent_id='+country_i+'&sort_by='+sort_by;	}	//alert(url);	//product_parent=country_i;	xmlGet(url, function(){ sort_order(); });}function sort_order(){	if (req.readyState==4){// 4 = "loaded"		if (req.status==200){// 200 = "OK"			//document.getElementById('txtResult').innerHTML='';		    document.getElementById('txtResult').innerHTML = req.responseText;			//alert(xmlhttp.responseText);	    }else{			alert("Problem retrieving data:" + req.statusText);		}	}else{		document.getElementById('txtResult').innerHTML='<table width="120px" align="center"><tr><td><IMG SRC="images/please_wait.gif" WIDTH="104" HEIGHT="104" BORDER="0" ALT=""></td></tr><table>';	}}function showUser(val,country_id, site){	//var cot_id = document.getElementById('country_id').value;	//alert(val);	//alert(country_id);	var url = '';	if (site == 'size'){		url='/php/style_cabinet_size.php?start='+val+'&country_id='+country_id;	}else if (site == 'search'){		url='/php/style_search.php?start='+val+'&country_id='+country_id;	}else{		url='/php/style_cabinet.php?start='+val+'&country_id='+country_id;	}	//alert("hi");	//alert(url);	//product_parent=country_i;	xmlGet(url, function(){ stateChange_shopping(); });}function stateChange_shopping(){	if (req.readyState==4){// 4 = "loaded"		if (req.status==200){// 200 = "OK"			///document.getElementById('txtResult').innerHTML='';		    document.getElementById('txtResult').innerHTML=req.responseText;			//alert(xmlhttp.responseText);	    }else{			alert("Problem retrieving data:" + req.statusText);		}	}}function isInteger (s){	var i;	if (isEmpty(s)){		if (isInteger.arguments.length == 1){			return 0;		}else{			return (isInteger.arguments[1] == true);		}	}	for (i = 0; i < s.length; i++){		var c = s.charAt(i);		if (!isDigit(c)){			return false;		}	}	return true;}function isEmpty(s){	return ((s == null) || (s.length == 0));}function isDigit (c){	return ((c >= "0") && (c <= "9"));}function add2cart(kk, redir){	id = document.getElementById('h_' + kk).value;	qty = document.getElementById('q_' + id).value;	qty = parseInt(qty, 10);		if (qty > 0){		var url='/php/add_cart.php?id=' + id + '&qty=' + qty;		//alert(url);		xmlGet(url, function(){ stateChange_shoppingCart(redir); });	}}function wish2cart(ids, qtys){	var url='/php/add_cart.php?querycart=' + ids + '&qty=' + qtys;	//alert(url);	xmlGet(url, function(){ stateChange_wishCart(); });}function stateChange_wishCart(){	if (req.readyState==4){		if (req.status==200){			// document.getElementById('txtResult_1').innerHTML=xmlhttp.responseText;			opener.location = '/shopping_cart.php';			window.close();			//alert("Your item has been added to your cart.  You may continue shopping.");			//window.location='/shopping_cart.php';		}else{			alert("Problem retrieving data:" + req.statusText);		}	}}/*function addcart() {	var total_prd = document.getElementById('total_no_item').value;	var myCart = new Array();	var i;	var querystring = '';	var amp = '';	var product = 'scheck';	var qty = 'qty';	var flg_qty = false;	var valid = true;	for( i=0 ; i<total_prd ; i++){		var h='h_'+i;			myCart[i] = document.getElementById(h).value;		var q = 'q_' + myCart[i];		if (document.getElementById(q).value > 0){			product += "*"+myCart[i];			qty += "*"+document.getElementById(q).value;			querystring = product+'&qty='+qty;			flg_qty = true;		}        if (!(isInteger(document.getElementById(q).value))){			alert("Please enter Valid Quantity");			return false;		}	}//for loop close here    if (!flg_qty){		alert('please enter the quantity and proceeds again');		return false;	}else{		//alert("query string=>"+querystring);		shopping_cart(querystring);	}}function shopping_cart(querycart){	var url='/php/add_cart.php?querycart='+querycart;	//alert(url);	xmlGet(url, function(){ stateChange_shoppingCart(); });	}*/function stateChange_shoppingCart(redir){	if (req.readyState==4){		if (req.status==200){			// document.getElementById('txtResult_1').innerHTML=xmlhttp.responseText;			//opener.location = '/shopping_cart.php';			//window.close();			if (redir != null){				window.location=redir;			}else{				alert("Your item has been added to your cart.  You may continue shopping.");			}		}else{			alert("Problem retrieving data:" + req.statusText);		}	}}function change_total(fld, price, i){	var sub_total = 'sb_'+i;	var total = 0;	var vr = 1;	var qty = fld.value;	if (!(isInteger(qty))){		alert("Please enter Valid Quantity");		fld.value = 0;		fld.focus();		return true;	}    // This is not right.  The user must not see the changes unless the cart is really updated.    // Must trigger the update.        cart_update();        /*	//document.form["quantity[]"][i].value=qty*price;	document.getElementById(sub_total).innerHTML = '$' + (qty * price).toFixed(2);	for(var i=0;i < (document.form1["total_prc[]"].length);i++){		vr = 0;		total += ((document.form1["total_prc[]"][i].value) * (document.form1["quantity[]"][i].value));	}	if (vr == 1){		total += ((document.getElementById('prc_1').value) * (document.getElementById('qty_1').value));	}	document.getElementById('total').innerHTML='Total Price $' + total.toFixed(2);	*/}function ContinueShopping()	{	var page = document.getElementById('page_name').value;	var page_itemname = document.getElementById('page_itemname').value;	var page_product_id = document.getElementById('page_product_id').value;	if ((page == "item") && (page_itemname != "") && (page_product_id != "")){		var page = 'itemnew.php?itemname=' + page_itemname + '&product_id=' + page_product_id;		window.location = page;	}else{		window.location="view_cabinet.php?category=base&style_id=1";	}}function remove_cart(){	var query = '';	var j = 0;	var cc = 0;	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";	var elements = document.form1.elements;	//alert(elements.length);	var pairs = new Array();	for (var i = 0; i < elements.length; i++) {		if ((name = elements[i].name) && (value = elements[i].value)){			//alert(name);			//alert(elements[i].checked);			if(name == 'product_id[]' && (!(elements[i].checked))){				//alert(elements[i].value);				pairs.push(name + "=" + encodeURIComponent(value));				j = i + 2;				name = elements[j].name;				value = elements[j].value;				pairs.push(name + "=" + encodeURIComponent(value));				//alert(elements[j].value);			}else if (name == 'product_id[]' && ((elements[i].checked))){				cc++;			}			//alert("Hi");		}	}	//alert(cc);	if(cc == 0){		alert("You haven't selected any item for deletion");		return false;	}	query = pairs.join("&");	// 	end of building of query string	//alert(query);	 	// Just send to update, the checked item is already removed. 	// update will clear the cart and simply add back the items sent here. 	var url='/php/cart_update.php';	//var url='/php/remove_cart.php';	xmlPost(url, query, function(){ state_alert(); });}		function wait(){	document.getElementById('apDiv1').style.display='none';	document.getElementById('apDiv1').innerHTML='';}function checkproduct(check){	//var cc=0;	var cc = document.form1.elements.length;		//var elements = document.form1.elements;	//var pairs = new Array();	//for (var i = 0; i < elements.length; i++) {	//	cc++;	//}	if(cc == 1){		alert("Your Cart is Empty please add to cart first");	}else{		if (check == 0){			alert("Your Cart is Empty please add to cart first");		}else{			//window.location="/checkout.php?user=guest";			window.location="https://www.uscabinetry.com/checkout.php?user=guest";		}	}}function checkout_check(check){	//var cc = 0;	//var elements = document.form1.elements;	//var pairs = new Array();	var cc = document.form1.elements.length;	//for (var i = 0; i < elements.length; i++) {	//	cc++;			//}	if(cc == 1){		alert("Your Cart is Empty please add to cart first");	}else{		if (check == 0){			alert("Your Cart is Empty please add to cart first");		}else{			window.location="https://www.uscabinetry.com/checkout.php";		}	}}function save_cart(){	var url = '/php/save_cart.php';	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";	var elements = document.form1.elements;	var pairs = new Array();	for (var i = 0; i < elements.length; i++) {		if ((name = elements[i].name) && (value = elements[i].value)){			if (name == 'product_id[]'){				pairs.push(name + "=" + encodeURIComponent(value));				j = i + 2;				name = elements[j].name;				value = elements[j].value;				pairs.push(name + "=" + encodeURIComponent(value));				j = i + 3;				name = elements[j].name;				value = elements[j].value;				pairs.push(name + "=" + encodeURIComponent(value));			}		}	}	query=pairs.join("&");	xmlPost(url, query, function(){ state_save(); });}function state_save(){	if (req.readyState==4){// 4 = "loaded"		if (req.status==200){// 200 = "OK"			//alert(xmlhttp.responseText);			if(req.responseText == "login.php"){				self.location='login.php';			}else if(req.responseText=="<b>The cart is saved.</b>"){				//document.writ(xmlhttp.responseText);				document.getElementById('apDiv1').innerHTML="<b>The cart is saved.</b>";					document.getElementById('apDiv1').style.display='';				setTimeout("wait()",3000);			}		}else{			alert("Problem retrieving data:" + req.statusText);		}	}}		 function cart_update(){	var query = '';	var j = 0;		/*if(document.form1["product_id[]"].length==0)		{			alert("No items selected");			return false;		}		else if(!(document.getElementById('product_1').checked))		{			alert("No items selected");			return false;		}*/		// Building the query string//	var contentType = "application/x-www-form-urlencoded; charset=UTF-8";	var elements = document.form1.elements;	var pairs = new Array();	for (var i = 0; i < elements.length; i++) {		if ((name = elements[i].name) && (value = elements[i].value)){			// Update should not care about the checkbox.			//if (name == 'product_id[]' && (!(elements[i].checked)) ){			if (name == 'product_id[]'){				pairs.push(name + "=" + encodeURIComponent(value));				j = i + 2;				name = elements[j].name;				value = elements[j].value;				pairs.push(name + "=" + encodeURIComponent(value));			}		}	}	query = pairs.join("&");	// 	end of building of query string	//alert(query);	var url='/php/cart_update.php';	xmlPost(url, query, function(){ state_alert(); });}function state_alert(){	if (req.readyState==4){// 4 = "loaded"		if (req.status==200){// 200 = "OK"			//alert(xmlhttp.responseText);			//document.getElementById('cart').innerHTML='';			document.getElementById('cart').innerHTML=req.responseText;				//alert("The selected item has been added to the shopping cart");			document.getElementById('apDiv1').style.display='';			setTimeout("wait()",3000);		}else{			alert("Problem retrieving data:" + req.statusText);		}	}}function ship(fedex){	//alert(country_i);	if (fedex.selectedIndex == 0){		return false;	}		var country = document.getElementById('ship_country'); 	var state = document.getElementById('ship_state');	var zipcode = document.getElementById('ship_post_code'); 	var price = document.getElementById('total_price').value;	var weight = document.getElementById('total_weight').value;	var url="/php/ship.php?fedex="+fedex.value+"&country="+country.options[country.selectedIndex].value+"&state="+state.options[state.selectedIndex].value+"&zipcode="+zipcode.value+"&price="+price+"&weight="+weight;	//alert(url);	//product_parent=country_i;    // Some error checking.    if (country.selectedIndex == 0){    	fedex.selectedIndex = 0;    	alert("Please choose the shipping country.");    	country.focus();    	return false;    }        if (zipcode.value.length < 5){    	fedex.selectedIndex = 0;    	alert("Please enter your shipping zip/postal code.");    	zipcode.focus();    	return false;    }        xmlGet(url, function (){ ship_res(); });    }function ship_res(){	if (req.readyState == 4){// 4 = "loaded" 		if (req.status == 200){// 200 = "OK"			document.getElementById('txtResult').innerHTML = '';			document.getElementById('txtResult').innerHTML = req.responseText;	    }else{		    alert("Problem retrieving data:" + xmlhttp.statusText);		}	}}function addwishlist(id) {	var qty1 = 'q_' + id;	//alert(qty1);	var qty = document.getElementById(qty1).value;	//alert(qty);	if (qty == 0){		alert("Please enter Valid Quantity");		return false;	}else{		//alert("before");		var url = '/php/add_wishlist.php?pid=' + id + '&qty=' + qty;//+'&sid='+Math.rand();		//alert(url);		alert("Added in your parts List");		xmlGet(url, null);	}}function remove_product(mid){	//	var url='add_wishlist.php?id='+id+'&';	var url="/php/add_wishlist.php?id="+mid+"&sid="+Math.random();	xmlGet(url, function() { reLoad()});	}function reLoad(){	if (req.readyState==4){// 4 = "loaded"		if (req.status==200){// 200 = "OK"			document.location.reload(true);		}	}}function searchInstallers(country_i){	var url='/php/installer.php?state='+country_i;	xmlGet(url, function(){ stateChange() });}