// 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") {
		slidedown( "spotlight_info" );
	 } else {
		slideup( "spotlight_info" );
	 }
}

function setSpotlightCount(count) {
	spotlightCount = count;
}

function showSpotlightBar(style) {
	this.faderStyle = style;
	this.faderObj = document.getElementById("spotBar");
	if( faderStyle == "IN" ) {
		clearTimeout( barTimer );
		slidedown("spotBar");
	} else {
		barTimer = setTimeout( "slideup('spotBar')", 2000 );
	}
}

function showSpotlight(pos) {
	if( oldSpotlight != null ) {
		opacity(oldSpotlight, 100, 0, 500);	
		oldSpotlightMenu.className = "spotlight_menu";
		slideup(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("slidedown('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(visibility) {
	document.getElementById("spotlight_menubar").style.visibility = visibility == true ? "visible" : "hidden";	
}
