var xmlhttpobj;

function GetXmlHttpObject()
{
	var xmlHttpObj = null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttpObj = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
    	{
    		xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
    	}
		catch (e)
		{
			xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttpObj;
}

function sendRequest(id, add)
{
	xmlhttpobj = GetXmlHttpObject();
	
	if (xmlhttpobj == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	
	var string = 'id=' + id + '&add=' + add;
		
	xmlhttpobj.onreadystatechange = stateChanged;
	xmlhttpobj.open("POST", 'scripts/ajax-script.php', true);
	
	xmlhttpobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttpobj.setRequestHeader("Content-length", string.length);
	xmlhttpobj.setRequestHeader("Connection", "close");

	xmlhttpobj.send(string);
}

function stateChanged() 
{ 
	if (xmlhttpobj.readyState == 4)
		document.getElementById("cart").innerHTML = xmlhttpobj.responseText;
}
