// ONLOAD
	// uso -> arOnload.push(findimg);
	var arOnload = new Array();
	var wol = window.onload;
	window.onload = function(){
		if (wol) wol.call();
		if (arOnload) {for (var i in arOnload) {arOnload[i].call();}}
		delete arOnload;
	}
	arOnload.push(findimg);

// HOVER DE IMAGENS
	var sufixoImgOver = '_ov';
	var classToOver = 'roll';
	var classDown = 'down';

	function roll(o,state){
		var i,isnode,src,ftype,newsrc,nownode;
		// loop através de todos os childNodes
		for (i=0;i<o.childNodes.length;i++){
			nownode = o.childNodes[i];
			// se o nó é um elemento
			// e é uma IMG, muda a variável e sai do loop
			if(nownode.nodeType==1 && /img/i.test(nownode.nodeName)){
				isnode = i;
				break;
			}
		}  // verifica o src e faz o roll-over
		if (o.locked){
			//o.locked from submenu.js
			return;
		}
		src = o.childNodes[isnode].src;
		ftype = src.substring(src.lastIndexOf('.'), src.length);
		if (state == 'over' && o.state != state) {
			//set over
			newsrc = src.replace(ftype, sufixoImgOver+ftype);
		} else if(o.state == 'over') {
			//set up
			newsrc = src.replace(sufixoImgOver,'');
		}
		if (newsrc) {
			o.state = state;
			o.childNodes[isnode].src=newsrc;
		}
	}
	function findimg(){
		var imgs,i;  // Faz um loop através de todas as imagens
		//verificando se alguma delas contém a classe da var 'classToOver'
		imgs=document.getElementsByTagName('img');
		for(i=0;i<imgs.length;i++){
			if(eval('/'+classDown+'/').test(imgs[i].className)) {
				roll(imgs[i].parentNode,'over');
			}
			if(eval('/'+classToOver+'/').test(imgs[i].className)) {
				// adiciona a função roll ao elemento-pai da imagem
				imgs[i].parentNode.onmouseover=function(){roll(this,'over'); };
				imgs[i].parentNode.onmouseout=function(){roll(this,'up');};
				imgs[i].parentNode.onfocus=function(){roll(this,'over');};
				imgs[i].parentNode.onblur=function(){roll(this,'up');};
			}
		}
	}
/*
DOWN
<script>
	var mnprodDown = id('id DOM da imagem');
	roll(mnprodDown.parentNode,'over');
	mnprodDown.parentNode.locked = true;
</script>
*/

//uso -> id("id_dom").value
	function id(idDesc){return document.getElementById(idDesc);}
	
	
// select order by	
	function addImovelLista(id){
		var obj = document.getElementById("cod"+id);
		if(obj.className == 'btFavoritos'){
			obj.className = 'btFavoritosHover';
			obj.innerHTML = "Im&oacute;vel Adicionado";
		}else{
			obj.className = 'btFavoritos';
			obj.innerHTML = "<span class='destaque'>+</span> Meus im&oacute;veis";
		}
		
	}	
	
function removeImovelLista(id){
		document.getElementById('cod'+id).parentNode.parentNode.style.display = "none";
		
	}		
	
//window.open

function windowPopup(cod,width,height){
	window.open('../imoveis/detalhe_imovel_popup.php','Janela','width='+width+',height='+width+',scrollbars=true,resizable=false')
	
	}
	
function wOpen(url,name,w,h){
	wn = window.open(url,name,'width='+w+',height='+h+',scrollbars=yes,status=yes,resizable=yes,top=10,left=10');
	wn.focus();
}

function verEdicaoSelecionada(edicao){
    wOpen("../revista/index.php?ed="+edicao,"revista",1035,710);
}

