$(document).ready(function()
{
    timer = 5000;
    paused = false;
    currentSlideID = 'gpu';
    
    $("#splash").hover(function () { paused = true; },  function () { paused = false; clearTimeout(tid); tid = setTimeout(mycode, timer); } );
    $("#splashnavigator").hover(function () { paused = true; },  function () { paused = false; clearTimeout(tid); tid = setTimeout(mycode, timer); } );
    
    // Handles the clicking of menu items
    $('#splashnavigator li').click(function(e)
    {
       next($(this));
    });
    
    function next(e)
    {
        $("#splashnavigator .selected").removeClass("selected");
			
        // switch this tab on
        $("#splashnavigator #" + e.attr("id")).addClass("selected");
           
        var itemID = $(e).attr("id");
        switchPanel(itemID);
    }
    
    
    function switchPanel(itemID)
    {
        // Stop the same slide reloading if clicked
        if(currentSlideID != itemID)
        {
            $("#" + currentSlideID).fadeOut(400, function()
            {
                currentSlideID = itemID;
                $("#" + itemID).fadeIn(600);
            });
        }
    }
    
    var tid = setTimeout(mycode, timer);
    function mycode()
    {
        if(paused == false)
        {
            nextItem = $("#" + currentSlideID).next();


            if(nextItem.length == 0)
            {
                nextItem = $("#gpu");
            }

            next(nextItem);
            tid = setTimeout(mycode, timer);
        }
    }

    
});
