﻿var spotlightContainer = $('spotlight_container');
var activeIndex = 0;
var paused = false;

$(document).observe('dom:loaded', function(){
    spotlightContainer = $('spotlight_container');

    spotlightContainer.observe('mouseover', function(){
        paused = true;
    });

    spotlightContainer.observe('mouseout', function(){
        paused = false;
    });
    
    setInterval('if(!paused) {nextSpotlight();}', timing);
});

function updateSpotlight()
{
    spotlightElement.update(spotlightHTML[activeIndex]);
    spotlightImageBox.src = spotlightgraphic[activeIndex]; 
}

function nextSpotlight()
{
    activeIndex++;
    
    if(activeIndex >= spotlightHTML.length)
        activeIndex = 0;
        
    updateSpotlight();    
}

function previousSpotlight()
{
    activeIndex--;
    
    if(activeIndex < 0)
        activeIndex = spotlightHTML.length - 1;
        
    updateSpotlight();    
}

