/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*		Heat Loss Calculator - February 20, 2007					 *
*		JavaScript programming by Philip Renich - www.elfboy.com	 *
*		For International Greenhouse Company - www.igcusa.com		 *
*	-------------------------------------------------------------	 *
*		This program calculates the heat loss in BTUHs in a 		 *
*		greenhouse based upon user chosen cloth type, dimensions,	 *
*		and other options. The result is displayed via DOM			 *
*		manipulation.												 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


var xmlHttp

function calcbtu(x)
{ 
	xmlHttp=GetXmlHttpObject()
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request")
		return
	}



	// Change this URL, possibly add as a var for function so you can do multiple
	var url="heatCalc.php"
	// Probably need this
	url=url+"?tempIn="+x.tempIn.value+"&tempOut="+x.tempOut.value+"&numHouses="+x.numHouses.value+"&width="+x.width.value+"&length="+x.length.value+"&height="+x.height.value+"&heatRetention="+x.heatRetention.checked+"&style="+x.style.checked+"&roofType="+x.roofType.value+"&sideType="+x.sideType.value+"&oppSideType="+x.oppSideType.value+"&endType="+x.endType.value+"&oppEndType="+x.oppEndType.value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		// Change stuff here (mostly)
		// At least return a message, even if you don't need to.
		if(xmlHttp.responseText != '0')
		{
			document.getElementById("result").innerHTML="Total heat loss in BTUH: "+xmlHttp.responseText
			document.getElementById("result").style.cssText = "display: block;"
		}
	}
}

function GetXmlHttpObject()
{
	try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(e) {}
	}

	if (xmlHttp==null)
	{
		xmlHttp=new XMLHttpRequest()
	}

	return xmlHttp
}