var xmlHttp;
function recalcprod(prodcode, prodname, price, featured, featureddiscount, valueorpercent, installation, shipping, shippingperitem, maxshipping, qtymin, qtymax, qtyunit, optionch, mobileinstall, givediscount) {

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("We use AJAX coding to run our shopping cart.\nYour browser does not support AJAX.");
  return;
  } 
	
var haveinstallation, optsel;
haveinstallation= "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 = "";
	}

var qty = document.getElementById("theqty").value;
a=shutdown();

var url="includes/dispitem_bn.html";

url=url+"?prodcode="+prodcode+"&prodname="+prodname+"&price="+price+"&featured="+featured+"&featureddiscount="+featureddiscount+"&valueorpercent="+valueorpercent+"&installation="+installation+"&shipping="+shipping+"&shippingperitem="+shippingperitem+"&maxshipping="+maxshipping+"&qtymin="+qtymin+"&qtymax="+qtymax+"&qtyunit="+qtyunit+"&optionch="+optionch+"&optsel="+optsel+"&qty="+qty+"&haveinstallation="+haveinstallation+"&mobileinstall="+mobileinstall+"&givediscount="+givediscount;

url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=readyttoupd1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function shuttopnav () {
	if (document.getElementById("sqtyandbuybut")) {
		document.getElementById("sqtyandbuybut").disabled=true;
	}
	
	if (document.getElementById("featuresbut")) {
		document.getElementById("featuresbut").disabled=true;
	}
	
	if (document.getElementById("brochurebut")) {
		document.getElementById("brochurebut").disabled=true;
	}
	
	if (document.getElementById("technicalbut")) {
		document.getElementById("technicalbut").disabled=true;
	}
	
}

function starttopnav () {
	if (document.getElementById("sqtyandbuybut")) {
		document.getElementById("sqtyandbuybut").disabled=false;
	}
	
	if (document.getElementById("featuresbut")) {
		document.getElementById("featuresbut").disabled=false;
	}
	
	if (document.getElementById("brochurebut")) {
		document.getElementById("brochurebut").disabled=false;
	}
	
	if (document.getElementById("technicalbut")) {
		document.getElementById("technicalbut").disabled=false;
	}
	
}


function shutdown() {
	if (document.getElementById("wantinstallation")) {
	var wantinstallation = document.forms['buymeform'].wantinstallation;
		for (i = 0; i < wantinstallation.length; i++)
	wantinstallation[i].disabled=true;
	}

	if (document.getElementById("opt1")) {
	}

if (document.getElementById("theqty")) {
		document.getElementById("theqty").disabled=true;
	}

if (document.getElementById("vcartbut")) {
		document.getElementById("vcartbut").disabled=true;
	}

if (document.getElementById("checkoutbut")) {
		document.getElementById("checkoutbut").disabled=true;
	}

if (document.getElementById("addtcartbut")) {
		document.getElementById("addtcartbut").disabled=true;
	}

if (document.getElementById("removefcartbut")) {
		document.getElementById("removefcartbut").disabled=true;
	}

if (document.getElementById("checkoutbut")) {
		document.getElementById("checkoutbut").disabled=true;
	}

if (document.getElementById("shoppingtbut")) {
		document.getElementById("shoppingtbut").disabled=true;
	}

if (document.getElementById("vcartbut")) {
		document.getElementById("vcartbut").disabled=true;
	}

}

function chkinstallquote() {
		if (document.getElementById("wantinstallation")) {
	var wantinstallation = document.forms['buymeform'].wantinstallation;
		for (i = 0; i < wantinstallation.length; i++) {
			wantinstallation[i].checked=false;
		}
		if (wantinstallation.length == 4) {
			wantinstallation[2].checked=true;
		}
		if (wantinstallation.length == 3) {
			wantinstallation[1].checked=true;
		}
	}

}

function startup() {
	if (document.getElementById("wantinstallation")) {
	var wantinstallation = document.forms['buymeform'].wantinstallation;
		for (i = 0; i < wantinstallation.length; i++)
	wantinstallation[i].disabled=true;
	}

	if (document.getElementById("opt1")) {
		for (i = 0; i < opt1.length; i++)
	opt1[i].disabled=false;
	}


if (document.getElementById("theqty")) {
		document.getElementById("theqty").disabled=false;
	}
	
if (document.getElementById("vcartbut")) {
		document.getElementById("vcartbut").disabled=false;
	}

if (document.getElementById("checkoutbut")) {
		document.getElementById("checkoutbut").disabled=false;
	}

if (document.getElementById("addtcartbut")) {
		document.getElementById("addtcartbut").disabled=false;
	}

if (document.getElementById("removefcartbut")) {
		document.getElementById("removefcartbut").disabled=false;
	}

if (document.getElementById("checkoutbut")) {
		document.getElementById("checkoutbut").disabled=false;
	}

if (document.getElementById("shoppingtbut")) {
		document.getElementById("shoppingtbut").disabled=false;
	}

if (document.getElementById("vcartbut")) {
		document.getElementById("vcartbut").disabled=false;
	}

}



function readyttoupd1() 
{ 
if (xmlHttp.readyState==4)
{ 
	document.getElementById("buynow").innerHTML=xmlHttp.responseText;

}
}

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;
}
