var rotateSpeed = 5000; // Milliseconds to wait until switching tabs.
var currentTab = 0; // Set to a different number to start on a different tab.
var numTabs; // These two variables are set on document ready.
var autoRotate;

function openTab(clickedTab) {
    var thisTab = $("#tabFeatureRot .tabs a").index(clickedTab);
    $("#tabFeatureRot .tabs li a").removeClass("active");
    $("#tabFeatureRot .tabs li a:eq("+thisTab+")").addClass("active");
    $("#tabFeatureRot .tabbed-content").hide();
    $("#tabFeatureRot .tabbed-content:eq("+thisTab+")").show();
    currentTab = thisTab;
}

function rotateTabs() {
    var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
    openTab($("#tabFeatureRot .tabs li a:eq("+nextTab+")"));
}

$(document).ready(function() {
    numTabs = $("#tabFeatureRot .tabs li a").length;
    $("#tabFeatureRot .tabs li a").click(function() {
        openTab($(this)); return false;
    });
    $("#tabFeatureRot").mouseover(function(){clearInterval(autoRotate)})
    .mouseout(function(){autoRotate = setInterval("rotateTabs()", rotateSpeed)});

    $("#tabFeatureRot .tabs li a:eq("+currentTab+")").click()
    $("#tabFeatureRot").mouseout();
});