var req1;

function loadXMLDocConsulta(url1, div1) {	
    req1 = null;
	document.getElementById(div1).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 processReqChangeConsulta()	{
		//***********************************
		// Caso a pagina tenha sido toda carregada
		//************************************
		if (req1.readyState == 4) {
			// o server retornou ok
			if (req1.status == 200) {
				// inseri no elemento indicado
				// e retorna o texto de html
				document.getElementById(div1).innerHTML = req1.responseText;
			} else {
				//alert("Problemas na página de dados:\n" + req1.statusText);
			}
		}
	}
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req1 = new XMLHttpRequest();
        req1.onreadystatechange = processReqChangeConsulta;
        url1 = antiCacheRandConsulta(url1)
        req1.open("GET", url1, true);
        req1.setRequestHeader("Cache-Control", "no-cache");
        req1.setRequestHeader("Pragma", "no-cache");
        req1.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        req1 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req1) {
            req1.onreadystatechange = processReqChangeConsulta;
              url1 = antiCacheRandConsulta(url1)
              req1.open("GET", url1, true);
              req1.setRequestHeader("Cache-Control", "no-cache");
              req1.setRequestHeader("Pragma", "no-cache");
              req1.send();
        }
    }
    
    
   function antiCacheRandConsulta(aurl1){
        var dt1 = new Date();
        if(aurl1.indexOf("?")>=0){// já tem parametros
            return aurl1 + "&" + encodeURI(Math.random() + "_" + dt1.getTime());
        }else{ return aurl1 + "?" + encodeURI(Math.random() + "_" + dt1.getTime());}
    }
    
}


//*****************
//Chamadas do site
//*****************


function visualizarCinema(element,keyidfilme) {
    var page = 'http://www.choveu.net/locadorafilme/visualizarcinema.aspx?key='+keyidfilme;
    loadXMLDocConsulta(page,element);
}

function visualizar(element,keyidfilme) {
    var page = 'http://www.choveu.net/locadorafilme/visualizar.aspx?key='+keyidfilme;
    loadXMLDocConsulta(page,element);
}

function buscachoveu(tipobusca,texto,element) {
    var page = 'http://www.choveu.net/locadorafilme/buscafilmes.aspx?tipobusca='+tipobusca+'&texto='+texto;
    loadXMLDocConsulta(page,element);
}
