// JavaScript Document
function resizeMe(obj){
	docHeight = stats.document.body.scrollHeight
	obj.style.height = docHeight + 0 + 'px'
}
function voltar(){
	history.go(-1);	
}
function abre_site(width, height, nome,barra) {
	var top; var left; 
	if (barra == "") {
		barra = 0;
	}
	top = ( (screen.height/2) - (height/2) )
	left = ( (screen.width/2) - (width/2) )
	window.open(nome, "","toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=1,width="+width+",height="+height+",left="+left+",top="+top);
}
function busca_rapida(){
	var codigo = document.form_busca.codigo.value;
	if(codigo == ""){
		alert("Favor informar o codigo!");
		document.form_busca.codigo.focus();
	} else {
		ver_imovel(codigo);
	}
}
function SomenteNumeros()
{
	if(event.keyCode < 48 || event.keyCode > 57)
	{
		event.keyCode = 0;
			return false;
	}
	else
	{
		return true;
	}
}
function addItem(obj,strText,strValue,blSel,intPos){ 
	 var newOpt,i,ArTemp,selIndex; 
	 selIndex = (blSel)?intPos:obj.selectedIndex; 
	 newOpt = new Option(strText,strValue); 
	 Len = obj.options.length+1 
	 if (intPos > Len) return 
	 obj.options.length = Len 
	 if (intPos != Len) { 
		  ArTemp = new Array(); 
		  for(i=intPos;i<obj.options.length-1;i++) 
			   ArTemp[i] = Array(obj.options[i].text,obj.options[i].value); 
		  for(i=intPos+1;i<Len;i++) 
			   obj.options[i] = new Option(ArTemp[i-1][0],ArTemp[i-1][1]); 
	 } 
	 obj.options[intPos] = newOpt; 
	 if (selIndex > intPos) 
		  obj.selectedIndex = selIndex+1; 
	 else if (selIndex == intPos)  
		  obj.selectedIndex = intPos; 
}
function _validaFormulario(frm){
		var campos = new Array();
		var mensagem = new Array();
		var temp1 = frm.campos_obrigatorios.value;
		var temp2 = frm.mensagem_preenchidos.value;
		campos = temp1.split(",");
		mensagem = temp2.split(",");
		for(i = 0; i < campos.length; i++){		
			if(campo = document.getElementById(campos[i])){
				if(campo.type == "text" || campo.type == "password"){
					if(campo.value == ""){
						alert(mensagem[i]);
						campo.focus();
						return false;
					}
				} else if(campo.type == "select-one"){
					if(campo.value == "0"){
						alert(mensagem[i]);
						campo.focus();
						return false;
					}
				} 
			}
		}
	}
function ver_imovel(codigo){
	abre_site(793,500,'detalhes-do-imovel?codigo='+codigo)	;
}