// JavaScript Document
//  -----------------------------  FUNÇÕES DO AJAX -----------------------------------

	//Fila de conexões
	fila=[]
	ifila=0

function ajaxPOSTRun(url,parameters){
	
	xmlhttp.onreadystatechange = alertContents;
	xmlhttp.open('POST', url, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", parameters.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(parameters);	
	
}


function ajaxHTML(id,url,carr){
		//Carregando...
		if (typeof carr == "undefined")
		document.getElementById(id).innerHTML="<div align='center'><img src='../arearestrita/imgs/ajax-loader.gif' /></div>";

		//Adiciona à fila
		fila[fila.length]=[id,url]
		//Se não há conexões pendentes, executa
		if((ifila+1)==fila.length)ajaxRun()
	}
	
function ajaxHTML2(id,url,carr){
	//Carregando...
	if (typeof carr == "undefined")

 	//Adiciona à fila
	fila[fila.length]=[id,url]
	//Se não há conexões pendentes, executa
	if((ifila+1)==fila.length)ajaxRun()
}
	
	//Executa a próxima conexão da fila
	function ajaxRun(){
		//Abre a conexão
		xmlhttp.open("GET",fila[ifila][1],true);
		//Função para tratamento do retorno
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4){
				//Mostra o HTML recebido
				retorno=unescape(xmlhttp.responseText.replace(/\+/g," "))
				//retorno=xmlhttp.responseText
				document.getElementById(fila[ifila][0]).innerHTML=retorno
				//Roda o próximo
				ifila++
				if(ifila<fila.length) setTimeout("ajaxRun()",20)
				if(document.getElementById('calendario')){
					var myTips = new Tips($$('#calendario .agenda_data_marcada'),{maxTitleChars:200,onShow:function(x){x.setOpacity(0.9)}});
					$$(".tool-tip").each(function(x){
						x.setStyle("visibility","hidden");									  
					});
				}
			}
		}
		//Executa
		xmlhttp.send(null)
	}
	
	//Tenta criar o objeto xmlHTTP
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
