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_new.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 );
		if(document.getElementById('items_'+item_id).value=='6')
		{
			if(document.getElementById("size").value!='')
			{
				params = params + "&size="+encodeURI( document.getElementById("size").value );
			}
			else
			{
				alert("Please select size of T-Shirt");
				document.getElementById("size").focus();
				return false;
			}
		}

// 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_new.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);

}

function Subscribe()
{
  xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 		return
 	} 
  //  Set our destination PHP page "ajaxpost.php"…
  xmlHttp.open("POST", "http://baxterbear.createsend.com/t/r/s/dutjih/", Math.random());
  xmlHttp.onreadystatechange = Subscribe_feedback;
  
  // Make our POST parameters string…
  var params = "?cm-dutjih-dutjih="+encodeURI( document.getElementById('cm-dutjih-dutjih').value) +
  	           "&cm-name="+encodeURI( document.getElementById("cm-name").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 Subscribe_feedback() 
{ 
 	
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	var str = xmlHttp.responseText;
	document.getElementById("shopping_cart").innerHTML=xmlHttp.responseText;
	return false;
 } 
}
