var reqtop10;

function loadXMLDocTop10(urltop10, divtop10) {	
    reqtop10 = null;
	document.getElementById(divtop10).innerHTML = '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><center><font size="1" color="#FF0000">Carregando...</font><br><img src="http://www.choveu.net/js/loading.gif" border="0"></center></td></tr></table>';
	function processReqChangeConsultaTop10()	{
		//***********************************
		// Caso a pagina tenha sido toda carregada
		//************************************
		if (reqtop10.readyState == 4) {
			// o server retornou ok
			if (reqtop10.status == 200) {
				// inseri no elemento indicado
				// e retorna o texto de html
				document.getElementById(divtop10).innerHTML = reqtop10.responseText;
			} else {
				alert("Problemas na página de dados:\n" + reqtop10.statusText);
			}
		}
	}
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        reqtop10 = new XMLHttpRequest();
        reqtop10.onreadystatechange = processReqChangeConsultaTop10;
        urltop10 = antiCacheRandConsultaTop10(urltop10)
        reqtop10.open("GET", urltop10, true);
        reqtop10.setRequestHeader("Cache-Control", "no-cache");
        reqtop10.setRequestHeader("Pragma", "no-cache");
        reqtop10.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        reqtop10 = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqtop10) {
            reqtop10.onreadystatechange = processReqChangeConsultaTop10;
              urltop10 = antiCacheRandConsultaTop10(urltop10)
              reqtop10.open("GET", urltop10, true);
              reqtop10.setRequestHeader("Cache-Control", "no-cache");
              reqtop10.setRequestHeader("Pragma", "no-cache");
              reqtop10.send();
        }
    }
    
    
   function antiCacheRandConsultaTop10(aurlTop10){
        var dt1 = new Date();
        if(aurlTop10.indexOf("?")>=0){// já tem parametros
            return aurlTop10 + "&" + encodeURI(Math.random() + "_" + dt1.getTime());
        }else{ return aurl1 + "?" + encodeURI(Math.random() + "_" + dt1.getTime());}
    }
    
}


//*****************
//Chamadas do site
//*****************

function ajaxtop10(texto,element) {
    var page = 'http://www.choveu.net/top10/ajaxtop10.aspx?tipo='+texto;
    loadXMLDocTop10(page,element);
}
