y='spotlight-news';

function changeSection(x) {
	document.getElementsByTagName('body')[0].id=x;
}

function changeSpotlight(t) {
	document.getElementById(y).style.display='none'
	document.getElementById(t).style.display='block'
	y=t;
}

						  
										  
function getElm(eID) {
	return document.getElementById(eID);
}
function show(eID) {
	getElm(eID).style.display='block';
}
function hide(eID) {
	getElm(eID).style.display='none';
}
function setOpacity(eID, opacityLevel) {
	var eStyle = getElm(eID).style;
	eStyle.opacity = opacityLevel / 100;
	eStyle.filter = 'alpha(opacity='+opacityLevel+')';
}
function fade(eID, startOpacity, stopOpacity, duration) {
	var speed = Math.round(duration / 100);
	var timer = 0;
	if (startOpacity < stopOpacity){
		for (var i=startOpacity; i<=stopOpacity; i++) {
			setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
			timer++;
		} return;
	}
	for (var i=startOpacity; i>=stopOpacity; i--) {
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * speed);
		timer++;
	}
}
function fadeIn(eID) {
	setOpacity(eID, 0); show(eID); var timer = 0;
	for (var i=1; i<=100; i++) {
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * 5);
		timer++;
	}
}
function fadeOut(eID) {
	var timer = 0;
	for (var i=100; i>=1; i--) {
		setTimeout("setOpacity('"+eID+"',"+i+")", timer * 3);
		timer++;
	}
	setTimeout("hide('"+eID+"')", 310);
}

var timer_stop=0;
var speed=10000;

function switchSpotlight(x) {
	if (x==y)
	{ 
		
	}
	else
	{
		fadeOut(y);
		document.getElementById(y+'-btn').className='spotlight-toggle'
		fadeIn(x);
		document.getElementById(x+'-btn').className+=' selected'
		y=x;
	}
}

function switchSpotlightManual(x) {
	if (x==y)
	{ 
		timer_stop=1;
	}
	else
	{
		fadeOut(y);
		document.getElementById(y+'-btn').className='spotlight-toggle'
		fadeIn(x);
		document.getElementById(x+'-btn').className+=' selected'
		y=x;
		timer_stop=1;
	}
}

function initSpotlight() {
	setTimeout("rotateSpotlight()", speed);
}

function rotateSpotlight() {
	if (timer_stop==0 && y=='spotlight-news')
	{
		switchSpotlight('spotlight-article');
		setTimeout("rotateSpotlight()", speed);
	}
	else if (timer_stop==0 && y=='spotlight-article')
	{
		switchSpotlight('spotlight-game');
		setTimeout("rotateSpotlight()", speed);
	}
	else if (timer_stop==0 && y=='spotlight-game')
	{
		switchSpotlight('spotlight-news');
		setTimeout("rotateSpotlight()", speed);
	}
}

