﻿function slideSwitch() {
    var $active = $('#slideshow img.active');
    $active.addClass('last-active');
    // verifica se existe um próximo objeto na div #slideshow, caso ele nao exista, retorna para o primeiro
    var $next = $active.next().length ? $active.next() : $('#slideshow img:first');
    // Codigo que define as transicoes entre as imagens
    $next.css({ opacity: 0.0 }).addClass('active').animate({ opacity: 1.0 }, 1000, function() {
        $active.removeClass('active last-active');
    });
}

//Altera conteudo por area
this.AlteraConteudoAbas = function(pElement) {
    var containerTab = $(pElement).parents(".parentTab");

    containerTab.children().each(function(i) {
        var arrChild = "";

        if ($(this).children().length != 0)
            arrChild = PegaCssLink($(this));
        else
            arrChild = RemoveCssAtivo(this);

        $(".info_" + arrChild).hide();
    });

    var cssNome = RetornaNomeBoxInfo($(pElement).attr("class"));
    $(".info_" + cssNome).show();
    $(pElement).addClass("act");
}

// Pega o objeto link e retorna o nome do css
this.PegaCssLink = function(pParentElement) {
    var arrChild = new Array();
    pParentElement.children("a").each(function(i) {
        arrChild += RemoveCssAtivo(this);
    });
    return arrChild;
}

// Remove o act do css
this.RemoveCssAtivo = function(pLink) {
    if ($(pLink).hasClass("act"))
        $(pLink).removeClass("act");

    return RetornaNomeBoxInfo($(pLink).attr("class"));
}

// Retorna o nome do box info
this.RetornaNomeBoxInfo = function(pCss) {
    var end = pCss.indexOf(" ");
    return (end != -1) ? pCss.substring(0, end) : pCss;
}

