var xmlHttp;

function add_to_cart(item_id)
{
  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	} 
  //  Set our destination PHP page "ajaxpost.php"…
  xmlHttp.open("POST", "actions.php", Math.random());
  xmlHttp.onreadystatechange = contact_feedback;
  
  // Make our POST parameters string…
  var params = "&items="+encodeURI( document.getElementById('items_'+item_id).value) +
  	           "&title="+encodeURI( document.getElementById("title_"+item_id).value ) +
			   "&price="+encodeURI( document.getElementById("price_"+item_id).value ) +
			   "&weight="+encodeURI( document.getElementById("weight_"+item_id).value ) +
			   "&ship_uk="+encodeURI( document.getElementById("ship_uk_"+item_id).value ) +
			   "&ship_os="+encodeURI( document.getElementById("ship_os_"+item_id).value ) +
			   "&actionid=addcart" +
			   "&qty="+encodeURI( document.getElementById("qty_"+item_id).value );
  // Set our POST header correctly…
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");

  // Send the parms data…
  xmlHttp.send(params);

}

function contact_feedback() 
{ 
 	
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	var str = xmlHttp.responseText;
	document.getElementById("shopping_cart").innerHTML=xmlHttp.responseText;
	return false;
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;

try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function empty_the_cart()
{
  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	} 
  //  Set our destination PHP page "ajaxpost.php"…
  xmlHttp.open("POST", "actions.php", Math.random());
  xmlHttp.onreadystatechange = contact_feedback;
  
  // Make our POST parameters string…
  var params = "&actionid=empty";
  // Set our POST header correctly…
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");

  // Send the parms data…
  xmlHttp.send(params);

}

function default_func()
{
  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	} 
  //  Set our destination PHP page "ajaxpost.php"…
  xmlHttp.open("POST", "viewcart.php", Math.random());
  xmlHttp.onreadystatechange = contact_feedback;
  
  // Make our POST parameters string…
  var params = "&act=view";
  // Set our POST header correctly…
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");

  // Send the parms data…
  xmlHttp.send(params);

}
