<!--
var linkBusca = '../Framework/Classes/Others/Ajax.php';
var codempresa = 'C00108';

function mostraItens(codsistema) 
{
	new Ajax.Request(linkBusca, getOpt('tiposimovel', codsistema, 'tipoimovel', "codtipoimovel", "descrtipoimo"));
	new Ajax.Request(linkBusca, getOpt('cidades', codsistema, 'cidade', "codcidade", "nomecidade"));
	new Ajax.Request(linkBusca, getOpt('bairros', codsistema, 'bairro', "codbairro", "nomebairro"));

	document.form_pesquisa.dormitorios.selectedIndex = 0;
	document.form_pesquisa.codimovel.value = "CODIGO";
	
	if (codsistema == "A")
		$('sistema').value = "adm";
	else if (codsistema == "V")
		$('sistema').value = "cpv";
} 

function getOpt(nomeCampo, codsistema, acao, campocodigo, campovalor)
{
	$(nomeCampo).length = 1;
	$(nomeCampo).options[1] = new Option ("Aguarde... Carregando...");
	
	var opt = {	
		// Use POST
		method: 'get',
		// Send this lovely data
		parameters: "codempresa="+codempresa+"&codsistema="+codsistema+"&acao="+acao,
		// Handle successful response
		onSuccess: function(t) {
			results = t.responseXML;
			$(nomeCampo).length = 1;

			var root  = results.getElementsByTagName('DataGrid')[0];
			var items = root.getElementsByTagName("Row");

			for (var i = 0 ; i < items.length ; i++)
			{
				// get one item after another
				var item = items[i];
				// now we have the item object, time to get the contents
				// get the name of the item
				var codigo = item.getElementsByTagName(campocodigo)[0].firstChild.nodeValue;
				// get the quantity
				var valor = item.getElementsByTagName(campovalor)[0].firstChild.nodeValue;

				$(nomeCampo).options[i+1] = new Option( valor, codigo, false, false );
			}
		},
		// Handle 404
		on404: function(t) {
			alert('Erro 404: local "' + t.statusText + '" não foi encontrado.');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Erro ' + t.status + ' -- ' + t.statusText);
		}
	}
	
	return opt;
}




function enviaForm()
{
	if(document.form_pesquisa.codimovel.value == "CODIGO")
		document.form_pesquisa.codimovel.value = "";
	if(document.form_pesquisa.precominimo.value == "Preço Mínimo")
		document.form_pesquisa.precominimo.value = "";
	if(document.form_pesquisa.precomaximo.value == "Preço Máximo")
		document.form_pesquisa.precomaximo.value = "";

	document.form_pesquisa.submit();
}

function voltaValoresPadroes()
{
	if(document.form_pesquisa.codimovel.value == "")
		document.form_pesquisa.codimovel.value = "CODIGO";
	if(document.form_pesquisa.precominimo.value == "")
		document.form_pesquisa.precominimo.value = "Preço Mínimo";
	if(document.form_pesquisa.precomaximo.value == "")
		document.form_pesquisa.precomaximo.value = "Preço Máximo";
}

function limparCampo(campo, valorPadrao)
{
	if(campo.value == valorPadrao)
		campo.value = "";
}

function voltarPadrao(campo, valorPadrao)
{
	if(campo.value == "")
		campo.value = valorPadrao;
}

function validaFormAvalie(f)
{
	if(f.valorImovel.value == "")
	{
		alert('Por favor, digite o valor do Imóvel!');
		f.valorImovel.focus();
		return false;
	}
	else if (f.enderecoImovel.value == "")
	{
		alert('Por favor, digite o endereço do Imóvel!');
		f.enderecoImovel.focus();
		return false;
	}
	else if (f.bairroImovel.value == "")
	{
		alert('Por favor, digite o bairro do Imóvel!');
		f.bairroImovel.focus();
		return false;
	}
	else if (f.cidadeImovel.value == "")
	{
		alert('Por favor, digite a cidade do Imóvel!');
		f.cidadeImovel.focus();
		return false;
	}
	else if (f.estadoImovel.value == "")
	{
		alert('Por favor, digite o estado do Imóvel!');
		f.estadoImovel.focus();
		return false;
	}
	else if (f.nome.value == "")
	{
		alert('Por favor, digite o seu nome!');
		f.nome.focus();
		return false;
	}
	else if (f.email.value == "")
	{
		alert('Por favor, digite o seu email!');
		f.email.focus();
		return false;
	}
	else if (f.enderecoCliente.value == "")
	{
		alert('Por favor, digite o seu endereço!');
		f.enderecoCliente.focus();
		return false;
	}
	else if (f.cidadeCliente.value == "")
	{
		alert('Por favor, digite a sua cidade!');
		f.cidadeCliente.focus();
		return false;
	}
	else if (f.estadoCliente.value == "")
	{
		alert('Por favor, digite o seu estado!');
		f.estadoCliente.focus();
		return false;
	}
	else if (f.cepCliente1.value == "" || f.cepCliente2.value == "")
	{
		alert('Por favor, digite o seu CEP!');
		f.cepCliente1.focus();
		return false;
	}
	else if (f.telefoneCliente.value == "")
	{
		alert('Por favor, digite o seu telefone!');
		f.telefoneCliente.focus();
		return false;
	}
	
	else
		return true;
}
function validaFormMaisInfoDetalhe(f)
{
	if(f.nome.value=="")
	{
		alert("Por favor, digite seu nome!");
		f.nome.focus();
		return false;
	}
	else if(f.email.value =="")
	{
		alert("Por favor, digite seu email!");
		f.email.focus();
		return false;
	}
	else if(f.telefone.value =="")
	{
		alert("Por favor, digite seu telefone!");
		f.telefone.focus();
		return false;
	}
	else
		return true;
}

function validaFormFaleConosco(f)
{
	if(f.nome.value == "")
	{
		alert('Por favor, digite seu nome!');
		f.nome.focus();
		return false;
	}
	else if(f.email.value == "")
	{
		alert('Por favor, digite seu e-mail!');
		f.email.focus();
		return false;
	}
	else if(f.telefone.value == "")
	{
		alert('Por favor, digite seu telefone!');
		f.telefone.focus();
		return false;
	}
	else
		return true;
}



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; 
} 

//Formata número tipo moeda usando o evento onKeyDown 

function formataNumeros(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 apenasNumericos(caracter,valor)
{
	if(document.all)
	{ // Internet Explorer
		var tecla = event.keyCode;
	}
	else
	{
		if(document.layers)
		{ // Nestcape
			var tecla = caracter.which;
		}
	}
	if (tecla == 46 && valor.indexOf(".") > -1)
	{
		return false;
	}
	if(tecla > 47 && tecla < 58)
	{ // numeros de 0 a 9
		return true;
	}
	else
	{
		if (tecla != 8 || tecla != 46)
		{ // backspace
			return false;
		}
		else
		{
			return true;
		}
	}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

-->