
function w_im(end) {
	if(typeof(end)!="string")end=end.href;
	if(end.indexOf(".asp")==-1)end="imovel.asp?im="+end;
	end=rpl(end,'imovel.asp?','imovel_pop.asp?')
//	wb(end,638,500,",menubar=no,scrollbars=yes,resizable=no,status=yes,location=no,tollbar=no","_blank",+30,0,null,1);
	
//	if(win1!=0)win1.focus();
	
	var win1=window.open(end,'im',
				'width=638,height=500,top='+
				((screen.height/2)-(550/2)-20)+',left='+
				((screen.width/2)-(638/2)-15)+
				',menubar=no,scrollbars=yes,resizable=no,status=yes,location=no,tollbar=no');

	win1.focus();
	return false;
}
function wchat(topic,nome,corretor,cliente,tempo) {
//group,nome corretor,id corrtor,nome cliente,tempo cliente

	if(topic==null){
		wb(endsite+'/chat/index.asp',440,346,
			',menubar=no,scrollbars=no,resizable=yes,status=no,location=no,tollbar=no','_blank',null,0)
	}else if(topic && nome && corretor && cliente==null && tempo==null)if(topic!=''){
		wb(endsite+'/chat/chatroom.asp?ajax=1&Topic='+topic+'&Name='+nome+
			'&corretor='+corretor+'&cliente='+cliente+'&tempo='+tempo,440,396,
			',menubar=no,scrollbars=no,resizable=yes,status=no,location=no,tollbar=no','_blank',null,0)
	}else if(topic && nome && corretor && cliente && tempo)if(topic!=''){
		wb(endsite+'/chat/atender.asp?ajax=1&Topic='+topic+'&Name='+nome+
			'&corretor='+corretor+'&cliente='+cliente+'&tempo='+tempo,440,396,
			',menubar=no,scrollbars=no,resizable=yes,status=no,location=no,tollbar=no','_blank',null,0)
	}
	return false;
}
function saber_cep() {
	wb('cep.htm',400,250)
	addEvent(w2,"unload",function(){setTimeout("$o('cep').select();",50)})
	return false;
}
function saber_cep2() {
	wb('cep.asp',400,250)
	addEvent(w2,"unload",function(){setTimeout("$o('cep').select();",50)})
	return false;
}

function f_xcid(){

	arqr(arbai,'ibai',1,3,'a[ i][2]==\''+($v('icid'))+'\'',$v('ibai'));
	alt('ibai','(Escolha o bairro)','0');
	add('ibai','(Qualquer bairro)','0',1);
}
function env_busca() {
	if($v("igrupo")=='0'){alert('Selecione o tipo de imóvel e tente novamente.');return false;}
	if($v("icid")=='0'){alert('Selecione a cidade e tente novamente.');return false;}
	if(ehnum(rpl($v("de")),".") && ehnum(rpl($v("ate")),".") ){
		mil_b('de','Mínimo');
		mil_b('ate','Máximo');
		if(rpl($v("de"),".")>rpl($v("ate"),".")){alert('O valor mínimo deve ser menor do que o valor máximo.');return false;}
		if(rpl($v("ate"),".")-rpl($v("de"),".")<3000){alert('A faixa de preço está muito estreita (de '+$v("de")+' até '+$v("ate")+') o que dificulta a pesquisa. Coloque pelo menos 3.000 de diferença entre o valor mínimo e máximo.');return false;}
	}

	if(!ehnum(rpl($v("de")),"."))$c("de","")
	if(!ehnum(rpl($v("ate")),"."))$c("ate","")
	return true;
}
function env_busca() {
	if($v("cod")=='' && ehnum($v("cod")) ){alert('Digite o número de referência do imóvel.');return false;}
	return true;
}

function ve_sincro_arq() {
//	ajax(0,endsite+"/sincro_arq.asp","js=1",null,null,null);
}
function _ve_sincro_arq() {addEvent(window,"load",ve_sincro_arq)}
function abre_sincro_arq() {
	wb(endsite+"/sincro_arq.asp?exec=1",350,30)
}

function initChecklist() {
				var lists = document.getElementsByTagName("ul");
				for (i = 0; i < lists.length; i++) {
					var theList = lists[i];
					if (theList.className.indexOf("checklist") > -1) {
						var labels = theList.getElementsByTagName("label");
						for (var j = 0; j < labels.length; j++) {
							var theLabel = labels[j];
							if(document.all && document.getElementById){
								theLabel.onmouseover = function() { this.className += " hover"; };
								theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
//								theLabel.onmousedown = function() { alert('');};
							}
							
						}
					}
				}
}
//onready(initChecklist);

function mil_b(o,a) {
	o=$o(o)
	if(o.value==''){
		o.value='Digite o Valor '+a;
		o.style.color='gray';
	}else if(fnum(rpl(o.value,'.'))<=999){
		$c(o,(rpl(preal(fnum(rpl($v(o),'.'))*1000),',00')));
	}
}

function schat() {
	if($o('schat'))if($o('schat').innerHTML=='Online'){
		$o('schat').style.color=($o('schat').style.color=='black'?'#00BF0A':'black')
//		$o('schat').style.display=($o('schat').style.display=='none'?'':'none')
		setTimeout("schat()",500)
	}
}
onready(schat);

function e_db() {
	rec("","&e_db=1","e_db_p()");
}
function e_del_aqui() {
	if(!confirm("tem certeza de que deseja deletar todo o historico de alterações neste servidor?"))return false;
	rec("","&e_del_aqui=1","");
}
function e_del_la() {
	if(!confirm("tem certeza de que deseja deletar todo o historico de alterações na internet?"))return false;
	rec("","&e_del_la=1","");
}
function e_db_p() {
	var id=prompt("ultimo id inserido: "+at_id,"25")
	if(id==null)return false;
	
	var im=prompt("ultimo im inserido: "+at_im,"4")
	if(im==null)return false;

	rec("","&e_db=1&e_im="+im+"&e_id="+id)
		
}
