var XmlHttp;

function GetXmlHttpObject()
{
   var XmlHttp = null;
   try {
      XmlHttp = new XMLHttpRequest();
   } catch (e) {
      try {
         XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
   }
   return XmlHttp;
}

function StateChanged()
{
   if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") {
      document.formcalc.total.value = XmlHttp.responseText;
   }
}

function ShowSum(url, params)
{
   XmlHttp = GetXmlHttpObject();
   if (XmlHttp == null)
      return;

   XmlHttp.onreadystatechange = StateChanged; 
   XmlHttp.open('POST', url, true);
   XmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   XmlHttp.setRequestHeader("Content-length", params.length);
   XmlHttp.setRequestHeader("Connection", "close");
   XmlHttp.send(params);
}

function GetInfo()
{
   var str = "fSize1=" + escape(encodeURI(document.getElementById("fSize1").value)) + 
             "&fSize2=" + escape(encodeURI(document.getElementById("fSize2").value)) + 
             "&pitch=" + escape(encodeURI(document.getElementById("pitch").value)) +
			 "&existing=" + escape(encodeURI(document.getElementById("existing").value)) + 
             "&difficulty=" + escape(encodeURI(document.getElementById("difficulty").value)) +
			 "&material=" + escape(encodeURI(document.getElementById("material").value));

   ShowSum('http://www.newenglandmetalroof.com/script/getcalc.php', str);
}
