﻿var fixar = 0;

function abreFav() {
    $.post("http://www.francopenteadoimoveis.com.br/Components/ficha/Ajax/processa.aspx", { action: 'buscaFav' }, function (retorno) {
        abrirLinkParametro('http://www.francopenteadoimoveis.com.br/Resultado.aspx?favoritos=1&referencia=' + retorno);
    });    
}




var mensagem="";
function clickIE() {if (document.all) {(mensagem);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(mensagem);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")


function o_89884() {
    var url = "http://www.linkws.com/chat/whois.jsp?userProductID=89884&origin=" + location.href + "&title=" + escape(document.title);
    var name = "chatWindow_89884";
    var width = 510;
    var height = 400;
    var top = (screen.height / 2) - (height / 2);
    var left = (screen.width / 2) - (width / 2);
    var params = "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + ",scrollbars=yes"; window.open(url, name, params);
}


function mudaCultura(cultura) {   
    var link = window.location.href;

    if (link.toLowerCase().indexOf("cultura=") != -1) {
        link = link.substring(0, link.toLowerCase().indexOf("cultura=") - 1) + link.substring(link.toLowerCase().indexOf("cultura=") + 13);
    }
    if (link.toLowerCase().indexOf("?") == -1)
        link = link + '?cultura=' + cultura;
    else
        link = link + '&cultura=' + cultura;

    window.open(link, '_self');
}


function abrirLink(url) {
    var link = window.location.href;

    if (link.toLowerCase().indexOf("cultura=") != -1) {
        window.open(url + '?' + link.substring(link.toLowerCase().indexOf("cultura="), (link.toLowerCase().indexOf("cultura=")) + 13), '_self');
    }
    else {
        window.open(url, '_self');
    }     
}

function abrirLinkParametro(url) {
    var link = window.location.href;
    if (link.toLowerCase().indexOf("cultura=") != -1) {
        window.open(url + '&' + link.substring(link.toLowerCase().indexOf("cultura="), (link.toLowerCase().indexOf("cultura=")) + 13), '_self');
    }
    else {
        window.open(url, '_self');
    }
}

$(document).ready(function () {

    $("#language1").click(function () {
        mudaCultura('en-US');
    });

    $("#language2").click(function () {
        mudaCultura('es-ES');
    });

    $("#language3").click(function () {
        mudaCultura('pt-BR');
    });

    $("#languageBandeira1").click(function () {
        mudaCultura('en-US');
    });

    $("#languageBandeira2").click(function () {
        mudaCultura('es-ES');
    });

    $("#languageBandeira3").click(function () {
        mudaCultura('pt-BR');
    });

    /*switch (busca.v_cultura) {
    case "en-US":
    var v_fixar = "Stay on the top";
    var v_flutuar = "Float";
    break;
    case "es-ES":
    var v_fixar = "Stay on the top";
    var v_flutuar = "Flotador";
    break;
    default:
    var v_fixar = "Fixar no topo";
    var v_flutuar = "Flutuar";
    break;
    }*/
    var v_fixar = "Fixar no topo";
    var v_flutuar = "Flutuar";

    $.post("http://www.francopenteadoimoveis.com.br/processa_atendimento.aspx", { action: "get" }, function (data) {
        if (data == "fixar") {
            $("#conteudoConsultorOnlineFixar").html(v_flutuar);
            fixar = 1;
        }
        else {
            $("#conteudoConsultorOnlineFixar").html(v_fixar);
            fixar = 0;
        }
    });

    $("#conteudoConsultorOnlineFixar").click(function () {
        if ($("#conteudoConsultorOnlineFixar").html() == v_fixar) {
            $("#conteudoConsultorOnlineFixar").html(v_flutuar);
            fixar = 1;
            $.post("http://www.francopenteadoimoveis.com.br/processa_atendimento.aspx", { action: "set", status: "fixar" }, function (data) { });
        }
        else {
            $("#conteudoConsultorOnlineFixar").html(v_fixar);
            fixar = 0;
            $.post("http://www.francopenteadoimoveis.com.br/processa_atendimento.aspx", { action: "set", status: "flutuar" }, function (data) { });
        }

        return false;
    });


    $("#conteudoConsultorOnlineFixarSeta1").click(function () {
        if ($("#conteudoConsultorOnlineFixar").html() == v_fixar) {
            $("#conteudoConsultorOnlineFixar").html(v_flutuar);
            fixar = 1;
        }
        else {
            $("#conteudoConsultorOnlineFixar").html(v_fixar);
            fixar = 0;
        }

        return false;
    });

    var y_fixo = $("#conteudoConsultorOnlineBg").offset().top;
    $(window).scroll(function () {
        $("#conteudoConsultorOnlineBg").animate({ top: $(document).scrollTop() + y_fixo + "px" }, { duration: 500, queue: false });
    });
});


function abrirAtendimento() {
    window.open('http://corretoronline.univenweb.com.br/atendimento.aspx?empresa=180&corretor=', 'popup', 'width=430 , height=420, top=300, left=200, scrollbars=no,fullscreen=no');
}

function verificarCamposContato() {
    var nome = $.trim($("#contato_nome").val());

    if (nome == "") {
        alert("Digite seu nome para poder enviar o contato.");
        $("#contato_nome").focus();
        return false;
    }
    else if ($.trim($("#contato_email").val()) == "") {
        alert(nome + ", digite seu e-mail para poder enviar o contato.");
        $("#contato_email").focus();
        return false;
    } else if ($.trim($("#contato_msg").val()) == "") {
        alert(nome + ", digite uma mensagem para poder enviar o contato.");
        $("#contato_msg").focus();
        return false;
    }
    
    return true;
}

function verificarCamposContato_enUS() {
    var nome = $.trim($("#contato_nome").val());

    if (nome == "") {
        alert("Enter your name to post contact.");
        $("#contato_nome").focus();
        return false;
    }
    else if ($.trim($("#contato_email").val()) == "") {
        alert(nome + ", enter your e-mail to post contact.");
        $("#contato_email").focus();
        return false;
    } else if ($.trim($("#contato_msg").val()) == "") {
        alert(nome + ", type a message to post contact.");
        $("#contato_msg").focus();
        return false;
    }

    return true;
}

function verificarCamposContato_esES() {
    var nome = $.trim($("#contato_nome").val());

    if (nome == "") {
        alert("Escriba su nombre para enviar contacto.");
        $("#contato_nome").focus();
        return false;
    }
    else if ($.trim($("#contato_email").val()) == "") {
        alert(nome + ", Ingrese su e-mail para enviar contacto.");
        $("#contato_email").focus();
        return false;
    } else if ($.trim($("#contato_msg").val()) == "") {
        alert(nome + ", escriba un mensaje a mensaje de contacto.");
        $("#contato_msg").focus();
        return false;
    }

    return true;
}

function abrirFichaLancamentos(id) {
    if ($.trim(id) == "")
        alert('Página do lançamento indisponível no momento.');
    else
        window.open(id, '_blank');
}


function verificaSejaNossoCorretor() {
    var nome = $.trim($("#txtNome").val());

    if (nome == "") {
        alert("Digite seu nome para poder enviar seu cadastro.");
        $("#txtNome").focus();
        return false;
    }
    else if ($.trim($("#txtEmail").val()) == "") {
        alert(nome + ", digite seu e-mail para poder enviar seu cadastro.");
        $("#txtEmail").focus();
        return false;
    }

    return true;
}

function verificaCadastreNews() {

    var categorias = "";
    $("#news_categoria option:selected").each(function () {
        if (categorias == "")
            categorias = $(this).text();
        else
            categorias += ", " + $(this).text();
    });

    var nome = $.trim($("#news_nome").val());

    if (nome == "") {
        alert("Digite seu nome para poder enviar a solicitação.");
        $("#news_nome").focus();
        return false;
    }
    else if ($.trim($("#news_email").val()) == "") {
        alert(nome + ", digite seu e-mail para poder enviar a solicitação.");
        $("#news_email").focus();
        return false;
    } else if ($.trim($("#news_cidade").val()) == "") {
        alert(nome + ", digite sua cidade para poder enviar a solicitaçao.");
        $("#news_cidade").focus();
        return false;
    }else if (categorias == "") {
        alert(nome + ", selecione pelo menos uma categoria para poder enviar a solicitaçao.");
        return false;
    }

    $("#news_categorias").val(categorias);


    return true;
}
