//alert('ds');
var qty;
var http;// = getHTTPObject();
var iProductId;// = getHTTPObject();
function handleHttpResponse_cart() 
{ 
	if (http.readyState == 4) 
	{
      	isWorking = false;
    	if (http.responseText.indexOf('invalid') == -1) 
		{
			var xmlDocument = http.responseXML;
			var msg = xmlDocument.getElementsByTagName('msg').item(0).firstChild.data;
			var TotalCart = xmlDocument.getElementsByTagName('totalcart').item(0).firstChild.data;
			if(document.getElementById("totalitem"))
				document.getElementById("totalitem").innerHTML = "("+parseInt(TotalCart)+")";
			//alert(document.getElementById('cart_message'));			
			document.getElementById('cart_message').style.display='';
			document.getElementById('div-loading-list').style.display='';
			if(document.body.clientHeight>document.documentElement.clientHeight)
				var obj_div_height =  document.body.clientHeight;
			else
				var obj_div_height =  document.documentElement.clientHeight;
				
			if(document.body.clientWidth>document.documentElement.clientWidth)
				var obj_div_width =  document.body.clientWidth;
			else
				var obj_div_width =  document.documentElement.clientWidth;

			obj_width = parseInt(parseInt(screen.width-500)/2);
			obj_height = parseInt(parseInt(screen.height-100)/2);
			//alert(obj_height);
			
			document.getElementById('div-loading-list').style.width=(obj_div_width)+'px';
			document.getElementById('div-loading-list').style.height=(parseInt(obj_div_height+50))+'px';
			
			document.getElementById('cart_message').style.top=(obj_height)+'px';
			document.getElementById('cart_message').style.left=(obj_width)+'px';
			
	
			//document.getElementById('cart_message').style.
			//if(document.getElementById('iqty'))
			//	document.getElementById('iqty').value += qty;
			//TB_show("Shopping Cart", "#TB_inline?height=85&width=450&inlineId=cart_message", "");
			/*if(msg!='')
			{
				document.getElementById('showcartmsg').innerHTML = msg;
				document.getElementById('main_tp').style.display='';
			}*/
			//setTimeout("hideCartDiv();",3000);
		}
  	}
}
function addToCart(iProId) 
{
	var qty = 1;
	var iProductAttributeId = iProId;
	var url = "addToCart.php?iProductAttributeId="+iProductAttributeId+"";
	//alert(url);
	var isWorking = false;
	if (!isWorking)
	{
		isWorking = true;
		if (window.XMLHttpRequest)
	  	{
	  		http=new XMLHttpRequest()
	  		http.open("GET",url, true);
		  	http.onreadystatechange=handleHttpResponse_cart
		  	http.send(null)
	  	}
		// code for IE
		else if (window.ActiveXObject)
	  	{
	  		http=new ActiveXObject("Microsoft.XMLHTTP")
	    	if (http)
	    	{
	    		http.open("GET",url, true);
	    		http.onreadystatechange=handleHttpResponse_cart
	    		http.send()
	    	}
	  	}
  	}
}

function view_cart()
{
	window.location = secure_url+'cart/mybasket/';
	return false;
}
function remove_element()
{
	document.getElementById('div-loading-list').style.display='none';
	document.getElementById('cart_message').style.display='none';
}