function formataVideos(){

	var objs = document.getElementsByTagName("object");
	
	n =objs.length;
	
	for(i=0; i<n; i++){
	
		if ( objs[i].id != 'BANNERS'  ){
		
			
						
			objs[i].width = 400;
			

		}
	
	
	
	}
	var embeds = document.getElementsByTagName("embed");
	
	n =embeds.length;
	
	for(i=0; i<n; i++){
	
		if ( embeds[i].id != 'BANNERS' ) {
			
			embeds[i].width = 400;

			

		}
	
	
	
	}

}

function mostraCamada( id ){

			



		document.getElementById(id).style.display='';

	



}









function escondeCamada( id ){





		

		

	document.getElementById(id).style.display='none';

	



}





function sel_option(id,valor){

	

	var o = document.getElementById(id);

	

	var n = o.length;

	var indice=0;
	
	
	for(	i = 0;	i < n;	i++	){

	

		if(o.options[i].value == valor){

		

			indice=i;

		

		}

	

	}

	

	

	o.selectedIndex=indice;



}





function MudaCorBorda(obj,estilo_borda){





	obj.style.border = estilo_borda;





}



function getPosicaoElemento(elemID){

    var offsetTrail = document.getElementById(elemID);

    var offsetLeft = 0;

    var offsetTop = 0;

    while (offsetTrail) {

        offsetLeft += offsetTrail.offsetLeft;

        offsetTop += offsetTrail.offsetTop;

        offsetTrail = offsetTrail.offsetParent;

    }

    if (navigator.userAgent.indexOf("Mac") != -1 && 

        typeof document.body.leftMargin != "undefined") {

        offsetLeft += document.body.leftMargin;

        offsetTop += document.body.topMargin;

    }

    return {left:offsetLeft, top:offsetTop};

}



function mostraSub( n ){





				var subcate = document.getElementById( "subcate_"+n);

				var cate = document.getElementById( "cate_"+n);

				

				var left = new Number(getPosicaoElemento("cate_"+n).left + 120);				

				var top = new Number(getPosicaoElemento("cate_"+n).top);				



			 

				

			 subcate.style.left = left.toString() +"px";				

			 subcate.style.top  = top.toString()+"px";

   		   subcate.style.display = "block";

	 

			 cate.className = "itemCate";



}			   



function escondeSub( n ){



				var subcate = document.getElementById( "subcate_"+n);

				var cate = document.getElementById( "cate_"+n);

				

			   subcate.style.display='none';


			 			 cate.className = "itemCateNotSel";

}			 			 





function envia_form(){



   document.getElementById( 'posts' ).submit();





}







function valida_email( obj )

{



  var txt = obj.value;

  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))

  {

    alert('Email incorreto');

	obj.focus();

  }

}



function mostra( foto ){



		

		document.getElementById('enquete').innerHTML = document.getElementById('parcial').innerHTML;

	

		

}





function esconde( foto){

	

	document.getElementById('enquete').innerHTML = document.getElementById('urna').innerHTML;



}



function MudaCor( OBJ ){





    OBJ.style.color = '#FFFFFF';







}

function VoltaCor( OBJ ){





    OBJ.style.color = '#666666';







}



function muda_img( obj, img ){





	obj.src = img;



}



function habilita( id ){





	document.getElementById(id).style.visibility="visible";





}



function mostra_cate( ){



//	document.getElementById('categorias').style.float= "right";

	document.getElementById('categorias').style.overflowY="auto";

	//document.getElementById('categorias').style.width= "200px";





}



function esconde_cate( ){



	document.getElementById('categorias').style.overflowY="hidden";

	document.getElementById('categorias').style.width= "";

	document.getElementById('categorias').style.float= "";



}



function SomenteNumero(e){

    

	var tecla=(window.event)?event.keyCode:e.which;

    

	if((tecla > 47 && tecla < 58)) return true;

    else{

    if (tecla != 8) return false;

    else return true;

    }

}



function testa_email( obj ){



	email = new String( obj.value );



	re = /^[^@]+@[^@]+.[a-z]{2,}$/i;

	

	

	if(email.search(re) == -1)		{

	

		return false;



	}

	else {

		return true;	

	}

}





function valida_form(){

	

	var nome = document.getElementById('NOME_CONT');

	var tel  = document.getElementById('TEL_CONT');

	var email= document.getElementById('EMAIL_CONT');

	var msg  = document.getElementById('MSG');

	

	erro ='';

	

	if ( nome.value == '' ){

	

		erro = 'nome, ';

		

	

	}

	

	if ( tel.value == '' ){

	

		erro = erro + 'telefone, ';

		

	

	}

	

	if ( ! testa_email(email) ){

	

		erro = erro + 'email, ';

		

	

	}

	

	if ( msg.value == '' ){

	

		erro = erro + 'mensagem, ';

		

	

	}

	

	if ( erro != ''){

		erro = erro.substr(0,(erro.length - 2))

		alert ('Por favor, preencha corretamente o(s) campo(s) ' + erro + '.');

	

	}

	else{

	

	

		document.getElementById('posts').submit();

	

	

	}

	

	



}