// trocar imagens
	var codAnterior;
	var CodImg;
	function loadPicture(codImovelDB){
		CodImg = codImovelDB;
		if(codImovelDB != codAnterior && codAnterior){	
			document.getElementById('Cod'+codAnterior).className = "";
			document.getElementById('img').src = "../../imagens/conteudo/zoom_foto"+codImovelDB+"_popup.jpg";
			document.getElementById('img').alt = "Imagem ampliada do Imóvel Cod. "+codImovelDB;
			
			document.getElementById('Cod'+codImovelDB).className = "aHover";
		}
		codAnterior = codImovelDB;
		document.getElementById('img').src = "../../imagens/conteudo/zoom_foto"+codImovelDB+"_popup.jpg";
		document.getElementById('img').alt = "Imagem ampliada do Imóvel Cod. "+codImovelDB;
		document.getElementById('Cod'+codImovelDB).className = "aHover";

	}
	
	
	//VALIDA QUANTIDADE DE CARACTERES DIGITADOS
	function countChars(num_chars, obj_mostrador, obj_texto, msg) {
		var campo = obj_texto.value;
		obj_mostrador.value=campo.length;
		if (campo.length>parseInt(num_chars)) {
			alert(msg+" "+num_chars+" caracteres.");
			obj_texto.value=campo.substring(0,parseInt(num_chars));
			obj_mostrador.value=num_chars;
			return false;
		}
		return true;
	}
	
	function TeclaInteiro(e){
		var key;
		var keychar;
		var reg;
		
		if(window.event) {
			// for IE, e.keyCode or window.event.keyCode can be used
			key = e.keyCode; 
		}
		else if(e.which) {
			// netscape or firefox
			key = e.which; 
		}
		else {
			// no event, so pass through
			return true;
		}
		if((key > 47 && key < 58) || (key == 8)) // numeros de 0 a 9 OU BACKSPACE
			return true;
		else {
			return false;
		}
	}

	function TeclaInteiroPonto(e){
		var key;
		var keychar;
		var reg;
		
		if(window.event) {
			// for IE, e.keyCode or window.event.keyCode can be used
			key = e.keyCode; 
		}
		else if(e.which) {
			// netscape or firefox
			key = e.which; 
		}
		else {
			// no event, so pass through
			return true;
		}
		if(key > 47 && key < 58) // numeros de 0 a 9
			return true;
		else {
			if ((key == 8) || ((key == 46))) // backspace
				return true;
			else 
				return false;
		}
	}


	function validaData(objeto) {
		
		var msg = "Digite uma data correta.";
		data = objeto.value;
		if (data == "") return true;
		if (data.length != 8 && data.length != 10) {
			alert(msg); 
			objeto.focus();
			return false;
		}
	
		dia = data.substring(0, 2);
		mes = data.substring(3, 5);
		
		if (data.length == 8)
			ano = data.substring(6, 8);
		else
			ano = data.substring(6, 10);
			
		objeto.value = dia + "/" + mes + "/" + ano;
		if ((retorno = isDate(objeto)) != false) {
			return true;
		} else {
			alert(msg);
			objeto.focus();
			return false;
	}	}
	//------------------------------------------------------------------------------------------------------------------------
	function tira_barra(obj) {
		data = obj.value;
		dia = data.substr(0, 2);
		mes = data.substr(3, 2);
		if (data.length == 10)
			ano = data.substr(6, 4);
		else
			ano = data.substr(6, 2);
		data = dia + mes + ano;
		obj.value=data;
	}
	//------------------------------------------------------------------------------------------------------------------------
	function isDate(objeto) {
	
	//	var ano = "<%'= year(date) %>";
	//	var hoje = "<%= year(date) & right("0"& month(date), 2) & right("0"& day(date), 2) %>";
		
		data = objeto.value;
		itens = data.split("/");
		if (itens[0] == "" || itens[1] == "" || itens[2] == "")
			return false;	
	
		if (isNaN(itens[0]) || isNaN(itens[1]) || isNaN(itens[2]))
			return false;
	
		/*if ((itens[2] + itens[1] + itens[0]) < strHoje)
			return "MENOR";//*/
	
		t0 = itens[0].length;	t1 = itens[1].length;	t2 = itens[2].length;
		if (t0 >= 3 || t1 >= 3 || t2 >= 5)
			return false;
	
		// valida se nunhum valor  menor que 0
		if (itens[0] <= 00 || itens[1] <= 00 || itens[2] <= 0000)
			return false;
	
		// valida o ano
		if (t2 <= 3) {
			if (itens[2] > 22)
				ano = "1900";
			else ano = "2000";
			aux = "";
			for (w = 0; w < 4 - t2; w++)
				aux += ano.charAt(w);
			y = 0;
			for (; w < 4; w++)
				aux += itens[2].charAt(y++);		
			itens[2] = aux;
		}
	
		// valida o mes
		if (itens[1] >= 13)
			return false;
	
		// captura o dia maximo para o mes digitado
		itens[1] = itens[1] * 1;
		if (itens[1] == 2) {
			if (itens[2]%400 == 0 || itens[2]%4 == 0 && itens[2]%100 != 0)
				vMax = 29;
			else	
				vMax = 28;
		} else
		if (itens[1] == 1 || itens[1] == 3 || itens[1] == 5 || itens[1] == 7 || itens[1] == 8 || itens[1] == 10 || itens[1] == 12)
			vMax = 31;
		else vMax = 30;
		itens[1] = "0"+ itens[1]; itens[1] = itens[1].charAt(itens[1].length - 2) + itens[1].charAt(itens[1].length - 1);
	
		// valida o dia do mes
		if (itens[0] > vMax)
			return false;
		itens[0] = "0"+ itens[0]; itens[0] = itens[0].charAt(itens[0].length - 2) + itens[0].charAt(itens[0].length - 1);
	
		objeto.value = itens[0] +"/"+ itens[1] +"/"+ itens[2];
		return true;
	}
	
	///**
