var xmlHttp;
var pSize=0;
function getXmlHttpObject(){
	var objXMLHttp=null;
	if(window.XMLHttpRequest){
 		objXMLHttp=new XMLHttpRequest();
 	}else if(window.ActiveXObject){
 		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
 	}
 	return objXMLHttp;
}
function showProducts(page_id){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("You are using a too old browser. Please update the browser.");
		return;
	}else{
		var url="../scripts/products_list.php";
		url=url+"?page="+page_id;
		xmlHttp.onreadystatechange=loadAny;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		
}
function showShoppingCart(item_id,action,qty){
	if(action=="update" && !qty){
		qty=0;
	}
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("You are using a too old browser. Please update the browser.");
		return;
	}else{
var url="../scripts/shopping_cart.php";
url=url+"?id="+item_id+"&action="+action+"&qty="+qty;
xmlHttp.onreadystatechange=function(){
	if(xmlHttp.readyState!=4){
		document.getElementById('body').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById('body').innerHTML=xmlHttp.responseText;
		if(action=="update" && qty==0){
			txtBoxName="txt"+item_id;
			document.forms[0].elements[txtBoxName].value="";
		}	
			document.forms[0].elements[txtBoxName].focus();
	}	
	}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
   		 }		
}
function showCartSummery(){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("You are using a too old browser. Please update the browser.");
		return;
	}else{
		var url="../scripts/shopping_cart_summery.php";
		xmlHttp.onreadystatechange=loadAny;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		
}
function loadAny(){
	if(xmlHttp.readyState!=4){
		document.getElementById('body').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById('body').innerHTML=xmlHttp.responseText;
	}
}
function showPrice(size_id,size_count,price){
		for(x=1;x<=size_count;x++){
				if(size_id==x){
						document.getElementById('s'+x).className="linked_td_sel";
						document.getElementById('pPrice').innerHTML='$'+price;
						document.forms[0].txtQty.value="";
						document.forms[0].txtQty.focus();
						pSize=size_id;
					}
				else{
						document.getElementById('s'+x).className="linked_td";
					}
			}
	}
function addToCart(pId,size,pQty,action){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("You are using a too old browser. Please update the browser.");
		return;
	}else{
		var url="../scripts/mini_cart.php";
		url=url+"?pId="+pId+"&size="+size+"&pQty="+pQty+"&action="+action;
		xmlHttp.onreadystatechange=loadMiniCart;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}
function showMiniCart(action){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("You are using a too old browser. Please update the browser.");
		return;
	}else{
		var url="../scripts/mini_cart.php";
		url=url+"?action="+action;
		xmlHttp.onreadystatechange=loadMiniCart;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}
function loadMiniCart(){
	if(xmlHttp.readyState!=4){
		document.getElementById("mini_cart_body").innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById("mini_cart_body").innerHTML=xmlHttp.responseText;	
	}
}
