// JavaScript Document
function resizeMe(obj){
	docHeight = stats.document.body.scrollHeight
	obj.style.height = docHeight + 0 + 'px'
}
function resizeMe2(){
	docHeight = stats.document.body.scrollHeight;
	docWidth = stats.document.body.scrollWidth;
	stats.resizeTo(docWidth,docHeight)
}
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.form2.codigo.value;
	if(codigo == "" || codigo == "Busca pelo código"){
		alert("Favor informar o codigo!");
		document.form2.codigo.focus();
	} else {
		abre_site(750,500,'viaimoveis/Imovel/detalhes_site.php?codigo='+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 _detalhe(cod,imob){
    open_page( "detalhes.php?codigo=" + cod+"&imobiliaria="+imob,'',10,10,670,590 );
}
function buscarapida(){
	
	var cod = document.busca.codigo.value;
	if(cod != "" && cod != "Busca pelo código!"){
//		location = "busca_rapida.php?codigo=" + cod;	
		open_page( "busca_rapida.php?codigo=" + cod,'',10,10,670,590 );
	} else {
		document.busca.codigo.focus();
		alert("Favor informar o código");
	}
	
}
	function _validaPesquisa(frm){		
		if(frm.tipo.value == "0"){
			alert("Favor informar o Tipo do Imóvel!");
			return false;
		} else if(frm.cidade.value == "0"){
			alert("Favor informar a Cidade do Imóvel!");
			return false;
		}
	}
	function selecionar_linha_li( obj, nome ) {
	obj.className = nome;
}

function open_page( page, name_window, x, y, w, h ){
	if ( x == undefined || x == '' ) { x = 0; }
	if ( y == undefined || y == '' ) { y = 0; }
	if ( w == undefined ) { w = 400; }
	if ( h == undefined ) { h = 300; }
	if ( name_window == undefined ) { name_window = ''; }
	window.open( page, name_window, 'statusbar,scrollbars,toolbar,resizable,top=' + x + ',left=' + y + ',width=' + w + ',height=' + h  );
}

