function buscaButton(){
	cp=document.getElementById('bdButton');
	cp.innerHTML='<input type="submit" class="submit" align="absmiddle" value=" Pesquisar " style="margin-right:10px;" />';
}

function imprimirMapa(){
	window.open('arquivos/mapa.html', null, 'help=no,status=no,scrollbars=yes,resizable=no,width=680,height=480,dependent=yes', false);
}

var margemEsq=100;

var map;
var i=0;
function createMarker(point, htmlText) {
    var infoTabs = [
      new GInfoWindowTab("tab"+(i+1), htmlText)
    ];
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowTabsHtml(infoTabs);
  });
  map.addOverlay(marker);
  marker.openInfoWindowTabsHtml(infoTabs);
}

function load_maps() {
  if (GBrowserIsCompatible()) {
	m=document.getElementById("map")
	if(m!=undefined){
		map = new GMap2(m);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(-27.127070628997252, -48.602668046951294), 18);
		map.setMapType(G_HYBRID_MAP);

			createMarker(new GLatLng(-27.127605351389985, -48.60193848609924),"<div style='font-family:Arial, Helvetica, sans-serif; background-color:#ffffff; font-size:10px'><b>Cal&ccedil;ad&atilde;o Praia Shopping</b></div>");
			createMarker(new GLatLng(-27.127228181396507, -48.602131605148315),"<div style='font-family:Arial, Helvetica, sans-serif; background-color:#ffffff; font-size:10px'><b>Supermercado Bar&atilde;o</b></div>");
			createMarker(new GLatLng(-27.12495081149728, -48.60384821891785),"<div style='font-family:Arial, Helvetica, sans-serif; background-color:#ffffff; font-size:10px'><b>Banco do Brasil</b></div>");
			createMarker(new GLatLng(-27.12862704599495, -48.60121428966522),"<div style='font-family:Arial, Helvetica, sans-serif; background-color:#ffffff; font-size:10px'><b>Shopping Russi & Russi</b></div>");
			createMarker(new GLatLng(-27.127070628997252, -48.602668046951294),"<div style='font-family:Arial, Helvetica, sans-serif; background-color:#ffffff; font-size:10px'><b>Imobili&aacute;ria Morada do Solria</b><br />Fone: (47) 3368-6988<br />Av. Nereu Ramos, n&deg; 3750, Sala 01 - Meia Praia - Itapema - SC</div>");
	}
  }
}


function linkMaisOver(n){
	m=document.getElementById("m"+n);
	m.className="mOver";

	t=document.getElementById("t"+n);
	t.className="tOver";
	m.style.cursor=t.style.cursor="pointer";
}
function linkMaisOut(n){
	m=document.getElementById("m"+n);
	m.className="mOut";

	t=document.getElementById("t"+n);
	t.className="tOut";
}

function janelaOnline(){
	window.open("arquivos/atendimento.php",null,"height=300,width=300,status=yes,toolbar=no,menubar=no,location=no");
}

function click0800() {
	var page = 'click0800.php?si=1&sf=6&hi=09&hf=18'
	var yes = 1;
	var no = 0;
	var menubar = no;
	var scrollbars = no;
	var locationbar = no;
	var directories = no;
	var resizable = no;
	var statusbar = no;
	var toolbar = no;
	var width = 336;
	var height = 186;
	var top = (screen.height - height) / 2 - 200;
	var left = (screen.width - width) / 2;
	windowprops = "width=" + (width) + ",height=" + (height) + ",top=" + (top) + ",left=" +	(left);
	windowprops += (menubar ? ",menubars" : "") + (scrollbars ? ",scrollbars" : "") +	(locationbar ? ",location" : "") +	(directories ? ",directories" : "") +	(resizable ? ",resizable" : "") +	(statusbar ? ",status" : "") + (toolbar ? ",toolbar" : "");
	window.open(page, 'fullPopup', windowprops);
}