function valida_email( obj )

{



  var txt = obj.value;

  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))

  {

    alert('Email incorreto');

	obj.focus();

  }

}





function testa_vazio( obj, msg ){



	if ( obj.value == '' ){

	

		alert( msg );



	

	}

}



function valida_cad_news(event){

var nome 	= 	document.getElementById('NOME_CAD');

var email 	=	document.getElementById('EMAIL_CAD');
	
	if (nome.value == '') {
	
		CancelaEvento(event);
		alert('Nome inválido');
			
	
	}
	else if ( ! testa_email(email) ){
	
		CancelaEvento(event);
		alert('Email inválido');
	
	
	}

}



function testa_email( obj ){



	email = new String( obj.value );



	re = /^[^@]+@[^@]+.[a-z]{2,}$/i;

	

	

	if(email.search(re) == -1)	{

	

		return false;

				

	

	}

	else{

		return true;	

	

	}



}





function envia_form(){



   document.getElementById('form2').submit();





}



function muda_img_enviar( img ){





	img.src ='imagem/enviar1.gif';



}

function muda_img( obj, img ){



	obj.src = img;





}



function fecha_popup(){

	var popup =  document.getElementById('popup');

	popup.style.display='none';





}





function mover(idElemento){



	var elemento = document.getElementById(idElemento);                     

	

	if (navigator.appName == "Microsoft Internet Explorer")

	{

	

			position = document.body.scrollTop;

			

		

	

	}

	else {

	

			position = window.pageYOffset;

			

			

	}	

		

	

	//var top= new Number(	window.innerHeight - getPosicaoElemento(idElemento).top + position);	

	

	top=position + 200;

	

	var s_top = top.toString()+"px";

	

	

	elemento.style.top = s_top;







}

function pos(idElemento, top,left){

	

	var elemento = document.getElementById(idElemento);    

	

	elemento.style.top = top+"px";

	elemento.style.left = left+"px";	



}



function centerOnScreen(id){

var elx = document.getElementById(id);//pega o elemento ext

var fw = elx.style.width;//pega a largura do elemento

var fh = elx.style.height;//pega a altura do elemento

var sw = screen.width;//pega a largura da tela

var sh = screen.height;//pega a altura da tela

var pt = (sh-fh)/4;//calcula distância do topo

var pl = (sw-fw)/2;//calcula distância do lado esquerdo

var el = document.getElementById(id);//pega o elemento DOM

el.style.position = 'absolute';//define como posição absoluta

el.style.top = pt + 'px';//define distãncia do topo

el.style.left = pl + 'px';//define distância da margem esquerda

}

function habilita_combo(obj){

	var i	=	obj.selectedIndex;
	var v	=	obj.options[i].value;
	
	if( v == 3) {
	
		document.getElementById('cod_cate').disabled=false;
	
	}
	else if( v== 4){

		document.getElementById('cate_noti').disabled=false;
	
	}
	else{
		document.getElementById('cod_cate').disabled=true;
		document.getElementById('cate_noti').disabled=true;
	
	}
	

}

function valida_busca(event){

var valor = document.getElementById('nome_empr').value;

	if ( (valor == '') || (valor == 'O que você está procurando?') || (valor.length < 3) ){
	
		CancelaEvento(event);
		

	}

}

function texto_busca(obj, event){
	
	var EVENTO =event.type;
	
	
	switch (EVENTO) {
	
	
		case "blur":
	
		
				if ( obj.value == '' ){
	
					obj.value='O que você está procurando?';
					
					
				}
			
			
		break;
		
		
		case "focus":
		
	
				
				if ( obj.value == 'O que você está procurando?' ){
	
					obj.value='';
					
									
					
				}	
			
				
	
	
		break;
		
	}

	

}
function CancelaEvento(event){



	if (navigator.appName == "Netscape") {
	
	
		
		event.preventDefault();


		
	}
	else {

		event.returnValue = false;		
	
	
	}


}
function chama_pagina(){

	var tipoimovel 		= document.getElementById('tipoimovel');
	
	var min				= document.getElementById('min');
	
	var quartos			= document.getElementById('quartos');
	
	var areaconstruida	= document.getElementById('areaconstruida');
	
	var gets = 'tipoimovel='+tipoimovel.options[tipoimovel.selectedIndex].value;

	gets = gets + '&min='+min.options[min.selectedIndex].value;

	gets = gets + '&quartos='+quartos.options[quartos.selectedIndex].value;

	gets = gets + '&areaconstruida='+areaconstruida.options[areaconstruida.selectedIndex].value;
				
	
	
	pagina('imoveis.php?'+gets);

}