/* home page */

var selGameRequest = 0;
function selDiv(objid) {
	selGameRequest = setTimeout("selDivDelay('" + objid + "')",175);
}

function selDivDelay(objid) {
	if (objid != 'most-popular') {
		$('div_most-popular').hide();
		$('title_most-popular-on').hide();
		$('title_most-popular').show();
	}
	if (objid != 'table-games') {
		$('div_table-games').hide();
		$('title_table-games-on').hide();
		$('title_table-games').show();
	}
	if (objid != 'video-poker') {
		$('div_video-poker').hide();
		$('title_video-poker-on').hide();
		$('title_video-poker').show();
	}
	if (objid != 'video-slots') {
		$('div_video-slots').hide();
		$('title_video-slots-on').hide();
		$('title_video-slots').show();
	}
	if (objid != 'slots') {
		$('div_slots').hide();
		$('title_slots-on').hide();
		$('title_slots').show();
	}
	$('title_'+objid).hide();
	$('title_'+objid+'-on').show();
	$('div_'+objid).show();
	//Effect.BlindDown('div_'+objid, {duration: 0.5});
}

var act = 1;
var delay_turn = false;
//Flash bottom-right corner of the homepage
function launch_Game() {
	openWindowFull(best_games_url[act-1],"best_games");
}

function turn_right() {
	if (!delay_turn) {
		delay_turn = true;
		$('id_flash').turnR();
		setTimeout("turn_right_delay()", 550);	
	}
}
function turn_left() {
	//clearTimeout(delay_turn);
	if (!delay_turn) {
		delay_turn = true;
		$('id_flash').turnL();
		setTimeout("turn_left_delay()", 550);	
	}
}
function turn_left_delay() {
	//$('id_flash').changeText('blala');
	//$('id_flash').turnL();
	$('game'+act).hide();
	if (act > 1) {
		act -= 1;
	} else {
		act = 3;
	}
	$('game'+act).show();

	if (act == 1) {
		$('bestgame_left').innerHTML = best_games[2];
		$('bestgame_right').innerHTML = best_games[1];
	} else if (act == 2) {
		$('bestgame_left').innerHTML = best_games[0];
		$('bestgame_right').innerHTML = best_games[2];
	} else if (act == 3) {
		$('bestgame_left').innerHTML = best_games[1];
		$('bestgame_right').innerHTML = best_games[0];
	}
	delay_turn = false;
}
function turn_right_delay() {
	//$('id_flash').turnR();
	$('game'+act).hide();
	if (act < 3) {
		act += 1;
	} else {
		act = 1;
	}
	$('game'+act).show();
	
	if (act == 1) {
		$('bestgame_left').innerHTML = best_games[2];
		$('bestgame_right').innerHTML = best_games[1];
	} else if (act == 2) {
		$('bestgame_left').innerHTML = best_games[0];
		$('bestgame_right').innerHTML = best_games[2];
	} else if (act == 3) {
		$('bestgame_left').innerHTML = best_games[1];
		$('bestgame_right').innerHTML = best_games[0];
	} 
	delay_turn = false;
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}


function jackpot_counter() {
	var jackpot = $('jackpot_counter').innerHTML;
	jackpot = jackpot.sub(',','');
	jackpot = parseFloat(jackpot);
	
	jackpot = jackpot + ((Math.random()/3)/10);
	jackpot = jackpot.toFixed(2);
	$('jackpot_counter').innerHTML = CurrencyFormatted(jackpot);
	
	setTimeout("jackpot_counter()",3000);
}