/* dryes [at] criticalmass.com */
function FlashLibrary(){
    var t = this;
    var activeX = false;
    t.ieAutoInstall = false;
    t.hasVersion = function(ver){
        t.swf = false;
        if(!ver) ver = 0;
        var n = navigator;
        if(n.plugins && n.plugins.length > 0){
            var m,tp,d,v;
            m = n.mimeTypes;
            tp = 'application/x-shockwave-flash';
            if(m && m[tp] && m[tp].enabledPlugin && m[tp].enabledPlugin.description){
                d = m[tp].enabledPlugin.description;
                v = d.charAt(d.indexOf('.')-1);
                t.swf = (v >= ver) ? true : false;
            }
        }else if(n.appVersion.indexOf("Mac") == -1 && window.execScript){
            for(var i=ver; i<=7&&i!=1&&t.swf!=true; i++){
                execScript('on error resume next: flash.swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');
            }
            if(t.swf) {
                activeX = true;
           }

        }else{
            t.swf = false;
        }
        return t.swf;
    }
    t.getPluginTag = function(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags){
        var s = '';
        var safari = (navigator.userAgent.toLowerCase().indexOf('safari') != - 1);
        var win = (navigator.appVersion.toLowerCase().indexOf("win")!=-1);
        var ie = (navigator.appName=="Microsoft Internet Explorer");
        if(!ie || (t.hasVersion(ver) && swfFile || (win && ie && swfFile && t.ieAutoInstall))){
            var additionalParams = '';
            if(params && params.length>0){
                var pArray = params.split(",");
                for(var i=0; i<pArray.length; i++){
                    var ta = pArray[i].substr(0,pArray[i].indexOf('='));
                    var v = pArray[i].substr(pArray[i].indexOf('=')+1,pArray[i].length);
                    additionalParams += (activeX)?'\t<param name="' + ta + '" value="' + v + '" />\n': ' '+ ta + '="' + v + '"';
                }
            }
            if(activeX){
                s = '<object id="flashObj'+name+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,21,0" width="'+width+'" height="'+height+'" '+pTags+'>\n';
                s += '\t<param name="movie" value="'+swfFile+'" />\n';
                s += '\t<param name="quality" value="high" />\n';
                s += '\t<param name="menu" value="false" />\n';
                s += '\t<param name="bgcolor" value="'+bgcolor+'" />\n';
                s += additionalParams;
                s += altFormat;
                s += '</object>\n';
                return s;
            }else{
                s = '<embed id="flashObj" src="'+swfFile+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'"'+additionalParams+(safari?' class="safari"':'')+'></embed>\n';
                return s;
            }
        }else{
            return altFormat;
        }
    }
    t.embedMovie = function(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags,retu){ 
		if(retu)
			return flash.getPluginTag(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags);
		else
	        document.write(flash.getPluginTag(swfFile,width,height,bgcolor,ver,altFormat,params,name,pTags)); 
    } 
}
var flash = new FlashLibrary();




IE4 = (document.all);
NS4 = (document.layers);

///////////////////// AJAX
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function ajaxRead(url,funcao,retorna){
    xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange=function(){
        if (xmlhttp.readyState==4){
			var texto=xmlhttp.responseText;
			texto=unescape(texto.replace(/\+/g," "));
			//alert(texto);
			eval(funcao);
			if(retorna!=undefined)
				return texto==retorna;
        }
    }
    xmlhttp.send(null);
}


function locacaoClick(request){
	locacao.innerHTML="Carregando...";
	ajaxRead("arquivos/locacaotemp.php"+request,"locacao.innerHTML=texto;");
}

function locacaoForm(form){
	if(document.periodo.pfim.value=="" || document.periodo.pini.value==""){
		alert("O período deve ser preenchido corretamente.");		
	} else {
		if(document.periodo.pfim.value<document.periodo.pini.value)
			alert("A data final deve ser maior que a inicial.");
		else if(document.periodo.pini.value==document.periodo.pfim.value)
			alert("A data final deve ser diferente que a inicial.");
		else {
			request="?id="+form.id.value+"&pfim="+form.pfim.value+"&pini="+form.pini.value;
			ajaxRead("arquivos/locacaotemp.php"+request,"locacao.innerHTML=texto;");
		}
	}
}





