/** * @author jose.orlando */var h2 = $("h2#inscricoes");
var botoes = $("#financas, #varejo, .curso");
var h3 = $("h3 a");
$(function(){
    h2.css({
        "background": 'none',
        'text-indent': '0'
    }).html('<img src="img/icones/inscricoes.png" id="botao" class="png" alt="Inscri&ccedil;&otilde;es Abertas" title="Inscri&ccedil;&otilde;es Abertas" />').children().animate({
        width: '155px',
        height: '154px'
    }, 200, function(){
        $(this).animate({
            width: '147px',
            height: '146px'
        }, 200, function(){
            animaBotao();
        })
    });
    botoes.bind('mouseover focus', function(){
		var top = '282px';
       	$(this).stop(false, false).animate({
            'top': top
        }, "fast")
    }).bind('mouseleave blur', function(){
        var top = '292px';
        $(this).stop(false, false).animate({
            'top': top
        }, "fast")
    });	
    $('.hide').hide();
    h3.click(function(){
        var id = $($(this).attr('href'));
        var idClass = id.attr('class');
        if (idClass == 'hide') {
            id.slideDown("fast", function(){
                id.attr({
                    'class': ""
                });
            });
            $(this).addClass('ativo').attr('title', 'Clique para ocultar o conteúdo');
        }
        else {
            id.slideUp("fast", function(){
                id.addClass('hide');
            });
            $(this).removeClass('ativo').attr('title', 'Clique para exibir o conteúdo');
        }
        return false;
    }).append('<span></span>');
    var tamanhoTexto = _getCookie("tamanhoTexto");
    var bloco = $('#conteudo[class="interna"]');
    var linkBarra = $('#funcionalidades a');
    if (tamanhoTexto == "") {
        bloco.css({
            fontSize: "1em"
        });
    }
    else {
        bloco.css({
            fontSize: tamanhoTexto
        });
    }
    linkBarra.click(function(){
        var $this = $(this);
        var tipo = $this.attr('class');
        var funcTitle = $('#funcionalidades .mostrar-ocultar');
        var tamanhoAtual = new Number(bloco.css("fontSize").replace(/em/, ""));
        switch (tipo) {
            case "voltar":
                window.location.href = $this.attr('href');
                break;
            case "mostrar-ocultar":
                var hide = $('#conteudo div');
                var h3 = $('#conteudo h3 a');
                if (h3.attr('class') == 'png ativo') {
                    hide.stop(false, false).slideUp('fast', function(){
                        hide.attr({
                            'class': "hide",
                            'style': 'display:none'
                        });
                    });
                    h3.removeClass('ativo');
                    funcTitle.attr('title', 'Mostrar todos');
                }
                else {
                    hide.stop(false, false).slideDown('fast', function(){
                        hide.attr({
                            'class': "",
                            'style': 'display:block'
                        });
                    });
                    h3.addClass('ativo');
                    funcTitle.attr('title', 'Ocultar todos');
                }
                break;
            case "diminuir":
                var tamanhoNovo = tamanhoAtual - 0.1;
                if (tamanhoAtual > 0.8) {
                    bloco.css({
                        fontSize: tamanhoNovo + "em"
                    });
                    _setCookie('tamanhoTexto', tamanhoNovo + "em", 30);
                }
                break;
            case "aumentar":
                var tamanhoNovo = tamanhoAtual + 0.1;
                if (tamanhoAtual < 2) {
                    bloco.css({
                        fontSize: tamanhoNovo + "em"
                    });
                    _setCookie('tamanhoTexto', tamanhoNovo + "em", 30);
                }
                break;
            case "restaurar":
                bloco.animate({
                    fontSize: "1em"
                });
                _setCookie('tamanhoTexto', "1em", 30);
                break;
        }
        return false;
    });
    $("a[rel='externo']").click(function(){
        var href = $(this).attr('href');
        window.open(href, '', '');
        return false;
    });
    function _getCookie(c_name){
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) 
                    c_end = document.cookie.length;
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return "";
    }
    function _setCookie(c_name, value, expiredays){
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
    }
});
function animaBotao(){
    h2.children().animate({
        width: '155px',
        height: '154px'
    }, 200, function(){
        $(this).animate({
            width: '147px',
            height: '146px'
        }, 200, function(){
            setTimeout("animaBotao()", 1000);
        });
    });
}
