meuTimer1 = 0;
IMGcarregando = new Image;
IMGcarregando.src = 'imagens/b.gif';

function mudaimg(nome, count)
	{
		var id = nome
		var nomefoto = count
		var infofoto = count

		document.MAINFOTO.src=IMGcarregando.src;
		document.MAINFOTO.src=infofoto;

       // foi excluido document.menuthumb.desc.value = nomefoto;
		document.menuthumb.numatual.value = id;
		document.menuthumb.selectfoto.value = count;

	   meuTimer1 = window.setTimeout('timer()', 500);
	   return lixoatomo = infofoto;
	}
function timer(){
resizeImage(lixoatomo);
}

function resizeImage(count)
	{
		theimg = new Image();
    	theimg.src = count;
    	h = theimg.height;
    	w = theimg.width;
		
//		window.clearTimeout(meuTimer1);
		if (h > 0 && w > 0)
			{
				document.MAINFOTO.height = h;
				document.MAINFOTO.width  = w;
			}
		else
			{
				   meuTimer1 = window.setTimeout('timer()', 500);
			}
	}


function goto() {
  window.location = document.MAINFOTO.src;
}
function getmain(id){
ajaxGet(url, document.getElementById("main"),true)
}
function getcontent(id){
ajaxGet('conteudo.php?includemain=ok&id='+id,document.getElementById('main'),true)
}
function mapa(url){
if(url == true){
ajaxGet("mapa_embed.php", document.getElementById("mapa"),true)
}
else{
ajaxGet("branco.php", document.getElementById("mapacontent"),true)
}
}
function admfotos(url, variaveis){
    aleat = Math.random() * 234444343434565342
ajaxGet(url+".php?odkns="+aleat+"&"+variaveis,document.getElementById("actfotos"),true)
document.filtro.bnome.value = url+".php?odkns="+aleat+"&"+variaveis
}
function recarrega(){
ajaxGet(document.filtro.bnome.value ,document.getElementById("actfotos"),true)
}
function ajaxmandaportal(url, variaveis, local){
aleat = Math.random() * 234444343434565342
ajaxGet(url+".php?odkns="+aleat+"&"+variaveis,document.getElementById(local),true)
}

function popup(titulo, phpvai){
tb_show(titulo,'','');
ajaxGet(phpvai, document.getElementById('TB_ajaxContent'),true);
}
function popimg(phpvai){
tb_show();
ajaxGet('fotopopup.php?pagesize='+tb_getPageSize()+'&foto='+phpvai, document.getElementById('TB_load'),true)
}
function popmapa(phpvai){
tb_show();
ajaxGet('mapapopup.php?pagesize='+tb_getPageSize()+'&id='+phpvai, document.getElementById('TB_load'),true)
}
function login(){
ajaxGet('login.php', document.getElementById('login_logis'), true);
}
function pop360(phpvai){
tb_show();
ajaxGet('360pop.php?pagesize='+tb_getPageSize()+'&id='+phpvai, document.getElementById('TB_load'),true)
}
function popvideo(phpvai){
tb_show();
ajaxGet('videopopup.php?pagesize='+tb_getPageSize()+'&video='+phpvai, document.getElementById('TB_load'),true);
}
function popinfo(phpvai){
tb_show('Sobre...','','');
ajaxGet('conteudo_mostra.php?id='+phpvai,document.getElementById('TB_ajaxContent'),true);
}
function popfotos(phpvai){
tb_show();
ajaxGet('popfotos.php?pagesize='+tb_getPageSize()+'&id='+phpvai, document.getElementById('TB_load'),true)
}

function janela(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
function linhadotempo(num){
ajaxGet('linhadotempo_pesquisa.php?'+num, document.getElementById('linhapesquisa'),true);
document.getElementById('conteudo_mostra').innerHTML = '';
}

function imgtam(num){
if(num == 1){
var add1 = num - 0;
} else {
var add1 = num - 19;
}
if(strat.height != add1){
strat.height=strat.height + (num - strat.height)/20;
meuTimer1 = setTimeout("imgtam('"+num+"')", 0);
}else{
clearTimeout(meuTimer1);
}
}

function convertesubtipoimovel(id){

if (id == 1){
document.getElementById('subtipoimovel').innerHTML = '<select style="width:160" id="subtipovalue"  name="subtipoimovel"><option value="">Indiferente</option><option value="1">Apt. Padr&atilde;o</option><option value="2">kitchenette</option></select>';
}
if (id == 2){
document.getElementById('subtipoimovel').innerHTML = '<select style="width:160" id="subtipovalue"  name="subtipoimovel"><option value="">Indiferente</option><option value="1">Casa padr&atilde;o</option><option value="2">Casa de condom&iacute;nio</option></select>';
}
if (id == 3){
document.getElementById('subtipoimovel').innerHTML = '<select style="width:160" id="subtipovalue"  name="subtipoimovel"><option value="">Indiferente</option><option value="1">Casa</option><option value="2">Conjunto comercial / salas</option></select>';
}
if (id == 4){
document.getElementById('subtipoimovel').innerHTML = '<select style="width:160" id="subtipovalue"  name="subtipoimovel"><option value="">Indiferente</option><option value="1">Terreno padr&atilde;o</option><option value="2">Condom&iacute;nio</option></select>';
}
if (id == 5){
document.getElementById('subtipoimovel').innerHTML = '<select style="width:160" id="subtipovalue"  name="subtipoimovel"><option value="">Indiferente</option><option value="1">ch&aacute;caras</option><option value="2">Fazendas</option><option value="3"> S&iacute;tios</option></select>';
}

}

function mostraclasstipo(id){
if (id == 1){
document.getElementById('classimovel').style.display = 'block';
document.getElementById('classpesq').style.display = 'none';
}else{
document.getElementById('classpesq').style.display = 'block';
document.getElementById('classimovel').style.display = 'none';
}
}
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function soNumeros(v){
    return v.replace(/\D/g,"")
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}
function dats(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1-$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{2})(\d)/,"$1-$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    return v
}