function calendario(receptor,obj2,busca,comp,fixo,ajax){
	obj=eval("document.periodo."+obj2);
	if(ajax==undefined){
		url="arquivos/calendario.php?receptor="+receptor+((comp!=false)? comp : "")+((obj.value!="")? "&data_atual="+obj.value : "")+"&obj="+obj2+"&busca="+busca;
		ajaxRead(url,"calendario(texto,'"+obj2+"',false,false,"+fixo+",true);");		
	} else {
		jsfuncoes.innerHTML=receptor;
		calendario_mask.innerHTML="<iframe id='calendario_mask_frame' src='javascript:false' style='filter:Alpha(Opacity=0); width:212px; height:159px;'></iframe>";
		if(!fixo){
			calendario_mask.style.left=jsfuncoes.style.left=findPosX(obj)+76;
			calendario_mask.style.top=jsfuncoes.style.top=findPosY(obj)+18;
		}
	}	
}

function isArray(obj){
	return(typeof(obj.length)=="undefined")?false:true;
}
function calendHide(){
	calendario_mask.innerHTML=jsfuncoes.innerHTML="";
}
function calendMClick(src,data){
	if(isArray(src)){
		for(i=0;i<src.length;i++)
			src[i].value=data;
	} else {
		src.value=data;
	}
		calendHide();
}
function calendMOver(src) {
	src.style.cursor="hand";
	src.bgColor="#003366";
	src.style.color="#FFFFFF";
}
function calendMOut(src) {
	src.bgColor="#77BBFF";
	src.style.color="#000000";
}
function calendFunc(receptor,data_atual,busca,url,local){
	sel=local.options[local.selectedIndex].value;
	calendario(receptor,data_atual,busca,url+sel,true);
}


function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

function getMouseXY() {
	tempX = event.clientX+document.body.scrollLeft;
	tempY = event.clientY+document.body.scrollTop;
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;} 
}

blOvr=false;
blBlock=true;
function blOver(){
	blOvr=(blOvr==false)?true:false;
}
function blPos(){
	if(blOvr==false){
		altmove=findPosY(blMovef)-findPosY(blMovei)+4;
		altmin=findPosY(blTop);
		altmax=findPosY(blBottom)-altmin-altmove;
		r=tempY-altmin-(altmove/2);
		if(r>altmax)
			r=altmax;
		if(r<0)
			r=0;
		blMove.style.marginTop=r;
	}
}
function blRun(){
	if(blBlock==false){
		getMouseXY(); 
		blPos();
	}
}

function mOvr(src) {
  if (!src.contains(event.fromElement)) {
	  src.style.cursor = 'hand';
  }
}
function mClick(url){
	window.location=url;	
}
function posicionaPag(pos){
	t=String(window.location);
	if(t.indexOf("#")==-1 && document.body.scrollTop==0)
		window.location=window.location+pos;
}
function voltar(){
	vol=-1;
	t=String(window.location);
	if(t.indexOf("#")!=-1)
		vol--;

	history.go(vol);
}
function altTitle(){
	t=String(document.title);
	if(t.indexOf("#")!=-1){
		r=t.substring(0,t.indexOf("#"));
		document.title=r;
	}
}

function cel(local){
	bgcolor1="#ffffff";
	bgcolor2="#e6f7ff";
	cor=document.getElementById("a"+local).style.backgroundColor;
	if(cor==bgcolor1){
		document.getElementById("a"+local).style.backgroundColor=bgcolor2;
		document.getElementById("a"+local).style.border="2px solid #CEEFFF";
	} else if(cor==bgcolor2){
		document.getElementById("a"+local).style.backgroundColor=bgcolor1;
		document.getElementById("a"+local).style.border="2px solid #FFFFFF";
	}
}



