// JavaScript Document

var faderDiv;
var faderObj;
var faderSpeed = 10;
var faderStyle = "OUT";
var faderAmount = 100;
var barTimer;
var showTimer;

var spotlightCount = 1;

var oldSpotlight;
var oldSpotlightMenu;
var oldSpotlightInfo;

function displaySpotlightBar() {
    var secEl = document.getElementById( "spotlight_info" );
	 
    if(secEl.style.display == "none") {
        pageManager.show( "spotlight_info" );
    } else {
        pageManager.hide( "spotlight_info" );
    }
}

function setSpotlightCount(count) {
    spotlightCount = count;
}

function showSpotlightBar(style) {
    this.faderStyle = style;
    this.faderObj = document.getElementById("spotBar");
    if( faderStyle == "IN" ) {
        clearTimeout( barTimer );
        pageManager.show("spotBar");
    } else {
        barTimer = setTimeout( "pageManager.hide('spotBar')", 2000 );
    }
}

function showSpotlight(pos) {
    if( oldSpotlight != null ) {
        opacity(oldSpotlight, 100, 0, 500);
        oldSpotlightMenu.className = "spotlight_menu";
        pageManager.hide(oldSpotlightInfo);
    }
	
    if( pos > spotlightCount ) {
        pos = 1;
    }
	
    var spotlight = document.getElementById("spotlight_item" + pos);
    var spotlightMenu = document.getElementById("spotlight_menu" + pos);
	
    if(spotlight != null) {
        spotlightMenu.className = "spotlight_menu selected";
        spotlight.style.display = "block";
		
        setTimeout("opacity('spotlight_item" + pos + "', 0, 100, 1000)", 1000);
		
        setTimeout("pageManager.show('spotlight_info" + pos + "')",1000);
		
        oldSpotlight = "spotlight_item" + pos;
        oldSpotlightMenu = spotlightMenu;
        oldSpotlightInfo = "spotlight_info" + pos;
    }
	
    if( showTimer != null ) {
        clearTimeout(showTimer);
    }
	
    if( spotlightCount > 1 ) {
        showTimer = setTimeout("showSpotlight(" + (++pos) + ")", 20000);
    }
}

function startSpotlightShow() {
    showSpotlight(1);
	
    if( spotlightCount > 1 ) {
        setSpotlightVisible( true );
    } else {
        setSpotlightVisible( false );
    }
}

function setSpotlightVisible(vi) {
    if( document.getElementById("spotlight_menubar") != null ) {
        document.getElementById("spotlight_menubar").style.visibility = (vi) ? "visible" : "hidden";
    } 
}
