function ShowCart() 
{
	document.getElementById("cartcontainer").style.display = "block";
	GetCartItems();
};

function HideCart() 
{
	document.getElementById('divCART').innerHTML = "";
	document.getElementById("cartcontainer").style.display = "none";
};

var xmlHttp3;
var responsefunc = null;
function GetAddItemToCart()
{ 
//			alert("!null");
	if (xmlHttp3.readyState==4)
	{ 
//		document.getElementById('divCART').innerHTML = xmlHttp3.responseText;
		if( responsefunc != null )
		{

			responsefunc(xmlHttp3.responseText);
		}
		responsefunc = null;
		xmlHttp3=null;
	}
}
function AddItemToCart( eLink, myfun )
{ 
	var szItem = eLink.id;
	responsefunc = myfun;
	
	var url="/ShopMachine/CartProc.asp";
	var cmd = "add";
	url = url + "?cmd=" + cmd + "&szItem=" + szItem;

	
	xmlHttp3=GetXmlHttpObject();
	if (xmlHttp3==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
    } 
	
	xmlHttp3.onreadystatechange=GetAddItemToCart;
	xmlHttp3.open("GET",url, true);
	xmlHttp3.send(null);
}




function RemoveCartItem( eLink )
{ 
	var ItemID = eLink.id;
	
	
	var url="/shopmachine/CartProc.asp";
	var cmd = "remove";
	url = url + "?cmd=" + cmd + "&ItemID=" + ItemID;
//	window.open (url,"mywindow");	
	
//	return;
	
	xmlHttp3=GetXmlHttpObject();
	if (xmlHttp3==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
    } 
	
	xmlHttp3.onreadystatechange=GetRemoveCartItem;	
	xmlHttp3.open("GET",url, false);
	xmlHttp3.send(null);
	xmlHttp3 = null;
	GetCartItems();
}

function GetRemoveCartItem()
{ 
	if (xmlHttp3.readyState==4)
	{ 
		alert(xmlHttp3.responseText);
		xmlHttp3=null;
	}
}

var xmlHttp1;
function GetCartItems()
{ 
	var url="/ShopMachine/GetCart.asp";
	
	xmlHttp1=GetXmlHttpObject();
	if (xmlHttp1==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
    } 
	
	xmlHttp1.onreadystatechange=GotCartItems;
	xmlHttp1.open("GET",url, true);
	xmlHttp1.send(null);
}


function GotCartItems() 
{ 
	if (xmlHttp1.readyState==4)
	{ 
		document.getElementById('divCART').innerHTML = xmlHttp1.responseText;
		xmlHttp1=null;
	}
}