function validate_contato(){
if (document.contato.nome.value=="") {
alert("Preencha seu nome.")
document.contato.nome.focus();
return false
}
if (document.contato.email.value=="") {
alert("Preencha seu e-mail.")
document.contato.email.focus();
return false
}
else {
    fieldName   = document.contato.email;
    fieldValue  = fieldName.value;
    fieldLength = fieldValue.length;

    var err01   = "Preencha seu e-mail corretamente.";
    var err02   = "Preencha seu e-mail corretamente.";

    if ( fieldLength < 8 ) {
        alert( err01 );
        fieldName.focus();
                return false
    } else {
        if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test( fieldValue )) {
        } else {
            alert( err02 );
            fieldName.focus();
                        return false
        }
    }
}
document.contato.submit();
}
function mOver(src) {
        var local = src;
        eval(local+'.style.cursor=\"hand\"')
        eval(local+'.bgColor=\"#FFFFFF\"')
        eval(local+'.style.color=\"#000000\"');
}
function mOut(sr,diaCo) {
        var local = sr;
        valor = document.incluir.nov[diaCo].value;
        if(valor=="marcado"){
                eval(local+'.bgColor=\"#044666\"')
                eval(local+'.style.color=\"#FFFFFF\"');
        } else if(valor=="reg"){
                eval(local+'.bgColor=\"#099BE1\"')
                eval(local+'.style.color=\"#FFFFFF\"');
        } else {
                eval(local+'.bgColor=\"#DFF5FF\"')
                eval(local+'.style.color=\"#000000\"');
        }
}

function resize(foto){
	img = new Image();
	img.src = foto;
	fotocentro.height=img.height;
	fotocentro.width=img.width;
}
function mOver_fotos(td){
	eval("foto"+td+".style.cursor=\"hand\"");
}



function validate_cadastro(form){

	form.submit();
}
function verifica_novidades(frm){
	if (frm.cli_nome.value=="") {
		alert("Preencha seu nome.")
		frm.cli_nome.focus();
		return false
	}
	if (frm.cli_email.value=="") {
		alert("Preencha seu e-mail.")
		frm.cli_email.focus();
		return false
	} else {
		fieldName   = frm.cli_email;
		fieldValue  = fieldName.value;
		fieldLength = fieldValue.length;

		var err01   = "Preencha seu e-mail corretamente.";
	
		if ( fieldLength < 8 ) {
			alert( err01 );
			fieldName.focus();
					return false
		} else {
			if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test( fieldValue )) {
			} else {
				alert( err01 );
				fieldName.focus();
				return false
			}
		}
	}
	if (frm.cli_cidade.value=="") {
		alert("Preencha sua Cidade.")
		frm.cli_cidade.focus();
		return false
	}
	if (frm.cli_telefone.value=="") {
		alert("Preencha seu Telefone.")
		frm.cli_telefone.focus();
		return false
	}
	frm.submit();
}

function abreJanela(arquivo,id){
	window.open(arquivo+'?id='+id, null, 'help=no,status=no,scrollbars=yes,resizable=no,width=600,height=500,dependent=yes', false);
}
function verificadata(campo){
	if(document.periodo.pfim.value=="__/__/____" || document.periodo.pini.value=="__/__/____"){
		alert("O período deve ser preenchido corretamente.");		
	} else {
		if(document.periodo.pfim.value<document.periodo.pini.value)
			alert("A data final deve ser maior que a inicial.");
		else if(document.periodo.pini.value==document.periodo.pfim.value)
			alert("A data final deve ser diferente que a inicial.");
		else
			document.periodo.submit();
	}	
}

function mudafoto(td,pos){
	imagem(td);
	imagemAtual=pos;
}

function isFunction(a) {
    return typeof a == 'function';
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}

