/*
function setup_tabs(event)
{
    if (event != null)
        event.preventDefault();
    
    var clicked_tab = $(this);
    $($(".main-tab .main-tabset a.active").attr("href")).fadeOut('fast', function()
    {
        // $(".tab-content").css("display", "none");

        // set active class
        $(".main-tab .main-tabset a").removeClass("active");
        clicked_tab.addClass("active");

        // show active content
        $(clicked_tab.attr("href")).fadeIn('fast');

        // setup the tabs again
        $(".main-tab .main-tabset a:not(.active)").click(setup_tabs);
    });

    setup_link_prev();
    setup_link_next();
};

function setup_link_prev()
{

    // determines the "active" tab and performs the prev actions for the <ul> in the main gallery inside that active tab
    var active_tab = $($(".main-tab .main-tabset a.active").attr("href"));
    var prev = $(active_tab.find(".main-switch").find("a.link-prev")[0]);

    prev.click(setup_newsevents_gallery_prev);
}

function setup_link_next()
{
    // determines the "active" tab and performs the prev actions for the <ul> in the main gallery inside that active tab
    var active_tab = $($(".main-tab .main-tabset a.active").attr("href"));
    var next = $(active_tab.find(".main-switch").find("a.link-next")[0]);

    next.click(setup_newsevents_gallery_next);
}

function get_newsevents_gallery_elements()
{
    var active_tab = $($(".main-tab .main-tabset a.active").attr("href"));
    return active_tab.find(".main-gallery li");
}

function setup_newsevents_gallery_next(e)
{
    e.preventDefault();
    var elements = get_newsevents_gallery_elements();

    // reenter contents into the DOM
    var gallery = $($(".main-tab .main-tabset a.active").attr("href")).find(".main-gallery");

    $(gallery).hide("slide", { direction : 'right' }, 'slow', function()
    {
        // move the elements around
        var visible_elms = elements.splice(0,5);
        elements = $("<ul></ul>").append(elements).append(visible_elms);

        gallery.html("");
        gallery.append(elements);

        gallery.show("slide", { direction : 'left' }, 'slow');
    });
}

function setup_newsevents_gallery_prev(e)
{
    e.preventDefault();
    var elements = get_newsevents_gallery_elements();

    // reenter contents into the DOM
    var gallery = $($(".main-tab .main-tabset a.active").attr("href")).find(".main-gallery");
    $(gallery).hide("slide", { direction : 'left' }, 'slow', function()
    {
        // move the elements around
        var visible_elms = elements.splice(elements.length - 5,5);
        elements = $("<ul></ul>").append(elements).prepend(visible_elms);

        gallery.html("");
        gallery.append(elements);
        gallery.show("slide", { direction : 'right' }, 'slow');
    });
}


$(document).ready(function()
{
    // initial setup
    $(".tab-content").css("display", "none");
    $($(".main-tab .main-tabset .active").attr("href")).css("display", "block");

    // setup tabs
    $(".main-tab .main-tabset a").click(setup_tabs);
    $(".main-tab .main-tabset a:first").click();
});
*/

$(document).ready(function()
{
    // specify initial conditions
    var newsevents = $(".newsevents");

    $(".newsevents .tab-content").css('display', 'none');
    $(".newsevents .main-tabset a.tab").click(function(event)
    {
        event.preventDefault();
        $(".newsevents .tab-content").css('display', 'none');
        $($(this).attr("href")).css("display", "block");
        $(this).parent().siblings("li").children("a.tab").removeClass('active');
        $(this).addClass('active');
    });
    $(".newsevents .main-tabset a.tab:first").click();
    $(".news-output").click(function(e)
    {
        window.location = $($(this).find('.line-more a')).attr('href');
    });

    setup_prev_control(".newsevents");
    setup_next_control(".newsevents");
});
