﻿var blocos = function () {
    return {
        init: function () {

        },
        GaleriaFotoMudar: function (target, data, alt) {
            $(target).find('img:first').removeAttr("src").removeAttr("alt");
            $(target).find('img:first').attr("src", data).attr("alt", alt);
        },
        IniciarAbas: function (bloco) {

            var _blocoTab = $(bloco).find('div:first');
            var _ul = $(_blocoTab).find('ul:first');

            var _tempElement = undefined;

            for (var i = 0; i < _ul.find('li').length; i++) {
                _tempElement = $(_ul.find('li')[i]).find('a');

                _tempElement.click(function () {
                    blocos.MudaAba($(this));
                });
            }

            $(_ul.find('li')[0]).find('a').addClass('abas_area_1_ativo');

        },
        MudaAba: function (elementSelected) {

            var _elementPrev = $(elementSelected).parent().parent();
            var _tempElement = undefined;
            var _tempDivElement = undefined;

            for (var i = 0; i < _elementPrev.find('li').length; i++) {
                _tempElement = $(_elementPrev.find('li')[i]).find('a').removeClass('abas_area_1_ativo').addClass('abas_area_1_inativo');

                _tempDivElement = $(_elementPrev.find('li')[i]).find('a').attr('rel');
                $(_tempDivElement).hide();
            }
            $(elementSelected).removeClass('abas_area_1_inativo').addClass('abas_area_1_ativo');
            _tempDivElement = $(elementSelected).attr('rel');
            $(_tempDivElement).show();
        },
        NoticiaMove: function () {

            $("#ul_scrool").css("width", "400");
            $("#rolagem").css("height", "300");
            $("#rolagem").easySlider({
                auto: false,
                continuous: false,
                vertical: true,
                orientation: "vertical"

            });
            $("#prevBtn").addClass("bt_rolagem_cima");
            $("#nextBtn").addClass("bt_rolagem_baixo");
        },
        GaleriaMyCaroucel_callback: function (carousel) {


            jQuery('#rolar_dir').bind('click', function () {
                carousel.next();
                return false;
            });

            jQuery('#rolar_esq').bind('click', function () {
                carousel.prev();
                return false;
            });
        },
        GaleriaStartCaroucel: function (elemento) {
            jQuery(elemento).jcarousel({
                scroll: 3,
                initCallback: blocos.GaleriaMyCaroucel_callback,
                // This tells jCarousel NOT to autobuild prev/next buttons
                buttonNextHTML: null,
                buttonPrevHTML: null
            });
        },
        DestChangeImg: function (target, url) {

            $(target).children().removeAttr("src");
            $(target).children().attr("src", url);

        },
        fnActionBusca: function (action) {
            var periodo = $("#periodo").val();
            var palavra_chave = $("#palavra_chave").val();
            if (palavra_chave == "") palavra_chave = "_";
            document.getElementById(action).action = "/noticia/resultadobusca/0/" + periodo + "/" + palavra_chave + "/0/1";
        },
        fnActionBuscaGeral: function (action) {
            var periodo = $("#periodo_geral").val();
            var palavra_chave = $("#palavra_chave_geral").val();
            if (palavra_chave == "") palavra_chave = "_";
            document.getElementById(action).action = "/noticia/resultadobusca/0/" + periodo + "/" + palavra_chave + "/0/1";
        }
    };
} ();