function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}

function site(v){
    //Esse sem comentarios para que você entenda sozinho ;-)
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?&])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}

function showtr(id){
if (document.getElementById('main_coluna'+id).style.display == ''){
document.getElementById('main_coluna'+id).style.display = 'none';
document.getElementById('main_coluna_img'+id).src = 'imagens/vejamais.gif'
} else {
document.getElementById('main_coluna'+id).style.display = '';
document.getElementById('main_coluna_img'+id).src = 'imagens/expand.gif'
}}
function expdeshowtr(tipo){
//
var xx = document.getElementById('qdtcresults').value;
clearTimeout(ssssss);
	if(tipo == 'm'){
		for (var i=0; i<xx; i++){
			var cont = xx - 1 - i;
			var ssssss = setTimeout('timershowtr('+i+', "none")', 1 + 100 * cont);
		}
	}
	else {
			for (var i=0; i<xx; i++){
			var ssssss = setTimeout('timershowtr('+i+', "")', 1 + 100 * i);
	     }
	}
}
function timershowtr(id, acao){
document.getElementById('main_coluna'+id).style.display = acao;
if(acao == ""){
document.getElementById('main_coluna_img'+id).src = 'imagens/expand.gif'
}else{
document.getElementById('main_coluna_img'+id).src = 'imagens/vejamais.gif'
}
}

	// pesquisa geral
	
	function pesquichange(id, tipo){
for (var i=1; i<=5; i++){
		if(i == id){
		document.getElementById('pesq'+i).className = 'pesquisa_geral_select';
		}else{
		document.getElementById('pesq'+i).className = 'pesquisa_geral_noselect';
		}
	}
	document.getElementById('tipobusca').value = tipo;
	if(tipo != 'b'){
	document.getElementById('pesqavan').style.display = 'none';
	  if(document.getElementById('pesquisaavancada').style.display == 'block'){
	     document.getElementById('pesquisaavancada').style.display = 'none';
	  }
	}else{
	 document.getElementById('pesquisaavancada').style.display = 'block';
	document.getElementById('pesqavan').style.display = 'block';
	}
	
	
}
function openfunny(){
document.getElementById('funny').style.visibility='visible';
document.getElementById('funny').innerHTML='<object width="643" height="440"> <param name="movie" value="flw/funny.swf">                        <param name="quality" value="high">                        <param name="wmode" value="transparent" />                 <embed src="flw/funny.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="643" height="440"></embed></object>';
}
function closefunny(){
document.getElementById('funny').style.visibility='hidden';
document.getElementById('funny').innerHTML='';
}		

function executa(){
document.getElementById("carrega").innerHTML =  '';
}

function escondepubli(){
document.getElementById("publicidade").style.display =  'none';
document.getElementById("publicidade").innerHTML =  '';

}

//muda tam fonte
var tgs = new Array( 'div' );
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;
function tamspan() {
		var d = document,cEl = null,sz = startSz,i,j,cTags;
		cEl = d.getElementsByTagName('span');
	for(i=0;i<cEl.length;i++){
	cEl[i].style.fontSize = szs[startSz];
	}
}
function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;
sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 6 ) sz = 6;
startSz = sz;
if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
cEl.style.fontSize = szs[ sz ];
for ( i = 0; i < tgs.length; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
tamspan();
}
function roundVal(val){
	var dec = 0;
	var result = Math.round(val*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function carrinho_add(qtd){
valorantigo = roundVal(document.getElementById('carrinhoqtd').innerHTML);
valor = roundVal(qtd);
novovalor = valorantigo + valor;
document.getElementById('carrinhoqtd').innerHTML = novovalor;
}	

function animaestrela(pos, meiopos, id){
unik = 0;
	for (var i=1; i<=5; i++){
		if(pos >= i){
		document.getElementById('estrela'+id+i).src = "imagens/estrela.gif"
		}else{
			if(meiopos >= 1 && unik < 1){
				unik = 1;
				document.getElementById('estrela'+id+i).src = "imagens/estrela_m.gif"
			}else{
				document.getElementById('estrela'+id+i).src = "imagens/estrela_u.gif"
			}
		
		}
	}
}
function vota(id, value){
alert('obrigado pelo voto');
ajaxGet("vota.php?id="+id+"&value="+value,document.getElementById("retornovota"),false);
}
function vidocobertura(video){
document.getElementById('video_whath').style.visibility='visible'; 
ajaxGet('video.php?video='+video, document.getElementById('exibe_video_main'), true);
}
function downloadimg() {
	if( event.button == 2 ){
	if(confirm("Deseja baixar essa foto?")){
        window.location = 'download.php?foto='+URLEncode(document.menuthumb.selectfoto.value);
	}}
}