// JavaScript Document

limpaForm = function(i, o){
	var f = document.forms[i], a;
	for(var i in o)
		f[i].onfocus = new function(o){
			f[i].onblur = function(){
				this.value == '' && (this.value = o);
			}
			return function(){
				this.value == o && (this.value = "");
			}
		}(o[i]);
}

//mostra qq objeto html q esteja oculto na tela
function mostraObjeto(obj){
	if ( document.getElementById(obj).style.display == 'block'){
		document.getElementById(obj).style.display = 'none';
		document.getElementById(obj).style.visibility = 'hidden';
	}else{
		document.getElementById(obj).style.display = 'block';
		document.getElementById(obj).style.visibility = 'visible';
	}
}

//Funcao para ocultar a camada de alerta
function ocultaObjeto(obj){
	document.getElementById(obj).style.visibility='hidden';
	document.getElementById(obj).style.display='none';
}

//Marca todos os checkboxs de uma pagina
function MarcaTudo(){
	
	if (form.checkbox_marca_tudo.checked == true){
	
		for (i=0; i<form.length; i++){
			 if (form.elements[i].type == "checkbox"){
				  form.elements[i].checked = true;
		     }
		 }
	}
	else
	{
			for (i=0; i<form.length; i++){
				 if (form.elements[i].type == "checkbox")
					 form.elements[i].checked = false;
	        }
	}

}//fim da funcao*/

function PulaCampo(campo1,campo2,tamanho)
{
  if ( campo1.value.length==tamanho )
   campo2.focus();
}

//******************************************************************************************************

function FormataCpf(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.form[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		document.form[campo].value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.form[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}

<!--
//Funcao para carregar o iframe com tamanho maior a depender da configuraçaõ do browser do usuario
function Carrega_Iframe()
{
if (window.screen.width == 1024)
 document.writeln(' <iframe border=0 name="Lista_Informacao" frameborder=0 scrolling="auto" marginwidth=0 width="100%" height=460px> </iframe>');
else
 document.writeln(' <iframe border=0 name="Lista_Informacao" frameborder=0 scrolling="auto" marginwidth=0 width="100%" height=340px> </iframe>');
 }
//-->

function Carrega_foto_iframe(cod_foto){

	window.frames["mostra_foto"].location = 'imoveis_foto_ampliada.asp?cod_foto='+cod_foto;
}

// Estas funcoes mudam a cor da linha da tabela
  function mOvr(src,clrOver) {
	  src.style.cursor = 'hand';
	  src.bgColor = clrOver;
  }
  
  function mOut(src,clrIn) {
	  src.style.cursor = 'default';
	  src.bgColor = clrIn;
  }
  
  function mClk(src) {
	  src.children.tags('A')[0].click();
  }

function abrePopUpCentro(url, vwidth, vheight,vscroll){
	//pega a resolução do visitante
	w = screen.width;
	h = screen.height;
	
	//divide a resolução por 2, obtendo o centro do monitor
	meio_w = w/2;
	meio_h = h/2;

	//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
	altura2 = vheight/2;
	largura2 = vwidth/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;
		
	window.open(url,'','toolbar=0,menubar=0,width=' + vwidth + ',height=' + vheight + ',top=' + meio1 + ',left=' + meio2 + ',scroolbar='+vscroll+'');
}

//Filtra os caracteres digitados mostra, retorna apenas numeros
//OnkeyPress = "return filtraTecla(this,event);"
function filtraTecla(Objeto,event)
{
	var tecla;
	var key;
	var strValidos = "0123456789"

	if( navigator.appName.indexOf("Netscape")!= -1 )
	tecla= event.which;
	else
	tecla= event.keyCode;
	return isNum( String.fromCharCode( tecla) );
}

function isNum( caractere )
{
	var strValidos = "0123456789";
	if ( strValidos.indexOf( caractere ) == -1 )
	return false;
	else
	return true;
}