var arrTabs = new Array();
var rc = 0; // rotate counter
$(function() {

    tabs = $('.tab');
    tabs.each(function() {
        arrTabs[rc] = $(this).attr("id");
        rc++;
    });
	
    rc = 0;
    $('.tab').hover(
        function() {
            id = $(this).attr("id");
            tabOver(id)
        },
        function() {
            id = $(this).attr("id");
            tabOut(id);
        }
        );
	
    $('.tab').click(
        function() {
            tab = $(this).attr("id");
            loadModule(tab);
            stopModules();
        }
        );
		
    loadModule('tab-welcome');
    modulePlayer = setInterval("playModules()", 10000);
	
	
    $('#alerts').innerfade({
        animationtype: 'fade',
        speed: 1000,
        timeout: 5000,
        type: 'random_start',
        containerheight: '1em'
    });
});


function stopModules() {
    clearInterval(modulePlayer);
}

function playModules() {
    loadModule(arrTabs[rc]);
    rc++;
    if(rc == arrTabs.length) {
        rc = 0;
    }
}

	


function tabReset() {
    $('.tab').removeClass("on");
    tabs = $('.tab');
    tabs.each(function() {
        id = $(this).attr("id");
        tabOut(id);
    });
}
	
function tabOver(id) {
    //$("#"+id +" a img").attr("src","/modules/images/"+id+"_on.gif");
    $("#"+id).addClass("over");
}	
	
function tabOut(id) {
    if(!$("#"+id).hasClass("on")) {
        //$("#"+id +" a img").attr("src","/modules/images/"+id+"_off.gif");
        $("#"+id).removeClass("over");
    }
}	