// * Testa se a String pCpfCnpj fornecida  um CPF ou CNPJ vlido.
// * Se a String tiver uma quantidade de dgitos igual ou inferior
// * a 11, valida como CPF. Se for maior que 11, valida como CNPJ.
// * Qualquer formatao que no seja algarismos  desconsiderada.
// * @param String pCpfCnpj
// * 	String fornecida para ser testada.
// * @return <code>true</code> se a String fornecida for um CPF ou CNPJ vlido.
// */
//function isCpfCnpj(pCpfCnpj)
//{
//	var numero = pCpfCnpj.replace(/\D/g, "");
//	if (numero.length > NUM_DIGITOS_CPF)
//		return isCnpj(pCpfCnpj)
//	else
//		return isCpf(pCpfCnpj);
//} //isCpfCnpj

/**===========================FIM DAS FUNCOES DE VALIDACAO DE CPF E CNPJ===============================================================*/

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
  var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

  if(window.event) {
	// for IE, e.keyCode or window.event.keyCode can be used
	nTecla = evtKeyPress.keyCode; 
  }
  else if(evtKeyPress.which) {
	// netscape or firefox
	nTecla = evtKeyPress.which; 
  }
  else {
	// no event, so pass through
	return true;
  }

  /*if(document.all) { // Internet Explorer
	nTecla = evtKeyPress.keyCode;
	 }
  else if(document.layers) { // Nestcape
	nTecla = evtKeyPress.which;
  }*/
  
  sValue = objForm[strField].value;

  if (sMask == '(99) 999-9999') {
	 if (sValue.length > 12) {
		sMask = '(99) 9999-9999';
	 }
  }

  // Limpa todos os caracteres de formatao que
  // j estiverem no campo.
  sValue = sValue.toString().replace( "-", "" );
  sValue = sValue.toString().replace( "-", "" );
  sValue = sValue.toString().replace( ".", "" );
  sValue = sValue.toString().replace( ".", "" );
  sValue = sValue.toString().replace( "/", "" );
  sValue = sValue.toString().replace( "/", "" );
  sValue = sValue.toString().replace( "(", "" );
  sValue = sValue.toString().replace( "(", "" );
  sValue = sValue.toString().replace( ")", "" );
  sValue = sValue.toString().replace( ")", "" );
  sValue = sValue.toString().replace( " ", "" );
  sValue = sValue.toString().replace( " ", "" );
  fldLen = sValue.length;
  mskLen = sMask.length;
  
  i = 0;
  nCount = 0;
  sCod = "";
  mskLen = fldLen;

  while (i <= mskLen) {
	bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
	bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

	if (bolMask) {
	  sCod += sMask.charAt(i);
	  mskLen++; }
	else {
	  sCod += sValue.charAt(nCount);
	  nCount++;
	}

	i++;
  }
  
  objForm[strField].value = sCod;

  if (nTecla != 8) { // backspace
	if (sMask.charAt(i-1) == "9") { // apenas nmeros...
	  return ((nTecla > 47) && (nTecla < 58)); } // nmeros de 0 a 9
	else if (sMask.charAt(i-1) == "A") { // apenas caracteres literais (formata automaticamente para maiuscula)...
	  if(evtKeyPress.keyCode >= 97 && evtKeyPress.keyCode <= 122){ //a - z
		  evtKeyPress.keyCode = evtKeyPress.keyCode - 32;
	  }
	  return ((nTecla <= 47) || (nTecla >= 58)); } // qualquer caracter menos os nmeros de 0 a 9
	else if (sMask.charAt(i-1) == "a") { // apenas caracteres literais (formata automaticamente para minuscula)...
	  if(evtKeyPress.keyCode >= 65 && evtKeyPress.keyCode <= 90){ //a - z
		  evtKeyPress.keyCode = evtKeyPress.keyCode + 32;
	  }
	  return ((nTecla <= 47) || (nTecla >= 58)); } // qualquer caracter menos os nmeros de 0 a 9
	else if (sMask.charAt(i-1) == "*") { // apenas caracteres literais...
	  return ((nTecla <= 47) || (nTecla >= 58)); } // qualquer caracter menos os nmeros de 0 a 9
	else { // qualquer caracter...
	  return true;
	}
  }  else {
	return true;
  }
}


