
var xmlHttp;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	else if (window.XMLHttpRequest) {
	xmlHttp = new XMLHttpRequest();
	}
}
    
function refreshproductList() {
	var prodType = document.getElementById("prodType").value;
    var url = "model.asp?brand=" + prodType;
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function refreshmodelList() {
	var prod = document.getElementById("prod").value;
	var url_model = "model.asp?model=" + prod;
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleState;
    xmlHttp.open("GET", url_model, true);
    xmlHttp.send(null);
}
    
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
       // if(xmlHttp.status == 200) {
				updateproductList();  
	  //  }
	}
}

function handleState() {
    if(xmlHttp.readyState == 4) {
	updatemodelList();  
    }
}

function updateproductList() {
 //   var productName = document.getElementById("prod");
 //   var results = xmlHttp.responseText;
//    var option = null;
//    p=results.split(",");
//    for (var i = 0; i < p.length; i++){
 //          option = document.createElement("option");
 //          option.appendChild(document.createTextNode(p[i]));
//           productName.appendChild(option);
   // }
	document.getElementById("model").innerHTML = xmlHttp.responseText;	
}

function updatemodelList() {
  //  var prods = document.getElementById("prods");
 //   var results = xmlHttp.responseText;
//    var option = null;
 //   p=results.split(",");
 //   for (var i = 0; i < p.length; i++){
 //          option = document.createElement("option");
//           option.appendChild(document.createTextNode(p[i]));
    //       prods.appendChild(option);
 //   }
document.getElementById("models").innerHTML = xmlHttp.responseText;	
}