nn4=(document.layers)?1:0;
nn6=(document.getElementById&&!document.all)?1:0;
op5=(document.all&&!document.styleSheets)?1:0;
ie5=(document.getElementById&&!nn6&&!op5)?1:0;
ie4 = (document.all);
ns4 = (document.layers);
tempX=tempY=0;
IE = false;

function getObjNN4(obj,name){
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function getElementWidth(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.width;
	} else {
		if(isObject(Elem)){
			var elem= Elem;			
		} else {
			if(document.getElementById) {
				var elem = document.getElementById(Elem);
			} else if (document.all){
				var elem = document.all[Elem];
			}
		}
		if (op5) {
			xPos = elem.style.pixelWidth;
		} else {
			xPos = elem.offsetWidth;
		}
		return xPos;
	}
}

function imagem(f){
	foto=document.getElementById("fotocentro");
	rand=(Math.round((Math.random()*900)+(Math.random()*900)));
	html='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="300" id="zoom" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="swf/zoom.swf?imagem='+f+'&r='+rand+'" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="bgcolor" value="#2f434c" /><embed src="swf/zoom.swf?imagem='+f+'" quality="high" bgcolor="#2f434c" width="400" height="300" name="zoom" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	foto.innerHTML=html;
}

function buscaChange(local,texto,ajax){
	form=document.buscadet;
	nome=(isObject(local))? local.name : local;
	switch (nome){
		case "tipo":
			cp1=document.getElementById('bdFinalidade1');
			cp2=document.getElementById('bdFinalidade2');
			if(ajax==undefined){
				valor=form.tipo.options[form.tipo.selectedIndex].value;
				if(valor.length>1)
					valor=valor.substr(0,1);
					
				buscaLimpa(0);
				if(valor!=""){
					cp2.innerHTML="Carregando...";
					url="arquivos/buscaCombo.php?local=tipo&valor="+valor;
					ajaxRead(url,"buscaChange('"+nome+"',texto,true);");
				}
			} else {
				cp1.innerHTML="FINALIDADE";
				arr=eval(texto);
				html='<select name="finalidade" class="campoBusca" onChange="buscaChange(this);">';
				html+='<option value="">--Selecione--</option>';
				for(i=0;i<arr.length-1;i++)
					if(arr[i]!="")
						html+='<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
						
				html+='</select>';
				cp2.innerHTML=html;
			}
		break;
		case "finalidade":
			cp1=document.getElementById('bdCidade1');
			cp2=document.getElementById('bdCidade2');
			if(ajax==undefined){
				valor1=form.tipo.options[form.tipo.selectedIndex].value;
				valor=form.finalidade.options[form.finalidade.selectedIndex].value;
				buscaLimpa(1);
				if(valor!=""){
					cp2.innerHTML="Carregando...";
					url="arquivos/buscaCombo.php?local=finalidade&valor1="+valor1+"&valor="+valor;
					ajaxRead(url,"buscaChange('"+nome+"',texto,true);");
				}
			} else {
				cp1.innerHTML="CIDADE";
				arr=eval(texto);
				html='<select name="cidade" class="campoBusca" onChange="buscaChange(this);">';
				html+='<option value="">--Selecione--</option>';
				html+='<option value="todos">Todos</option>';
				for(i=0;i<arr.length-1;i++)
					if(arr[i]!="")
						html+='<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
						
				html+='</select>';
				cp2.innerHTML=html;
			}
		break;
		case "cidade":
			cp1=document.getElementById('bdBairro1');
			cp2=document.getElementById('bdBairro2');
			if(ajax==undefined){
				valor1=form.tipo.options[form.tipo.selectedIndex].value;
				valor2=form.finalidade.options[form.finalidade.selectedIndex].value;
				valor=form.cidade.options[form.cidade.selectedIndex].value;
				buscaLimpa(2);
				if(valor=="todos"){
					buscaChange("bairro");
				} else if(valor!=""){
					cp2.innerHTML="Carregando...";
					url="arquivos/buscaCombo.php?local=cidade&valor1="+valor1+"&valor2="+valor2+"&valor="+valor;
					ajaxRead(url,"buscaChange('"+nome+"',texto,true);");
				}
			} else {
				cp1.innerHTML="BAIRRO";
				arr=eval(texto);
				html='<select name="bairro" class="campoBusca" onChange="buscaChange(this);">';
				html+='<option value="">--Selecione--</option>';
				html+='<option value="todos">Todos</option>';
				for(i=0;i<arr.length-1;i++)
					if(arr[i]!="")
						html+='<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
						
				html+='</select>';
				cp2.innerHTML=html;
			}
		break;
		case "bairro":
			cp1=document.getElementById('bdLocalizacao1');
			cp2=document.getElementById('bdLocalizacao2');
			valor1=form.tipo.options[form.tipo.selectedIndex].value;
			if(ajax==undefined){
				valor2=form.finalidade.options[form.finalidade.selectedIndex].value;
				valor3=form.cidade.options[form.cidade.selectedIndex].value;
				valor="";
				if(form.bairro!=undefined){
					valor=form.bairro.options[form.bairro.selectedIndex].value;
					buscaLimpa(3);
				}
				cp2.innerHTML="Carregando...";
				url="arquivos/buscaCombo.php?local=bairro&valor1="+valor1+"&valor2="+valor2+"&valor3="+valor3+((valor!="")? "&valor="+valor : "");
				ajaxRead(url,"buscaChange('"+nome+"',texto,true);");
			} else {
				cp1.innerHTML="LOCALIZAÇÃO";
				arr=eval(texto);
				if(arr.length>1){
					html='<select name="localizacao" class="campoBusca" onChange="buscaChange(\''+((valor1!=3 && valor1!=4)? "dormitorios" : "valores")+'\');">';
					html+='<option value="">--Selecione--</option>';
					html+='<option value="todos">Todos</option>';
					for(i=0;i<arr.length-1;i++)
						if(arr[i]!="")
							html+='<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
							
					html+='</select>';
					cp2.innerHTML=html;
				} else {
					cp1.innerHTML=cp2.innerHTML="";
					buscaChange("dormitorios");
				}
			}
		break;
		case "localizacao":
			if(ajax==undefined){
				valor=form.localizacao.options[form.localizacao.selectedIndex].value;
//								buscaLimpa(4);
				if(valor!=""){
					buscaChange("dormitorios");
				}
			}
		break;
		case "dormitorios":
			cp1=document.getElementById('bdDormitorio1');
			cp2=document.getElementById('bdDormitorio2');
			if(ajax==undefined){
				valor1=form.tipo.options[form.tipo.selectedIndex].value;
				valor2=form.finalidade.options[form.finalidade.selectedIndex].value;
				valor3=form.cidade.options[form.cidade.selectedIndex].value;

				if(form.dormitorios!=undefined)
					valord=form.dormitorios.options[form.dormitorios.selectedIndex].value;
				else
					valord=false;	
					
				url="arquivos/buscaCombo.php?local=dormitorio&valor1="+valor1+"&valor2="+valor2+"&valor3="+valor3;
				if(form.bairro!=undefined){
					valor4=form.bairro.options[form.bairro.selectedIndex].value;
					if(valor4!="todos")
						url+="&valor4="+valor4;
				}
				if(form.localizacao!=undefined){
					valor5=form.localizacao.options[form.localizacao.selectedIndex].value;
					if(valor5!="todos")
						url+="&valor5="+valor5;
				}
				//alert(url);
				buscaLimpa(5,true);
				if(valor1=="1" || valor1=="2" || valor1=="5" || valor1=="1|5"){
					if(valord==false){
						cp2.innerHTML="Carregando...";
						ajaxRead(url,"buscaChange('"+nome+"',texto,true);");
					} else if(valord!="") {
						buscaButton();
						valord="";
						buscaChange("valores");
					}
				} else if(valord!=""){
					buscaButton();
					valord="";
					buscaChange("valores");
				}
			} else {
				cp1.innerHTML="DORMITÓRIOS";
				arr=eval(texto);
				html='<select name="dormitorios" class="campoBusca" onChange="buscaChange(this);">';
				html+='<option value="">--Selecione--</option>';
				html+='<option value="todos">Todos</option>';
				for(i=0;i<arr.length-1;i++)
					if(arr[i]!="")
						html+='<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
						
				html+='</select>';
				cp2.innerHTML=html;
			}
		break;
		case "valores":
			cp1=document.getElementById('bdValores1');
			cp2=document.getElementById('bdValores2');
			if(ajax==undefined){
				valor1=form.tipo.options[form.tipo.selectedIndex].value;
				valor2=form.finalidade.options[form.finalidade.selectedIndex].value;
				valor3=form.cidade.options[form.cidade.selectedIndex].value;
				url="arquivos/buscaCombo.php?local=valores&valor1="+valor1+"&valor2="+valor2+"&valor3="+valor3;
				if(form.bairro!=undefined){
					valor4=form.bairro.options[form.bairro.selectedIndex].value;
					if(valor4!="todos")
						url+="&valor4="+valor4;
				}
				if(form.localizacao!=undefined){
					valor5=form.localizacao.options[form.localizacao.selectedIndex].value;
					if(valor5!="todos")
						url+="&valor5="+valor5;
				}
				if(form.dormitorios!=undefined){
					valor6=form.dormitorios.options[form.dormitorios.selectedIndex].value;
					if(valor6!="todos")
						url+="&valor6="+valor6;
				}
				
//								alert(url);
				buscaLimpa(6,true);
				cp2.innerHTML="Carregando...";
				ajaxRead(url,"buscaChange('"+nome+"',texto,true);");
			} else {
				cp1.innerHTML="VALORES";
//								alert(texto);
				arr=eval(texto);
				html='<select name="valores" class="campoBusca" onChange="buscaChange(\'fim\');">';
				html+='<option value="">--Selecione--</option>';
				html+='<option value="todos">Todos</option>';
				for(i=0;i<arr.length-1;i++)
					if(arr[i]!="")
						html+='<option value="'+arr[i][0]+'">'+arr[i][1]+'</option>';
						
				html+='</select>';
				cp2.innerHTML=html;
			}
		break;
		case "fim":
			buscaButton();
		break;
	}	
}	
function buscaLimpa(local,fim){
	bodys=Array('bdFinalidade1','bdFinalidade2','bdCidade1','bdCidade2','bdBairro1','bdBairro2','bdLocalizacao1','bdLocalizacao2','bdDormitorio1','bdDormitorio2','bdValores1','bdValores2','bdButton');
	tam=bodys.length-((fim!=undefined && fim==true)? 1 : 0);
	for(i=local*2;i<tam;i++){
		cp=document.getElementById(bodys[i]);
		cp.innerHTML='';
	}
}	

function newsletter_form(texto,ajax){
	if(ajax==undefined){
		nome=document.newsletter.nome.value;
		email=document.newsletter.email.value;
		if(email!="" && nome!="")
			if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test( email )) {
				url="arquivos/newsletter.php?nome="+nome+"&email="+email;
				ajaxRead(url,"newsletter_form(texto,true);");
			} else {
				alert("Preencha corretamente o e-mail.");
				document.newsletter.email.focus();
			}
	} else {
		if(texto=="0"){
			alert("E-mail já cadastrado.");		
		} else {
			document.newsletter.reset();
			alert("E-mail cadastrado com sucesso. Obrigado.");
		}
	}
}

function imprimir(id){
	ajaxRead("arquivos/impresso.php?id="+id,"window.print();");
}


function janelaOnline2(t){
	window.open("arquivos/atendimento.php",null,"height=400,width=500,status=yes,toolbar=no,menubar=no,location=no");
}
