// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject(); 

// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject() 
{  
    var xmlHttp;
    if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

// make asynchronous HTTP request using the XMLHttpRequest object 
function process()
{
	
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    // retrieve the name typed by the user on the form
    Height=encodeURIComponent(document.getElementById("SHeight").value);
	Width=encodeURIComponent(document.getElementById("SWidth").value);
	SStyleID=encodeURIComponent(document.getElementById("SStyleID").value);

	
	document.getElementById("DivPanel").innerHTML ="<img src='../Graphics/loading.gif'>";
	url="panel.php?Height="+Height+"&Width="+Width+"&StyleID="+SStyleID;
	xmlHttp.open("GET",url, true);  
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
  }
  else
    setTimeout('process()', 1000);
}
function process2(attrstylevalue)
{
	
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    // retrieve the name typed by the user on the form
    Height=encodeURIComponent(document.getElementById("SHeight").value);
	Width=encodeURIComponent(document.getElementById("SWidth").value);
	SStyleID=encodeURIComponent(document.getElementById("SStyleID").value);
	Panel=encodeURIComponent(document.getElementById("Panel").value);
	AttrStyleValue=attrstylevalue;
	
	document.getElementById("DivPrice").innerHTML ="<img src='../Graphics/loading.gif'>";
	url="panel.php?Panel="+Panel+"&Height="+Height+"&Width="+Width+"&StyleID="+SStyleID+"&AttrStyleValue="+AttrStyleValue;
	xmlHttp.open("GET",url, true);  
    xmlHttp.onreadystatechange = handleServerResponse2;
    xmlHttp.send(null);
  }
  else
    setTimeout('process2()', 1000);
}
function handleServerResponse2() 
{
	
  if (xmlHttp.readyState == 4) 
  {
  	
    if (xmlHttp.status == 200) 
    {
	 	  document.getElementById("DivPrice").innerHTML = xmlHttp.responseText;
     } 
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}
// executed automatically when a message is received from the server
function handleServerResponse() 
{
	
  if (xmlHttp.readyState == 4) 
  {
  	
    if (xmlHttp.status == 200) 
    {
	 	  document.getElementById("DivPanel").innerHTML = xmlHttp.responseText;
     } 
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}