function validaBusca(){
	if (document.getElementById("id_cat").value == "0"){
		alert('Selecione um Tipo de Imóvel!');
		return false;
	}	
	else{
		return true
	}
}
function fale(){
	location.href="javascript:void(window.open('http://www.homecenterimoveis.com.br/chat/livezilla.php','','width=600,height=600,left=0,top=0,resizable=yes,menubar=no,location=yes,status=yes,scrollbars=yes'))";	
}
function valida(){
	if (document.getElementById("nome").value == ""){
		alert('Preencha o campo nome !');
		document.getElementById("nome").focus();
		return false;
	}
	else if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert('O e-mail que você digitou é inválido!!');
		document.getElementById("email").value="";
		document.getElementById("email").value.focus();
		return false;
	}
	else if (document.getElementById("email").value == ""){		
		alert('Preencha o campo E-mail !');
		document.getElementById("email").focus();
		return false;	
	}
	else {
		return true;
	}
	
}
function chama_infs(){
	//var agenda = document.getElementById('sltAgenda').value;
	new Ajax.Updater('ajax_imoveis', 'ajax_infs.asp');
	//alert('ok');
}
function escreve_topo(){
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="960" height="319">');
    document.write('<param name="movie" value="swf/topo.swf" />');
    document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
    document.write('<embed wmode="transparent" src="swf/topo.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="960" height="319"></embed>');
  document.write('</object>');
}

//Formata número tipo moeda usando o evento onKeyDown
function Limpar(valor, validos) {
// retira caracteres invalidos da string
var result = "";
var aux;
for (var i=0; i < valor.length; i++) {
aux = validos.indexOf(valor.substring(i, i+1));
if (aux>=0) {
result += aux;
}
}
return result;
}

function Formata(campo,tammax,teclapres,decimal) {
var tecla = teclapres.keyCode;
vr = Limpar(campo.value,"0123456789");
tam = vr.length;
dec=decimal

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 <= dec )
{ campo.value = vr ; }

if ( (tam > dec) && (tam <= 5) ){
campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 6) && (tam <= 8) ){
campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
}
if ( (tam >= 9) && (tam <= 11) ){
campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 12) && (tam <= 14) ){
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 - dec, tam ) ; }
if ( (tam >= 15) && (tam <= 17) ){
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 ) ;}
} 

}
function escreve_flash(nome,width,height){
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" style="width: ' + width + 'px; height: ' + height + 'px;">');
   document.write('<param name="movie" value="../swf/' + nome + '" />');
   document.write('<param name="quality" value="high" />');
   document.write('<param name="wmode" value="transparent" />');
   document.write('<param name="allowScriptAccess" value="always" />');
   document.write('<embed allowScriptAccess="always" wmode="transparent" src="../swf/' + nome + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" style="width: ' + width + 'px; height: ' + height + 'px;" /></embed>');
   document.write('</object>');
}
