var req;

var urlsite = (location.host=='localhost') ? 'http://localhost/caffeditalia/' : 'http://'+location.host+'/';

function loadXMLDoc(url, func){
 	req = null;
	url = urlsite+url;
	
	if (window.XMLHttpRequest) {
 		req = new XMLHttpRequest();
 		req.onreadystatechange = func;
 		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 = func;
 			req.open("GET", url, true);
 			req.send();
		}
	}
}


function processReqChange(){

	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById("divMarcas").innerHTML = req.responseText;
			var t = setTimeout("atualizaMarcas()",5000);
		} else {
			//alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}

function processCBMarcas(){

	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById("divCBMarcas").innerHTML = req.responseText;
		} else {
			alert("Houve um problema ao obter os dados:\n" + req.statusText);
		}
	}
}

function atualizaMarcas(){
	loadXMLDoc("randimgs.php?ver=1&u="+Date.parse(new Date()), processReqChange);
}

function atualizaDivMarcas(id){	
	loadXMLDoc("getMarcas.php?id="+id+"&u="+Date.parse(new Date()), processCBMarcas);
}


/*var altura = document.getElementById("menucentro").style.height;
		var altura2 = parseInt(document.getElementById("menulogin").style.height);
		
		alert(altura);	
		if(altura < altura2)
		{
		
		}*/
