//----------------------------------------------------------------------------	
function levanolink(linkdetalhes)
{
	document.location.href = linkdetalhes;
}
//  window.onload = function()
function refazerTexto(id)
{
		if (window.attachEvent == undefined)
		{
				//var tag = document.getElementsByTagName("span");
				var tag = document.getElementById(id);
				for (var i = 0; i < tag.length; i++)
				{
						if (tag.item(i).className == "wdp")
						{
								var text = tag.item(i).innerHTML;
								tag.item(i).innerHTML = text.replace(/(.*?)/g, "<br />");
						}
				}
		}
}

//------------------------------------ betaurus ---
function apresentarDiv(id_div, campoTexto)
{
//	document.getElementById(id_div).style.display = "inline";// Adiciona o DIV +	
	var campoDeTexto = document.getElementById(campoTexto);
	if (campoDeTexto.value == "")
	{
		document.getElementById(id_div).style.display = "none"; // continua com o DIV apagado
		alert("campo vazio não permitido!"); // verifica se o campo esta vazio ou não.
		campoDeTexto.focus();
		return false;
	}
	else
	{
    var nonNumbers = /\D/; // aqui verifica se o campo é numerico ou não.
			if  ( campoDeTexto.value.length > 0  )
			{
					if  ( nonNumbers.test( campoDeTexto.value )  )
					{
							document.getElementById(id_div).style.display = "none"; // ainda não mostra o DIV
							alert("Somente números são permitidos");
							campoDeTexto.focus();
							return false;
					}
					else
					{
							document.getElementById(id_div).style.display = ''; // agora sim mostra o DIV
							document.getElementById("divMostraBusca").style.display = "none"; // Escondo o DIV de busca
							AjaxLink(id_div,'buscaCodigo.asp?codImovel=' + document.getElementById(campoTexto).value + '');
							return false;
					}
			}
	}
//------------------------------------ betaurus ---
}
function zerarDiv(id_div)
{
	document.getElementById(id_div).style.display = "none";// Remover o DIV +	
}
//----------------------------------------------------------------------------	
function fecharGuia(identificador, identificador2, fecharX, clicks)
{
		switch(clicks)
		{
		case 1:
				document.getElementById(identificador).style.display = "none"; // retira o DIV
				document.getElementById(identificador2).style.display = "inline";// Adiciona o DIV +
				document.getElementById(fecharX).style.display = "none"; // retira o DIV
				break;
		case 2:
				document.getElementById(identificador).style.display = "inline";// Adiciona o DIV +
				document.getElementById(identificador2).style.display = "none"; // retira o DIV
				document.getElementById(fecharX).style.display = "inline"; // retira o DIV				
				break;
		}
	}
//------- // script para mostrar ou não a busca --------------------------------
	function buscaRapidaAparece()
		{
			if(document.getElementById("buscarapida").className == "dov2")
			{
				document.getElementById("buscarapida").className = "dov1";
			}
			else
			{
				document.getElementById("buscarapida").className = "dov2";
			}
		}
