/**
 * Added to expand every element that has class hide
 * @return
 */
function expandAll(){
	var rows = document.getElementsByTagName('a');
	for( var i = 0, row; row = rows[i]; i++ ) {
		if(rows[i].id == 'hidden')
		{
			if(rows[i].className =='hide') 
				rows[i].className ='show';
			else
				rows[i].className ='hide';
		}
	}
}
function expand(){
	var toexpand = document.getElementById('toexpand');
	if (toexpand.className == 'hide') toexpand.className = 'show';
	else  toexpand.className = 'hide';
}
var theclass;
function unselect(div){
//	div.className = theclass;
//	return true;
	/*day6.innerHTML = '';
	day5.innerHTML = '';
	day4.innerHTML = '';
	day3.innerHTML = '';
	day2.innerHTML = '';
	day1.innerHTML = '';
	txtday.innerHTML = '';*/
}
var gg2Count = 0;
var tg2wait = 8000;
var tg2out = null;
tg2out = setTimeout('shiftLeftWinners();', tg2wait);
function shiftLeftWinners() {
	clearTimeout(tg2out);
	gg2Count++;
	updateWinners(1);
	gg2Count++;
	updateWinners(2);
	tg2out = setTimeout('shiftLeftWinners();', tg2wait);
}
function shiftRightWinners() {
	clearTimeout(tg2out);
	gg2Count--;
	updateWinners(1);
	gg2Count--;
	updateWinners(2);
	tg2out = setTimeout('shiftRightWinners();', tg2wait);
}
function updateWinners(which) {
	if(gg2Count < 0){
		gg2Count = srcGame.length - 1;
    }
    if(gg2Count >= srcGame.length){
        gg2Count = 0;
    }
    document.getElementById('bgImg'+which).src = srcGame[gg2Count];
	document.getElementById('bgImg'+which).alt = altGame[gg2Count];
	document.getElementById('game'+which+'Txt').innerHTML = txtGame[gg2Count];
}
//
var g2Count = 0;
var g2wait = 8000;
var g2out = null;
g2out = setTimeout('shiftLeftGames();', g2wait);
function shiftLeftGames() {
	clearTimeout(g2out);
	g2Count++;
	updateGames();
	g2out = setTimeout('shiftLeftGames();', g2wait);
}
function shiftRightGames() {
	clearTimeout(g2out);
	g2Count--;
	updateGames();
	g2out = setTimeout('shiftRightGames();', g2wait);
}
function updateGames() {
	if(g2Count < 0){
		g2Count = srcGame2.length - 1;
    }
    if(g2Count >= srcGame2.length){
        g2Count = 0;
    }
    document.getElementById('promo').src = srcGame2[g2Count];
	document.getElementById('promo').alt = altGame2[g2Count];
}
//-------------------------------------
var Count = 0;
var GameId = 0;
function shiftBottomJack() {
	Count++;
	updateJackpot();
}
function shiftTopJack() {
	Count--;
	updateJackpot();
}
function updateJackpot(showid) {
	if(Count < 0){
		Count = game.length - 1;
    }
    if(Count >= game.length){
        Count = 0;
    }
    var changed = false;
	if (showid !== null){
		for (key in id){
			if (id[key] == showid){
				var tempCount = Count;
				Count = key;
				changed = true;
			}
		}
	}
	document.getElementById('jackpot_name').innerHTML = checkLenght(game[Count]);
	document.getElementById('line1').innerHTML = "$"+avg_hit_size[Count];
	document.getElementById('line2').innerHTML = "$"+tot_win[Count];
	document.getElementById('line3').innerHTML = hits[Count];
	document.getElementById('line4').innerHTML = "$"+last_hit_amount[Count];
	
	var thevalue	= window["jsvalue"+id[Count]];
	var thedate		= window["jsdate"+id[Count]];

	showGraph(thevalue, thedate);
	GameId = Count; // update the current game id
	
	if (changed){
		Count = tempCount;
	}
}
function checkLenght(name){
	if (name.length > 20){
		return name.substring(0,18)+"..";
	}
	return name;
}