// jQuery scripts used in web on document ready

$(document).ready(function() {
    // teaser cycler
    numTabs = $("#teaser .item").length;
    $('#teaser-menu li a').bind('click', function() {
        openTab($("#teaser .item:eq("+$(this).parent().index()+")"));
        return false;
    });
    autoRotate = setInterval("rotateTabs()", rotateSpeed);
});

// ----------------------------------------------------------------------------
// teaser setting and functions
var currentTab = 0;
var rotateSpeed = 6000;
var numTabs;
var autoRotate;
var toggleSpeed = 1500;
var toggleType = "";

function openTab(clickedTab) {
    var thisTab = $("#teaser .item").index(clickedTab);

    $("#teaser-menu li a").removeClass("active");
    $("#teaser-menu li:eq("+thisTab+") a").addClass("active");

    $("#teaser .item").fadeOut(toggleSpeed);
    $("#teaser .item:eq("+thisTab+")").fadeIn(toggleSpeed);

    currentTab = thisTab;
}

function rotateTabs() {
    var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
    openTab($("#teaser .item:eq("+nextTab+")"));
}


