var xmlHttp;

var posx = 0;
var posy = 0;
var msg = "";
    
function addCart(id)
{ 
  xmlHttp = GetXmlHttpObject();
  
  if(xmlHttp == null)
  {
    alert("Your browser does not support AJAX!");
    return;
  } 
  
  var url = "shopping_cart3.php";
  var params = "id=" + id + "&action=add_item&qty=1";
       
  xmlHttp.onreadystatechange = stateChanged;
  xmlHttp.open("POST",url,true);

  //Send the proper header information along with the request
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // text/html; charset:ISO-8859-1
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");
  
  xmlHttp.send(params);
} 

function stateChanged() 
{ 
 if(xmlHttp.readyState == 4)
 { 
   if(xmlHttp.responseText.length != 0)
     msg = document.getElementById("msg").innerHTML = xmlHttp.responseText;
   else
     msg = "Errore";
 }
}

function GetXmlHttpObject()
{
  var xml_Http = null;
  try
  {
   // Firefox, Opera 8.0+, Safari
   xml_Http = new XMLHttpRequest();
  }
  catch (e)
  {
   // Internet Explorer
   try
   {
     xml_Http = new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e)
   {
     xml_Http = new ActiveXObject("Microsoft.XMLHTTP");
   }
  }
  return xml_Http;
}

function showMsg(event)
{
  var e = null;
  
  if (!event) 
    e = window.event;
  else
    e = event;
 
  if (e.pageX || e.pageY) 	
  {
    posx = e.pageX;
	posy = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
     posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
  }
  
  posx = posx-250; // 550
  posy = posy+40;
  
  posx = posx+"px";
  posy = posy+"px"
  
  /*
  Shows cood position
  var coord  = "client height: " + document.body.clientHeight + " px\n";
      coord += "client width: "  + document.body.clientWidth  + " px\n";
      coord += "client left: "  + document.body.clientLeft  + " px\n";
      coord += "client top: "  + document.body.clientTop  + " px\n";
      coord += "client off height: " + document.body.offsetHeight + " px\n";
      coord += "client off width: "  + document.body.offsetWidth  + " px\n";
      coord += "client scroll left " + document.body.scrollLeft + " px\n";
      coord += "client scroll top: "  + document.body.scrollTop  + " px\n";
      coord += "event client X: " + e.clientX  + " px\n";
      coord += "event client Y: " + e.clientY  + " px\n";
      coord += "event screen X: " + e.screenX  + " px\n";
      coord += "event screen Y: " + e.screenY  + " px\n";
      coord += "event page X: " + e.pageX  + " px\n";
      coord += "event page Y: " + e.pageY  + " px\n";
     
  alert(coord);
  */
  
  /*
  posx = document.body.clientHeight/2;
  posy = document.body.clientWidth/2;
  
  posx = posx+"px";
  posy = posy+"px"
 */
  
 
  /* 
  document.getElementById("msg").style.left = posx;
  document.getElementById("msg").style.top  = posy;
 */
  
  document.getElementById("msg").style.display = "block";
  
  document.getElementById("msg").innerHTML = msg;
  
  hideMsg(3000);
}

function hide()
{
  document.getElementById("msg").style.display = "none";
}

function hideMsg(delay)
{
  // document.getElementById("msg").style.visibility = "hidden";
  var t = setTimeout("hide()",delay);
}