// JavaScript Document
var ajax_1 = null;
var ajax_2 = null;

function InicializaAjax(){
  //verifica se o browser tem suporte a ajax
   try {
		 ajax = new ActiveXObject("Microsoft.XMLHTTP");
	  } 
	  catch(e) {
		 try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		 }
		 catch(ex) {
			try {
			   ajax = new XMLHttpRequest();
			}
			catch(exc) {
			   alert("Esse browser não tem recursos para uso do Ajax");
			   ajax = null;
			}
		 }
	  }
  return ajax;
}
	
function abreAtendimento(corretorChamado){
	departmentId=corretorChamado.getAttribute("idImobiliaria");
	window.open('../../atendimento_online/live/main.php?departmentid='+departmentId+'&client=1', '', 'toolbar=no, status=no, scrollbars=yes, resizable=yes, location=no, menubar=no, directories=no, width=400, height=400');return false;
}
	
	
function verificaStatusCorretor() {
	  
  ajax_1 = InicializaAjax();
  
  //se tiver suporte ajax
  if(ajax_1) {
	 ajax_1.open("POST", "../_includes/icon_status.php", true);
	 ajax_1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 ajax_1.onreadystatechange = function() {
		//enquanto estiver processando...emite a msg de carregando
		if(ajax_1.readyState == 1) {
		   //idOpcaoBairro.innerHTML = "Carregando...";   
		}

		if(ajax_1.readyState == 4 ) {
			//alert(ajax.responseText);
		   if(ajax_1.responseText != "VAZIO" && ajax_1.responseText != "") {
			  var arrayRetorno = ajax_1.responseText.split("|");
			  var arrayItens;
			  var status = "";
			  var departmentId = "";
			  for(var i=0; i<arrayRetorno.length; i++){
				  //alert(arrayRetorno[i]);
				  arrayItens = arrayRetorno[i].split("#");  
				  departmentId = arrayItens[0];
				  status = arrayItens[1];
				  if(document.getElementById("btCorretor"+departmentId) != null){
					  if(status == "A"){
						document.getElementById("btCorretor"+departmentId).className = "btCorretorOnLine";
						document.getElementById("btCorretor"+departmentId).title = "On-line";
						document.getElementById("btCorretor"+departmentId).innerHTML = "Corretor <br>On-line";
						
						if(document.all){
							document.getElementById("btCorretor"+departmentId).onclick = function(){ abreAtendimento(this);return false;};
						}else{
							document.getElementById("btCorretor"+departmentId).setAttribute("onclick","javascript:window.open('../../atendimento_online/live/main.php?departmentid="+departmentId+"&client=1', '', 'toolbar=no, status=no, scrollbars=yes, resizable=yes, location=no, menubar=no, directories=no, width=400, height=400');return false;");
						}
					  }else{
						document.getElementById("btCorretor"+departmentId).className = "btCorretorOffLine";
						document.getElementById("btCorretor"+departmentId).title = "Off-line";
						document.getElementById("btCorretor"+departmentId).innerHTML = "Corretor <br>Off-line";
						document.getElementById("btCorretor"+departmentId).setAttribute("onclick","return false;");
					  }
					  //alert(status + " - " + departmentId);
				  }
			  }
			  setTimeout("verificaStatusCorretor()", 30000);
		   }else{
			   //caso não seja um arquivo XML emite a mensagem abaixo
			   //idOpcaoBairro.innerHTML = "";
		   }
		}
	 }
	 var params = "departmentids="+document.getElementById("departmentids").value;
	 //alert("params: "+params);
	 ajax_1.send(params);
  }
}