//-------------------------------------------------------------------------------
function adicionaDiv()
{// adiciona o DIV de mostrar buscas novamente depois de ter removido ela
	document.getElementById("divMostraBusca").style.display = "";
	document.getElementById("mostraItens").style.display = "";
	document.getElementById("respostax").style.display = "";
}
//-------------------------------------------------------------------------------
function removeEstrela()
{
	document.getElementById("estrela").style.display = "none";
	document.getElementById("estrelaLink").style.display = "none";
	document.getElementById("mostraEstrela").style.display = "";
}
//- para verificar o campo vazio.
/*function verificarCampo(campotxt)
{
	var campoDeTexto = document.getElementById(campotxt);
	if (campoDeTexto.value == "")
	{
		alert("campo vazio nao permitido!");
		campoDeTexto.focus();
		return false;
	}
	else
	{
    var nonNumbers = /\D/;
			if  ( campoDeTexto.value.length > 0  ) 
			{
					if  ( nonNumbers.test( campoDeTexto.value )  )  
					{
							alert("O valor precisa ser numérico!");
							return false;
					}
			}
		}
} */
//-------------------------------------------------------------------------------
//verificando somente número.
function v_NR(tecla)
{
		if(typeof(tecla) == 'undefined')
		var tecla = window.event;
		var codigo = (tecla.which ? tecla.which : tecla.keyCode ? tecla.keyCode : tecla.charCode);
		// permite números, 8=backspace, 46=del e 9=tab
			if ( (codigo >= 48 && codigo <= 57) || (codigo >= 96 && codigo <= 105) || codigo == 8 || codigo == 46 || codigo == 9 || codigo == 13)
			{
				return true;
			}
				else
			{
				alert("Apenas números são permitidos !");
				document.getElementById("txtCod").value = "";
				document.getElementById("txtCod").focus();
				return false;
			}
}
//-------------------------------------------------------------------------------
function verificauf(iten) // função para verificar se o campo estado foi selecionado.
{
	if(document.getElementById(iten).value == null || document.getElementById(iten).value == 0)
	{
		alert("Escolha pelo menos um estado!");
		return false;
	}
	else
	{
		abrirdiv();
		return true;
	}
}
//-------------------------------------------------------------------------------
function retiraDiv(nm)
{// remove a DIV que foi relacionada no comando 'onclick'
	document.getElementById(nm).style.display = 'none';
}
//-------------------------------------------------------------------------------
function retiraDivdivMostraBusca()
{
// remove a DIV da Busca, rápida caso não queire mais ve-la.
	document.getElementById("divMostraBusca").style.display = "none";
}
//----------- função para abrir o prontos para morar com ajax
function retiraDivdItens()
{
	document.getElementById("resultadoquasetudao").style.display = "none";
}
//------------ abrir janelas.
//function abrirJanelaM(pagina, largura, altura, janelaS){ // abrir a janela no meio da tela..
    // Definindo meio da tela
//    	var esquerda = 100;	//(screen.width - largura)/2;
//    	var topo = 100;	//(screen.height - altura)/2;
//    	window.open(pagina,'','height=' + altura + ', width=' + largura + ', top=' + topo + ', left=' + esquerda);
	//(largura-(20))
	//(altura-(100))
//}
function abrirJanelaMSN(pagina, largura, altura){ // abrir a janela no meio da tela..
    // Definindo meio da tela		
    	window.open(pagina,'','height=' + (altura) + ',width=' + (largura) + ',top=' + 100 + ',left=' + 100 +',scrollbars=1');
}
//--
function abrirJanelaM(pagina, largura, altura){ // abrir a janela no meio da tela..
    // Definindo meio da tela
    	var esquerda = (screen.width - largura)/2;
    	var topo = (screen.height - altura)/2;		
    	window.open(pagina,'','height=' + (altura-(100)) + ',width=' + (largura-(20)) + ',top=' + topo + ',left=' + esquerda +',scrollbars=1');
}
// somente numeros
function somente_numero(campo){
    var digits="0123456789"
    var campo_temp
    for (var i=0;i<campo.value.length;i++){
      campo_temp=campo.value.substring(i,i+1)    
      if (digits.indexOf(campo_temp)==-1){
            campo.value = campo.value.substring(0,i);
            break;
       }
    }
}
//-- checar campos do agendamento visitas
function check(obj){
		var nao = "Campo vazio, favor preencha!"; 
		var escolhaSel = "Escolha um campo";
	with(obj){
	
		if(nome.value==""){
			window.alert(nao);
			nome.focus();
			return false;
		}
		 
		if(assunto.value==""){
			window.alert(nao);
			assunto.focus();
			return false;
		}
		
		if(endereco.value==""){
			window.alert(nao);
			endereco.focus();
			return false;
		}
		
		if(textarea.value==""){
			window.alert(nao);
			textarea.focus();
			return false;
		}
		
		if(estado.value==""){
			window.alert(escolhaSel);
			estado.focus();
			return false;
		}
		
		if(cidade.value==""){
			window.alert(escolhaSel);
			cidade.focus();
			return false;
		}
	}
}



