function LoadMyCart(redirecto)
{
	var url="processcart.php";
	var params="to="+redirecto;

	function callbackResponse(xmlHttp)
	{
		var el = document.getElementById('MasterCartForm');
		el.innerHTML=xmlHttp.responseText;
	}

	AjaxRequestPage('GET',url,params,callbackResponse);
}

function ChangeCountItemMyCart(itemid, newvalue, redirecto)
{
	var url="processcart.php";
	var params="to="+redirecto+"&item="+itemid+"&count="+newvalue+"&act=modify";

	function callbackResponse(xmlHttp)
	{
		var el = document.getElementById('MasterCartForm');
		el.innerHTML=xmlHttp.responseText;
	}

	AjaxRequestPage('GET',url,params,callbackResponse);
}


function DeleteItemMyCart(itemid, redirecto)
{
	var url="processcart.php";
	var params="to="+redirecto+"&item="+itemid+"&act=remove";

	function callbackResponse(xmlHttp)
	{
		var el = document.getElementById('MasterCartForm');
		el.innerHTML=xmlHttp.responseText;
	}

	AjaxRequestPage('GET',url,params,callbackResponse);
}



function EmptyMyCart(redirecto)
{
	var url="processcart.php";
	var params="to="+redirecto+"&act=empty";

	function callbackResponse(xmlHttp)
	{
		var el = document.getElementById('MasterCartForm');
		el.innerHTML=xmlHttp.responseText;
	}

	AjaxRequestPage('GET',url,params,callbackResponse);
}

function ChangeCart(item_id)
{
	var url="changecart.php";
	var params="id="+item_id;

	function callbackResponse(xmlHttp)
	{
		var el = document.getElementById('item'+item_id);
		el.src=xmlHttp.responseText;
	}

	AjaxRequestPage('GET',url,params,callbackResponse);
}

function AjaxRequestPage(protocal,url,params,refunc)
{
	var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){alert ("Your browser does not support AJAX!"); return;} 
	xmlHttp.onreadystatechange=function() 
	{
		if (xmlHttp.readyState==4 && xmlHttp.status == 200){refunc(xmlHttp);}
	}
	if (protocal=='GET')
	{
		url=url+'?'+params;
		xmlHttp.open('GET',url,true);		
		xmlHttp.send(null);
	}
	else if (protocal=='POST')
	{
		//Send the proper header information along with the request
		xmlHttp.open('POST',url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
	}
	else
	{
		xmlHttp.open('GET',url,true);		
		xmlHttp.send(null);
	}
}

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;
}