var tempo = null;
function verificaStatusDetalheCorretor() {
	  
  ajax_2 = InicializaAjax();
  
  //se tiver suporte ajax
  if(ajax_2) {
	 ajax_2.open("POST", "../_includes/icon_status.php", true);
	 ajax_2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 ajax_2.onreadystatechange = function() {
		//enquanto estiver processando...emite a msg de carregando
		if(ajax_2.readyState == 1) {
		   //idOpcaoBairro.innerHTML = "Carregando...";   
		}

		if(ajax_2.readyState == 4 ) {
			//alert(ajax.responseText);
		   if(ajax_2.responseText != "VAZIO" && ajax_2.responseText != "") {
			  var arrayItens;
			  var status = "";
			  var departmentId = "";
			  //alert(ajax_2.responseText);
			  arrayItens = ajax_2.responseText.split("#");  
			  departmentId = arrayItens[0];
			  status = arrayItens[1];
			  if(document.getElementById("btDetalheCorretor"+departmentId) != null){
				  if(status == "A"){
					document.getElementById("btDetalheCorretor"+departmentId).className = "btCorretorOnLine";
					document.getElementById("btDetalheCorretor"+departmentId).title = "On-line";
					document.getElementById("btDetalheCorretor"+departmentId).innerHTML = "Corretor <br>On-line";
					if(document.all){
						document.getElementById("btDetalheCorretor"+departmentId).onclick = function(){ window.open('../../atendimento_online/live/main.php?departmentid='+departmentId+'&client=1', '', 'toolbar=no, status=no, scrollbars=yes, resizable=yes, location=no, menubar=no, directories=no, width=400, height=400');return false;};
					}else{
						document.getElementById("btDetalheCorretor"+departmentId).setAttribute("onclick","javascript:window.open('../../atendimento_online/live/main.php?departmentid="+departmentId+"&client=1', '', 'toolbar=no, status=no, scrollbars=yes, resizable=yes, location=no, menubar=no, directories=no, width=400, height=400');return false;");
					}
				  }else{
					document.getElementById("btDetalheCorretor"+departmentId).className = "btCorretorOffLine";
					document.getElementById("btDetalheCorretor"+departmentId).title = "Off-line";
					document.getElementById("btDetalheCorretor"+departmentId).innerHTML = "Corretor <br>Off-line";
					document.getElementById("btDetalheCorretor"+departmentId).setAttribute("onclick","return false;");
				  }
			  }
			  tempo = setTimeout("verificaStatusDetalheCorretor()", 30000);
		   }else{
			   //caso não seja um arquivo XML emite a mensagem abaixo
			   //idOpcaoBairro.innerHTML = "";
		   }
		}
	 }
	 if(document.getElementById("detalhe_departmentid") == null){
		 clearTimeout(tempo);
		 return false;
	 }
	 var params = "departmentids="+document.getElementById("detalhe_departmentid").value;
	 //alert("params: "+params);
	 ajax_2.send(params);
  }
}

