var xmlHttp;

function getCarData(model,type){
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){
		alert("AJAX!");
		return;
	}
	var url="database/getCarData.php";
	var url=url+"?model="+encodeURIComponent(model)+"&type="+encodeURIComponent(type)+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChanged(){
	if(xmlHttp.readyState==4){
	    $("pro_content").innerHTML=xmlHttp.responseText;
	}
}

function getEquipmentData(id){
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){
	    alert("AJAX!");
		return;
	}
	var url="database/getEquipmentData.php";
	var url=url+"?id="+id+"&sid="+Math.random();
	xmlHttp.onreadystatechange=equipmentChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function equipmentChanged(){
	if(xmlHttp.readyState==4){
		$("pro_content").innerHTML=xmlHttp.responseText;
	}
}

function getItemData(){
	id = document.getElementById("item").value;
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null){
	    alert("AJAX!");
		return;
	}
	var url="database/getItemData.php";
	var url=url+"?id="+id+"&sid="+Math.random();
	xmlHttp.onreadystatechange=itemChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function itemChanged(){
	if(xmlHttp.readyState==4){
		$("pro_content").innerHTML=xmlHttp.responseText;
	}
}

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;
}
