

function executaScripts(texto){
        var ini = 0;
        while (ini!=-1){
                ini = texto.indexOf('<script', ini);
                if (ini >=0){
                        ini = texto.indexOf('>', ini) + 1;
                        var fim = texto.indexOf('</script>', ini);
                        codigo = texto.substring(ini,fim);
                        novo = document.createElement("script");
						$("body").append("<div id='scriptsResponse'></div>")
						$("#scriptsResponse").html("<script>" + eval(codigo) + "</script>");
						$("#scriptsResponse").remove();						
						
                }
        }
}


function buscaDetalhada() {
	$("#buscaGeral").slideToggle();
}


function newsletter() {
    $.ajax({
    type: "POST",
    url: "includes/newsletter_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: "email=" + $("#newsletterEmail").val(),
    success:function(response){
	  executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
	  alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}






function contato() {
	$("#botaoEnviar").attr("disabled", "true");
	$("#botaoEnviar").val("Aguarde");
    $.ajax({
    type: "POST",
    url: "includes/contato_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formContato").serialize(),
    success:function(response){
	  $("#botaoEnviar").val("Enviar mensagem");
      $("#botaoEnviar").removeAttr("disabled");
	  executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
	  $("#botaoEnviar").val("Enviar mensagem");
	  $("#botaoEnviar").removeAttr("disabled");
	  alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}

function cadastro() {
	$("#botaoEnviar").attr("disabled", "true");
	$("#botaoEnviar").val("Aguarde");
    $.ajax({
    type: "POST",
    url: "includes/cadastro_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formCadastro").serialize(),
    success:function(response){
	  $("#botaoEnviar").val("Enviar interesse");
      $("#botaoEnviar").removeAttr("disabled");
	  executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
	  $("#botaoEnviar").val("Enviar interesse");
	  $("#botaoEnviar").removeAttr("disabled");
	  alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}


function corretor() {
	$("#botaoEnviar").attr("disabled", "true");
	$("#botaoEnviar").val("Aguarde");
    $.ajax({
    type: "POST",
    url: "includes/corretor_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formCorretor").serialize(),
    success:function(response){
	  $("#botaoEnviar").val("Enviar mensagem");
      $("#botaoEnviar").removeAttr("disabled");
	  executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
	  $("#botaoEnviar").val("Enviar mensagem");
	  $("#botaoEnviar").removeAttr("disabled");
	  alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}


function indicar() {
	$("#botaoEnviar").attr("disabled", "true");
	$("#botaoEnviar").val("Aguarde");
    $.ajax({
    type: "POST",
    url: "includes/indicar_exe.asp",
    dataType: "html",
    timeout: 60000,
    data: $("#formIndicar").serialize(),
    success:function(response){
	  $("#botaoEnviar").val("Enviar indicação");
      $("#botaoEnviar").removeAttr("disabled");
	  executaScripts(response);
    },
    error: function( objAJAXRequest, strError ){
	  $("#botaoEnviar").val("Enviar indicação");
	  $("#botaoEnviar").removeAttr("disabled");
	  alert("Erro: " + objAJAXRequest.status);
    }
    });
  return false;
}

function chaveOn1() {
	if ($("#chave1").val() == "Apartamento") {
		$("#chave1").val("");
		$("#chave1").focus();
	}
}
function chaveOff1() {
	if ($("#chave1").val() == "") {
		$("#chave1").val("Apartamento");
	}
}
function chaveOn2() {
	if ($("#chave2").val() == "Brusque") {
		$("#chave2").val("");
		$("#chave2").focus();
	}
}
function chaveOff2() {
	if ($("#chave2").val() == "") {
		$("#chave2").val("Brusque");
	}
}


function cliqueMouse() {
if (event.button==2||event.button==3) {
return false;
}
}
document.onmousedown=cliqueMouse
document.onkeydown=teclaCtrl
document.oncontextmenu = new Function("return false;")

	
function teclaCtrl()
{
              var ctrl=window.event.ctrlKey;
              var tecla=window.event.keyCode;
              if (ctrl && tecla==67) {event.keyCode=0; event.returnValue=false;}

}