function mostra_imob(str_imovel, str_tipo) {
	if (str_tipo==2) {
		document.getElementById('im '+str_imovel).style.display = 'none';
	} else {
		document.getElementById('im '+str_imovel).style.display = '';
	}
}

var ajaxEnquete = null;
function carregaVotoEnquete(idEnquete){
	if(validaOpcao()){
		var objDivRetorno = document.getElementById("boxEnquete");
		ajaxEnquete = InicializaAjax();
		//se tiver suporte ajax
		if(ajaxEnquete) {
			var url="../_includes/inc_enquete.php";
			ajaxEnquete.open("POST", url, true);
			ajaxEnquete.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
			ajaxEnquete.onreadystatechange = function() {
				//enquanto estiver processando...emite a msg de carregando
				if(ajaxEnquete.readyState == 1) {
					objDivRetorno.innerHTML = "<img src='../../imagens/icones/ajax-loader.gif' />&nbsp;&nbsp;<h5>Carregando, por favor aguarde...</h5>";   
				}
				//após ser processado
				if(ajaxEnquete.readyState == 4 ) {
					if (ajaxEnquete.status == 200){
						if(objDivRetorno != null) objDivRetorno.innerHTML = ajaxEnquete.responseText;
					}else{
						if(objDivRetorno != null){
							objDivRetorno.innerHTML = "Ocorreu um erro ao carregar a notícia:<br>"+ajaxEnquete.statusText;
							objDivRetorno.innerHTML += "<br/>Por favor, tente novamente.";
						}
					}
				}
			}
			var opcao = "0";			
			var objForm = document.enquete;
			for(var i=0; i<objForm.elements.length; i++){
				if(objForm.elements[i].type != null && objForm.elements[i].type.toLowerCase() == "radio"){
					if(objForm.elements[i].checked){
						opcao = objForm.elements[i].value;
					}
				}
			}
			
			var params = "enq_id=" + idEnquete + "&opcao="+opcao+"&acao=VOTAR";
			ajaxEnquete.send(params);
		}
	}
}

// Array.indexOf( value, begin, strict ) - Return index of the first element that matches value
Array.prototype.indexOf = function( v, b, s ) {
	for( var i = +b || 0, l = this.length; i < l; i++ ) {
		if( this[i]===v || s && this[i]==v ) { return i; }
	}
	return -1;
};

/*
Função Ajax para carregar os conteudos dinamicos
*/
var ajaxConteudo = null;
function carregaConteudo(idContent,area,idImobiliaria,idBairro){
	var objDivRetorno = document.getElementById("contentMiolo");
	ajaxConteudo = InicializaAjax();
	//se tiver suporte ajax
	if(ajaxConteudo) {
		var url="";
		switch(area){
			case "tudo-sobre-imoveis":	url = "../home/conteudo.php"; 						break;
			case "sobre-rede": 			url = "../home/conteudo.php"; 						break;
			case "revista": 			url = "../sobre-rede/revista-rede.php"; 			break;
			case "imobiliarias": 		url = "../sobre-rede/imobiliarias-associadas.php"; 	break;
			case "imobiliaria-det": 	url = "../sobre-rede/imobiliaria.php"; 				break;
			case "bairros": 			url = "../joinville-regiao/bairros.php"; 			break;
			case "bairros-det": 		url = "../joinville-regiao/conteudo.php"; 			break;
			default: return false;
		}
		
		ajaxConteudo.open("POST", url, true);
		ajaxConteudo.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
		ajaxConteudo.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajaxConteudo.readyState == 1) {
				objDivRetorno.innerHTML = "<img src='../../imagens/icones/ajax-loader.gif' />&nbsp;&nbsp;<h5>Carregando, por favor aguarde...</h5>";   
			}
			//após ser processado
			if(ajaxConteudo.readyState == 4 ) {
				if (ajaxConteudo.status == 200){
					if(objDivRetorno != null){
						objDivRetorno.innerHTML = ajaxConteudo.responseText;
					}
					
					//chama funcao que verifica status online/offline do corretor
					if(idImobiliaria > 0) verificaStatusDetalheCorretor();
					
				}else{
					if(objDivRetorno != null){
						objDivRetorno.innerHTML = "Ocorreu um erro ao carregar o conteúdo:<br>"+ajaxConteudo.statusText;
						objDivRetorno.innerHTML += "<br/>Por favor, tente novamente.";
					}
				}
			}
		}
		
		var params = "content=" + idContent;
		params += "&imobiliaria=" + idImobiliaria;
		params += "&bairro=" + idBairro;
		params += "&area=" + area;
		ajaxConteudo.send(params);
	}
}


