// JavaScript Document
function loading(obj){
	if(obj=='web'){
		return true;
	}
	if(obj.substring(0,2)!="H_"){
		var loadCod = "<table width='100%' height='100%' border='0'><tr><td align='center' valign='middle'><img src='/imagens/bullets/loading.gif' onclick=\"ifila--;\"><br />Carregando...<br /></td></tr></table>";
	}else{
		var loadCod = "aguarde...";
	}
	var txtObj = new getObj(obj);
		txtObj.innerHTML = loadCod;	
}

/* Ajax */
fila	= [];
ifila	= 0;
function ajaxHTML(id,url,funcao){
	fila[fila.length]=[id,'includes/'+url,funcao]
    if((ifila+1)==fila.length)ajaxRun()
}
function ajaxObj(){
	var tXHR=0;	
	if (window.XMLHttpRequest){
		tXHR	= new XMLHttpRequest();
	}else{
		try{
			tXHR	= new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				tXHR	= new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				tXHR	= false;
			}
		}
	}
	if (navigator.appVersion.indexOf("MSIE 5.01") != -1){
		tXHR	= false;
	}
return tXHR;
}
function ajaxRun(){
	if((fila[ifila][2]!='contador') && (fila[ifila][2]!='updateItem')){
		loading(fila[ifila][0])
	}
	var str	= "/includes/executa.php";
	tXHR.open("POST",str,true);
	tXHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //AQUI
	tXHR.setRequestHeader("Content-length", fila[ifila][1].length); //AQUI
	tXHR.setRequestHeader("Connection", "close"); //AQUI
	
    tXHR.onreadystatechange=function() {
        if(tXHR.readyState==4){
			retorno = tXHR.responseText;
				if(fila[ifila][2]=='exibe'){
					exibe(fila[ifila][0]);
				}
				if(fila[ifila][2]=='vLogin'){
					var vLogin = retorno.split(':')
					vMsg(vLogin[0],'H_LOGIN',vLogin[1])
				}				
			ifila++
			if(ifila<fila.length)setTimeout("ajaxRun()",500);
        }
    }
    //tXHR.send(null)
	tXHR.send('SCRIPT='+fila[ifila][1]); //AQUI
}
tXHR =	new ajaxObj();

//Complemento AJAX
function exibe(ly) { 
	if (tXHR.readyState == 4) { 
		var status	= tXHR.status
		var valor	= tXHR.responseText
		if(status==200){
			var retorno	= valor;
		}else{
			var retorno	= status +" - "+ valor
			ifila--;
			alert('Ocorreu um erro status!=200 ')
		}
		if((retorno!='') && (ly!='web')){
			var txtObj = new getObj(ly);
				txtObj.innerHTML	= ""+retorno+"";
		}else{
			return retorno;
		}
	}
}
function script(local,script){
	ajaxHTML(local,'includes/'+script,'exibe');
}








