var xmlHttp

function addProduct(id)
{ 
qty = document.getElementById("qty"+id).value;
w = document.getElementById("weight"+id).value;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="ajax-add-to-basket.asp";
url=url+"?id="+id+"&qty="+qty+"&w="+w;
//url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=function()
{
    if(xmlHttp.readyState==4)
      {
	  
	  var xmlDoc=xmlHttp.responseXML.documentElement;
	  
		document.getElementById("itemCount").innerHTML=xmlDoc.getElementsByTagName("itemCount")[0].childNodes[0].nodeValue;
		document.getElementById("basketTotal").innerHTML=xmlDoc.getElementsByTagName("basketTotal")[0].childNodes[0].nodeValue;
		document.getElementById("add"+id).src=xmlDoc.getElementsByTagName("imageSrc")[0].childNodes[0].nodeValue;

     
	  //if(xmlHttp.responseText=="working"){
	  //document.getElementById("add"+id).src="_assets/added.gif";
	  //}else{
	  //document.getElementById("add"+id).src="_assets/add.gif";
	  //}
      }
}

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

//function stateChanged() 
//{ 
//if (xmlHttp.readyState==4)
//{ 
//document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
//document.getElementById("add"+id).src="_assets/added.gif";
//}
//}

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;
}