
var req;
var pos;
function loadXMLDoc(url){
	req = null;
	if (window.XMLHttpRequest) {
 		req = new XMLHttpRequest();
 		req.onreadystatechange = processReqChange;
 		req.open("GET", url, true); 
 		req.send(null);
	} else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		} catch(e) {
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
			} catch(e) {
				try {
					req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(e) {
					try {
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch(e) {
						req = false;
					}
				}
			}
		}
		if (req) {
 			req.onreadystatechange = processReqChange;
 			req.open("GET", url, true);
 			req.send();
		}
	}
}


function processReqChange(){
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById(pos).innerHTML = req.responseText;
			document.all.carregando.style.visibility = 'hidden';
			parent.document.body.style.cursor='default';
		} else {
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}


function atualiza(valor){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "atualiza";
	loadXMLDoc("inc/busca/modelos.php?marca="+valor);
}

function principal(page){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "principal";
	loadXMLDoc(page);
}

function lista(page){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "lista";
	loadXMLDoc(page);
}

function equipe(foto){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "foto_normal";
	loadXMLDoc("equipe/foto_normal.php?id="+foto);
}

function div_carro(id){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "div_carro"+id;
	loadXMLDoc("veiculos/exibir_car.php?id="+id);
}

function fecha_div_carro(id){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "div_carro"+id;
	loadXMLDoc("inc/empty.php");
}

function foto_carro(id,pic){
	document.all.carregando.style.visibility = 'visible';
	parent.document.body.style.cursor='wait';
	pos = "foto_carro"+id;
	loadXMLDoc("veiculos/foto_carro.php?id="+id+"&pic="+pic);
}