﻿
function boxSistema_Click() {
    if ($("#boxLogin").css("top") == "0px") {
        $("#boxLogin").animate({ top: -74 }, "slow");
        $("#boxLoginConteudo").animate({ top: -74 }, "slow");
    } else {
        $("#boxLogin").animate({ top: 0 }, "slow");
        $("#boxLoginConteudo").animate({ top: 0 }, "slow");
    }
}

function boxClick(boxImg, checkBox) {
    $(boxImg).toggleClass('boxSelecionado');
    document.getElementById(checkBox).checked = !document.getElementById(checkBox).checked;
    //$(checkBox).attr('checked', !$(checkBox).attr('checked'));
}
var carregando;
var sistemaExterno = 'doc';
var segundoExterno = 0;

function firstTimeLoading(sistema) {
    sistemaExterno = sistema;
    segundoExterno = 0;
}




function pararLoading(){
    if (typeof (carregando) != 'undefined') {
        clearTimeout(carregando);
    }
}

function continuarLoading() {
    if (typeof (carregando) != 'undefined') {
        clearTimeout(carregando);
    }
   carregarProximoBanner(segundoExterno,sistemaExterno);
}

function selecionar(sistema) {
    var objDoc = $('#btnDoc');
    var objFlag = $('#btnFlag');
    var objBuy = $('#btnBuy');

    $("#btnDoc").css('background-position', 0);
    $("#btnFlag").css('background-position', 0);
    $("#btnBuy").css('background-position', 0);

    if (typeof (carregando) != 'undefined') {
        clearTimeout(carregando);
    }

    switch (sistema) {
        case 'doc':
            $('#banner_mask').scrollTo($('#banner_doc'), 2000, { easing: 'swing', queue: false, axis: 'xy' });
            $("#btnDoc").css('background-position', "-22px -0px");
            break;
        case 'flag':
            $('#banner_mask').scrollTo($('#banner_flag'), 2000, { easing: 'swing', queue: false, axis: 'xy' });
            $("#btnFlag").css('background-position', "-22px -25px");
        break;
        case 'buy':
            $('#banner_mask').scrollTo($('#banner_buy'), 2000, { easing: 'swing', queue: false, axis: 'xy' });
            $("#btnBuy").css('background-position', "-22px -50px");
        break;
    }
    carregarProximoBanner(0,sistema);
}

function carregarProximoBanner(segundo,sistema) {
    if (segundo < 9) {
        sistemaExterno = sistema;
        segundoExterno = segundo;

        carregando = window.setTimeout('carregarProximoBanner(' + (segundo + 1) + ',"' + sistema + '")', 700);

        switch (sistema) {
            case 'doc':
                $("#btnDoc").css('background-position', ""+(-segundo * 22)+"px -0px");
                break;
            case 'flag':
                $("#btnFlag").css('background-position', "" + (-segundo * 22) + "px -25px");
                break;
            case 'buy':
                $("#btnBuy").css('background-position', "" + (-segundo * 22) + "px -50px");
                break;
        }

    } else {
        switch(sistema){
            case 'doc':
                selecionar("flag");
            break;
            case 'flag':
                selecionar("buy");
            break;
            case 'buy':
                selecionar("doc");
            break;
        }
    }
    
}


function ocultarPanel(panelId) {
    $("#" + panelId).fadeOut("normal", function () {
        $("#boxTransparent_" + panelId).slideUp("normal", function () {
        });
    });
}

function slideToTop() {
    $.scrollTo('#topo', 800, { easing: 'swing' });
}

function verificaLoginEmBranco(email, senha) {

    email = document.getElementById(email);
    senha = document.getElementById(senha);

    $("#inputLoginErroNome").removeClass("inputLoginHover");
    $("#inputLoginErroSenha").removeClass("inputLoginHover");

    if (email.value.length <= 0) {
        $("#inputLoginErroNome").toggleClass("inputLoginHover");
        return false;
    } else if (senha.value.length <= 0) {
        $("#inputLoginErroSenha").toggleClass("inputLoginHover");
        return false;
    }
    return true;
}

function changeCheck(checkID,checkbox) {
    var objeto = document.getElementById(checkID);
    var objCheckBox = document.getElementById(checkbox);
    if (objeto.className == "unchecked") {
        objCheckBox.value = 1;
        objeto.className = "checked";
    } else {
        objCheckBox.value = 0;
        objeto.className = "unchecked";
    }
}

function carregaFlipImagens() {
    jQuery('#flip').jcoverflip({
        current: 2,
        beforeCss: function (el, container, offset) {
            el.children().removeClass("lightBox");

            switch (offset) {
                case 0:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) - 250 + 'px', bottom: '20px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '180px' }, {})
                            ];
                    break;
                case 1:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) - 800 + 'px', bottom: '40px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '120px' }, {})
                            ];
                    break;
                case 2:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) - 800 + 'px', bottom: '60px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '60px' }, {})
                            ];
                    break;
                case 3:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) - 800 + 'px', bottom: '80px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '0px' }, {})
                            ];
                    break;
                case 4:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) - 1000 + 'px', bottom: '100px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: tamanhoInicial + 'px' }, {})
                            ];
                    break;
                default:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) - 200 + 'px', bottom: '100px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: tamanhoInicial + 'px' }, {})
                            ];
                    break;
            }



        },
        afterCss: function (el, container, offset) {
            el.children().removeClass("lightBox");

            switch (offset) {
                case 0:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 370 + 'px', bottom: '20px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '180px' }, {})
                            ];
                    break;
                case 1:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 800 + 'px', bottom: '40px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '120 px' }, {})
                            ];
                    break;
                case 2:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 946 + 'px', bottom: '60px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '120 px' }, {})
                            ];
                    break;
                case 3:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 946 + 'px', bottom: '80px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '120 px' }, {})
                            ];
                    break;
                case 4:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 946 + 'px', bottom: '100px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: '120 px' }, {})
                            ];
                    break;
                default:
                    return [
                                $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 946 + 'px', bottom: '120px' }, {}),
                                $.jcoverflip.animationElement(el.find('img'), { width: tamanhoInicial + 'px' }, {})
                            ];
                    break;
            }
        },
        currentCss: function (el, container) {

            el.children().addClass("lightBox");

            return [
              $.jcoverflip.animationElement(el, { left: (container.width() / 2 - 150) + 'px', bottom: 0 }, {}),
              $.jcoverflip.animationElement(el.find('img'), { width: '300px' }, {})
            ];
        },
        change: function (event, ui) {
            jQuery('#scrollbar').slider('value', ui.to * 25);
            $('.lightBox').lightBox();
        }
    });


    jQuery('#scrollbar').slider({
        value: 50,
        stop: function (event, ui) {
            if (event.originalEvent) {
                var newVal = Math.round(ui.value / 25);
                jQuery('#flip').jcoverflip('current', newVal);
                jQuery('#scrollbar').slider('value', newVal * 25);
            }
        }
    });
}



