function print_imovel(id) {
	var ww = 520;var center_y = (screen.height/2)-(ww/2);
	var wh = 680;var center_x = (screen.width/2)-(wh/2);
	MM_openBrWindow("imovel.print.inc.php?id="+id,"detalhe","scrollbars=yes, width="+ww+", left="+center_x+", top="+center_y+"\"");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function initialize(){
		MM_preloadImages('images/menu_02_02.gif','images/menu_02_03.gif','images/menu_02_04.gif','images/menu_02_05.gif','images/menu_02_06.gif','images/menu_02_07.gif','images/menu_02_08.gif');
}

//FUNÇÃO PARA VALIDAÇÃO DO FORMULÁRIO DE CONTATO
function ValidaContato(formContato){
	with (formContato){
		if (nome.value == "") {
			alert('Favor preencher o campo Nome!');
			nome.focus();
			return false;
		}
		if (telefone.value == "") {
			alert('Favor preencher o campo Telefone!');
			telefone.focus();
			return false;
		}
		if (email.value == "") {
			alert('Favor preencher o campo E-mail!');
			email.focus();
			return false;
		} else {
			var x = email.value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!filter.test(x)) {
				alert('Formato de e-mail inválido!');
				email.focus();
				email.select();
				return false;
			}
		}
		if (assunto.value == "") {
			alert('Favor preencher o campo Assunto!');
			assunto.focus();
			return false;
		}
		if (mensagem.value == "") {
			alert('Favor preencher o campo Mensagem!');
			mensagem.focus();
			return false;
		}
		if (codigo_seguranca.value == "") {
			alert('Favor preencher o Código de Segurança!');
			codigo_seguranca.focus();
			return false;
		}
		return true;
	}
}

//FUNÇÃO PARA VALIDAÇÃO DO FORMULÁRIO DE LOGIN ANUNCIANTE (EXTRANET)
function ValidaLogin(formLogin){
	with (formLogin){
		if (USUARIO.value == "") {
			alert('Favor preencher o nome de Usuário!');
			USUARIO.focus();
			return false;
		}
		if (SENHA.value == "") {
			alert('Favor preencher a Senha!');
			SENHA.focus();
			return false;
		}
		return true;
	}
}

//FUNCAO PARA TROCA DE IMAGENS
function troca_imagem(cid, img, tam){
	//document.getElementById('imgG').src = "http://www.imovelbauru.com.br/2006/upload/fotos/imoveis/"+cid+"/360/"+img;
	document.getElementById('imgG').src = "http://www.imovelbauru.com.br/2006/resize.php?img=2006/upload/fotos/imoveis/"+cid+"/"+img+"&img_x="+tam;
}

//AMPLIACAO DAS IMAGENS
function DisplayImage(picURL){
	var bImg = new Image();

	bImg.src = picURL.replace('imagens/','imagens/g');
	
	if ((bImg.width == 0) && (bImg.height == 0)) {
		bImg.width = 600;
		bImg.height = 600;
	}

	posx = (screen.width/2)-(bImg.width/2);
	posy = (screen.height/2)-(bImg.height/2);
	newWindow=window.open('','zoom','toolbar=no,width='+bImg.width+',height='+bImg.height+',left='+posx+',top='+posy);
	newWindow.document.write('\
	<html><head><\/head>\
	<body style="background-color: #BC9B6A;margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;">\
	<a href="javascript:window.close()">\
		<img id="img_m" border="0" src="'+bImg.src+'">\
	</a>\
	<\/body><\/html>\
	');
	newWindow.document.close();
	newWindow.focus();
}

function abrirCategoria(cat){
	ajaxHTML('meioconteudo','anunciantes.inc.php?pcat='+cat+'&scat=0');	
	trocarTitulo(cat);
}

function abrirConteudo(cat){
	ajaxHTML('meioconteudo','conteudo.inc.php?secao=conteudo&cat='+cat+'&scat=0');	
	trocarTitulo(cat);
}

function abrirHotsite(cat, id){
	document.getElementById('fundok').style.display = 'block';
	document.getElementById('hot').style.display = 'block';
	ajaxHTML('hot','hotsite.php?secao=conteudo&pcat='+cat+'&scat=0&id='+id);
	document.getElementById('fundok').style.height = document.body.scrollHeight+25;
}

function fecharHotsite(cat){
	document.getElementById('fundok').style.display = 'none';
	document.getElementById('hot').style.display = 'none';
}

function atualizaHotsite(cat){
	ajaxHTML('hot','hotsite.php?secao=conteudo&cat='+cat+'&scat=0');
}

function trocarTitulo(num){
	document.getElementById('titulo_cat').src='images/tit_'+num+'.gif';
}

function buscaRapida(){
	var qs='';
	if (document.getElementById('busca_rapida').BUSCA.value == ""){
		alert('Preencha o parâmetro para busca');
		return false;
	} else {
		qs += '?BUSCA='+document.getElementById('busca_rapida').BUSCA.value;
		alert(qs);
	}
	ajaxHTML('meioconteudo','anunciantes.inc.php'+qs);
}

function enterPress(){
	var keycode;
	if (window.event){
		keycode = window.event.keyCode;
	}else{
		if(e){
			keycode = e.which;
		}else{
			return true;
		}
	}
	
	if (keycode == 13){
		buscaRapida();
		return false;
	}else{
		return true;
	}
	/*
	if ((window.event ? event.keyCode : event.which) == 13){
		buscaRapida();
		return false;
	}
	*/
}