var timeout;
var players_g;
var time = 5000;

function	initLaunchPage(players)
{
	players_g = players;
	$('#my_email').focus(function() {
		$('#my_email').val('');
	});
	$('.arrowright').click(function() {
		goRight();
	});
	$('.arrowleft').click(function() {
		goLeft();
	});	
	$('#player').hover(function() {
		clearTimeout(timeout);
	},
	function () {
		timeout = setTimeout('changePlayer()', time);
	});
	timeout = setTimeout('changePlayer()', time + 3);
}

function	goLeft()
{
	players = players_g;
	if (offset != 0) {
		$('#overflow').animate({'left': '-' + ((offset - 1) * 152) + 'px'});
		offset--;
		if (offset == 0)
			$('.arrowleft').removeClass('aorange');
		if (offset + 4 != players)
			$('.arrowright').addClass('aorange');
	}
}

function	goRight()
{
	players = players_g;
	if (offset + 4 < players) {
		$('#overflow').animate({'left': '-' + ((offset + 1) * 152) + 'px'});
		offset++;
		if (offset + 4 == players)
			$('.arrowright').removeClass('aorange');
		if (offset != 0)
			$('.arrowleft').addClass('aorange');
	}
}

function	changePlayer()
{
	if (offset + 4 == players_g) {
		offset = 1;
		goLeft();
	}
	else
		goRight();
	timeout = setTimeout('changePlayer()', time);
}
