var conexoes = new Array();
function openAjax() {
	try	{
		xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e) {
		try 		{
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}catch (Ex) {
			xmlhttp= false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
	   xmlhttp= new XMLHttpRequest();
	}
	return xmlhttp;
}

function ReqHeader(method, index){
	conexoes[index].open(method, URL, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
    xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 
    xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); 
    xmlhttp.setRequestHeader("Pragma", "no-cache"); 
}

function Response(dv,index){
   conexoes[index].onreadystatechange=function() {
      if(conexoes[index].readyState==4) {
	     if(conexoes[index].status==200) {
		    resp=conexoes[index].responseText;
		    switch(dv) {
		    	case 'alert':
		    		alert(resp);
		    		break;
		    	default:
		    		 get(dv).innerHTML=resp;
		    }
	     }
      }
   }
}

function buscarConteudo(dv,dst,param1,param2) {	
	idx = conexoes.push(openAjax());
	idx-=1;
	URL='conteudo.php';
	ReqHeader('post', idx); 
	if(dv!='alert' && typeof(dv)!='null' && typeof(dv)!='undefined')
		get(dv).innerHTML='<b>Aguarde, carregando...<img src="imagens/carregando.gif" border="0"></b>'; 
	conexoes[idx].send("acao=" + escape(dst)+"&param1="+escape(param1)+"&param2="+escape(param2));
	Response(dv,idx);
}

function buscarURL(dv,dst,param) {
	idx = conexoes.push(openAjax());
	idx-=1;
	URL=dst;
	if(dst=='')
		URL='conteudo.php';
	ReqHeader('post', idx); 
	if(dv!='alert' && typeof(dv)!='null' && typeof(dv)!='undefined')
		get(dv).innerHTML='<b>Aguarde, carregando...<img src="imagens/carregando.gif" border="0"></b>'; 
	conexoes[idx].send(param);
	Response(dv,idx);
}