// JavaScript Document
function Muda(){
	xmlHttp = GetXmlHttpObject();
	
	url = "contagem.asp";
	url = url + "?sid="+ Math.random();
	
	xmlHttp.onreadystatechange = MudaValor;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	if (xmlHttp.readyState == 1) {
		document.getElementById('comparar').innerHTML = "Aguarde..";
   	}
	
	function MudaValor() { 
		if (xmlHttp.readyState == 4){ 
			document.getElementById('comparar').innerHTML=xmlHttp.responseText;
		}
	}
}

function GetXmlHttpObject(){
	
	if (window.XMLHttpRequest) {   
		a = new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)  
	else {  
		try { a = new ActiveXObject("Msxml2.XMLHTTP");  /*activeX (IE5.5+/MSXML2+)*/ }	 
		catch(e) {  
			try { a = new ActiveXObject("Microsoft.XMLHTTP"); /*activeX (IE5+/MSXML1)*/ }	 
			catch(e) { /* O navegador não tem suporte */ a = false; }  
		}  
	}   
	return a;  
}


function Session(id_imoveis,excluir,img){
	
	xmlHttp = GetXmlHttpObject();
	url = "session.asp";
	
	var id_imoveis = id_imoveis;
	var excluir = excluir;
	var img = img;
	
	url = url + "?sid=" + Math.random();
	url = url + "&id_imoveis="+ id_imoveis;
	url = url + "&excluir="+ excluir;
	
	xmlHttp.onreadystatechange=CriaSession;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	if (xmlHttp.readyState == 1) {
		 if(img=='img_1'){ 
			  document.getElementById(id_imoveis+'_imovel').style.display='none';
			  document.getElementById(id_imoveis+'_imovel_b').style.display='block';
			  document.getElementById('comparar').style.display='block';
		 }
		 
		 
		 if(excluir==1){
			 
			 
			 if(img=='img_2'){ 
			  document.getElementById(id_imoveis+'_imovel_b').style.display='none';
			  document.getElementById(id_imoveis+'_imovel').style.display='block';
		 }
			
			if(img=='img_3'){
				document.getElementById(id_imoveis+'_imovel').style.display='block';
				document.getElementById(id_imoveis+'_imovel_b').style.display='none';
			}
			
		 }
	 }

	function CriaSession(){ 

		if (xmlHttp.readyState == 4){ 
			//document.getElementById(id_imoveis+"_imovel").innerHTML=xmlHttp.responseText;
			setTimeout("Muda()",1);
		}
	}
	
}
function GetXmlHttpObject()
	{
	 if (window.XMLHttpRequest) {   
			   a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)  
		   else {  
			 try {   
				a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)  
			 }	 
			 catch(e) {  
			   try {   
				  a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)  
			   }	 
			   catch(e) { /* O navegador não tem suporte */   
				  a=false;   
			   }  
			 }  
		   }   
		   return a;  
	}
