﻿function deletaFavorito(cookie) {

    //alert("VocÃª retirou o ImÃ³vel de CÃ³digo " + cookie + " do seu Favorito.");
    $.post("removeFavorito.aspx", { queryString: "" + cookie + "" });
}

function janelaSecundaria(cod) {
    window.open('http://www.netimoveis.com/login/index_detalhes.asp?codigo=' + cod, 'Netimoveis', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=110, LEFT=110, WIDTH=623, HEIGHT=500');
}


//alert(window.location.href);
if (window.location.host == 'www.redebrasilia.com.br') {
    window.location = "http://www.netimoveis.com/redebrasilia/";
}
if (window.location.host == 'www.netimoveis.com.br') {
    window.location = "http://www.netimoveis.com";
}
if (window.location.host == 'www.redenetimoveis.com') {
    location.href = "http://www.netimoveis.com";
}




$(function () {
    var rdn = Math.random(2);
    // CONFIG DA VITRINE
    estado = $.cookie("v_estado");
    if (estado == null) {
        estado = "14";
    }
    //estado = "8";
    //alert(estado);


    $('#vitrine_destaques').load('CarregaVitrine.aspx?vitrine=destaques&rand=' + rdn + "&estado=" + estado);
    resolucao = screen.width;

    $('#bt_destaques').click(function () {
        $('#vitrine_destaques').show();
        $('#vitrine_vistos').hide();
        $('#vitrine_lanc').hide();
        var rdn = Math.random(2);
        $('#vitrine_destaques').load('CarregaVitrine.aspx?vitrine=destaques&rand=' + rdn + "&estado=" + estado);

    });

    $('#bt_vistos').click(function () {
        $('#vitrine_vistos').show();
        $('#vitrine_destaques').hide();
        $('#vitrine_lanc').hide();
        var rdn = Math.random(2);
        $('#vitrine_vistos').load('CarregaVitrine.aspx?vitrine=vistos&rand=' + rdn + "&estado=" + estado);

    });

    $('#bt_lanc').click(function () {
        $('#vitrine_lanc').show();
        $('#vitrine_vistos').hide();
        $('#vitrine_destaques').hide();
        var rdn = Math.random(2);
        $('#vitrine_lanc').load('CarregaVitrine.aspx?vitrine=lancamentos&rand=' + rdn + "&estado=" + estado);

    });

    //AJUSTAR VITRINE AO TAMANHO DA TELA
    AjaxPause = 1;
    $(window).resize(function () {
        var rdn = Math.random(2);
        if (AjaxPause == 1) {
            if ($('#vitrine_destaques').is(':visible')) {
                var rdn = Math.random(2);
                $('#vitrine_destaques').load('CarregaVitrine.aspx?vitrine=destaques&rand=' + rdn + "&estado=" + estado);
                AjaxPause = 0;
                setTimeout("AjaxPause = 1", 500);
            }
            else if ($('#vitrine_vistos').is(':visible')) {
                var rdn = Math.random(2);
                $('#vitrine_vistos').load('CarregaVitrine.aspx?vitrine=vistos&rand=' + rdn + "&estado=" + estado);
                AjaxPause = 0;
                setTimeout("AjaxPause = 1", 500);
            }
            else if ($('#vitrine_lanc').is(':visible')) {
                var rdn = Math.random(2);
                $('#vitrine_lanc').load('CarregaVitrine.aspx?vitrine=lancamentos&rand=' + rdn + "&estado=" + estado);
                AjaxPause = 0;
                setTimeout("AjaxPause = 1", 500);
            }
        }
    });

    $('body').click(function () {
        timer = 0;
    });

    $('#fechar_postit').click(function () {
        $('#aba_ajuda').hide();
    });

    //verificatimer();
});

var timer = 0;
var aux_flag = 0;

function verificatimer() {
    timer++;

    if (timer == 10 && aux_flag == 0 && $.cookie('auxcookie') == null) {
        $('#aba_ajuda').slideDown();
        timer = 0;
        aux_flag = 1;
        $.cookie('auxcookie', '1');
    }

    setTimeout("verificatimer()", 1000);
}