// holds an instance of XMLHttpRequest
var xml_Http = createXmlHttpRequestObject();
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
// will store the reference to the XMLHttpRequest object
var xml_Http;
// this should work for all browsers except IE6 and older
try
{
// try to create XMLHttpRequest object
xml_Http = new XMLHttpRequest();
}
catch(e)
{
// assume IE6 or older
try
{
xml_Http = new ActiveXObject("Microsoft.XMLHttp");
}
catch(e) { }
}
// return the created object or display an error message
if (!xml_Http)
alert("Error creating the XMLHttpRequest object.");
else
return xml_Http;
}
	// called to read a file from the server
function addToCart_ajax(pid,size)
{
	//alert('here is pid:'+ pid +'\nhere is size: '+ size);
	if (xml_Http)
	{
		try
		{
			xml_Http.open("GET", "ajax_addtocart.php?pid="+pid+"&size="+size, true);
			xml_Http.onreadystatechange = loadcartdata;
			xml_Http.send(null);
		}
		catch (e)
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}
function loadcartdata()
{
// obtain a reference to the <div> element on the page
	sideCartDiv = document.getElementById("sideCart");
	sideCartloader = document.getElementById("sideCartLoader");
	// display the status of the request
	if (xml_Http.readyState == 1)
	{
		sideCartloader.style.display="block";
		sideCartDiv.style.display="none";
		//myDiv.style.display="none";
	}/*
	else if (xml_Http.readyState == 2)
	{
	myDiv.innerHTML += "Request status: 2 (loaded) <br/>";
	}
	else if (xml_Http.readyState == 3)
	{
	myDiv.innerHTML += "Request status: 3 (interactive) <br/>";
	}
	// when readyState is 4, we also read the server response
	*/
	else if (xml_Http.readyState == 4)
	{
	// continue only if HTTP status is "OK"
		sideCartloader.style.display="none";
		sideCartDiv.style.display="block";
	//myDiv.style.display="block";
		if (xml_Http.status == 200)
		{
			
			try
			{
			// read the message from the server
				response = xml_Http.responseText;
				sideCartDiv.innerHTML = response;
			
			}
			catch(e)
			{
				alert("Error reading the response: " + e.toString());
			}
		}
		else
		{
		alert("There was a problem retrieving the data:\n" +
		xml_Http.statusText);
		}
	}
}
