var xmlHttp
function addtocart(prodref, prodname)
{
if (prodref.length==0)
  { 
	alert("No product code");
	return;
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

a=shutdown();
a=shuttopnav();
	
var haveinstallation, extras, optsel;
haveinstallation = "no";
extras = "no";
optsel = "";

	
	if (document.getElementById("waitarea2")) {
	document.getElementById("waitarea2").innerHTML="<img src='images/pleasewait.gif'>";
	}

	if (document.getElementById("wantinstallation")) {
	var wantinstallation = document.forms['buymeform'].wantinstallation;
	if (wantinstallation[0]) {
			for (i = 0; i < wantinstallation.length; i++)
				if (wantinstallation[i].checked) {
					haveinstallation=wantinstallation[i].value;
				}
		}
		else {
			if (wantinstallation.checked) { 
			haveinstallation=wantinstallation.value;
			}
		}
	}
	else {
		haveinstallation = "no";
	}

	if (document.getElementById("opt1")) {
	var opt1 = document.forms['buymeform'].opt1;
		if (opt1[0]) {
			for (i = 0; i < opt1.length; i++)
				if (opt1[i].checked) {
					optsel=opt1[i].value;
				}
		}
		else {
			if (opt1.checked) { 
			optsel=opt1.value;
			}
		}
	}
	else {
		optsel = "";
	}

qty = document.getElementById("theqty").value;
qty = qty

//-------------------------
var url="addtocart.html";
url=url+"?prodid="+prodref+"&qty="+qty+"&haveinstall="+haveinstallation+"&options="+optsel+"&prodname="+prodname;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=oktoaddtocart;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function oktoaddtocart() 
{ 
if (xmlHttp.readyState==4)
{ 
	document.getElementById('addtcartbut').disabled=true
	document.getElementById("buynow").innerHTML=xmlHttp.responseText;
	a=starttopnav();
}
}

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;
}