// retira caracteres invalidos da string de valor
function LimparValor(valor, validos) {
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;
}

//Formata número tipo moeda 
//Pode ser usado de dois modos:
//1 - Para formatar o valor de um campo deve-se usar o evento onKeyDown. Exemplo: onKeydown="FormataValor('',this,event,20)"
//2 - Para formatar o valor de uma variavel, deve-se usar a chamada FormataValor(variavel,'','',20);
function FormataValor(valorvariavel,valorcampo,teclapres,tammax) 
{
	
	// Verificação se valor por campo ou variavel.
	var tecla = teclapres.keyCode;
		
	if (!(tecla == 8 || (tecla >= 48 && tecla <= 57) || 
	(tecla >= 96 && tecla <= 105 || tecla == 188 || tecla == 9 || tecla == 190 || tecla == 194 || tecla == 110)))
		{
			//valorcampo.value = '';
			if (teclapres.preventDefault){
                teclapres.preventDefault(); 
                }
            else {
			teclapres.keyCode = 46;
		}
		}
	
	// Trava de tamanho, para não executar a rotina novamente.
	if (valorvariavel=='')
	{
		var trava = "";	
		trava = valorcampo.value;				
		if (trava.length >= tammax)
		{			
			return false;		
		}
	}
	
	
	// Rotina de verificação de Decimal para acrescentar 00. 
	if (valorvariavel!=''){		
		var Decimal = false;
		var ValorDecimal = valorvariavel;				
		for(i = 0; i < ValorDecimal.length; i++) {
			if (isNaN(ValorDecimal.substring(i, i+1))) {
				if (ValorDecimal.substring(i, i+1) == '.' || ValorDecimal.substring(i, i+1) == ',' ) 
				{					
					var Decimal = true;
				}
			}		
		}		
		if (!(Decimal))
		{		
		valorvariavel+='00'						
		}
	}	

	if (valorvariavel==''){
		vr = LimparValor(valorcampo.value,"0123456789");
		var retorno = valorcampo.value
		tam = vr.length;	
		if (tam < tammax && tecla != 8){tam = vr.length + 1 ;}
		if (tecla == 8){tam = tam - 1 ;}
	}
	else{
		vr = LimparValor(valorvariavel,"0123456789");
		var retorno = valorvariavel
		tam = vr.length;	
	}		

	// Rotina de Formatacao.
	if ( tam > (tammax-2) || valorvariavel != '' || tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){		
		if ( tam <= 2 ){retorno = vr;}		
		if ((tam >= 2) && (tam <= 5)){retorno = vr.substr(0, tam - 2) + ',' + vr.substr(tam - 2, tam );}
		if ((tam >= 6) && (tam <= 8)){retorno = vr.substr(0, tam - 5) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam) ;}
		if ((tam >= 9) && (tam <= 11)){retorno = vr.substr(0, tam - 8) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam ) ; }
		if ((tam >= 12) && (tam <= 14)){retorno = vr.substr(0, tam - 11) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3 ) + ',' + vr.substr(tam - 2, tam);}
		if ((tam >= 15) && (tam <= 17)){retorno = 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);}
	}

	
	// Retorno em campo ou variavel.
	if (valorvariavel==''){
		valorcampo.value = retorno;		
	}
	else{		
		return retorno;		
	}			
}