var gameType = "no_limit", playersType = "full_table";

var Limit = new Array ( );
Limit[ "limit" ] = new Array ( );
Limit[ "limit" ][ "full_table" ] = Array (
	Array ( "05_1",			"$0.5/$1",      3.5 ),
	Array ( "1_2",			"$1/$2",        5 ),
	Array ( "2_4",			"$2/$4",        7 ),	
	Array ( "3_6",			"$3/$6",        9.5 ),	
	Array ( "5_10",			"$5/$10",	15.5 ),	
	Array ( "10_20",		"$10/$20", 	16.5 )
);
Limit[ "limit" ][ "short_handed" ] = Array (
	Array ( "05_1",			"$0.5/$1",      5.5 ),
	Array ( "1_2",			"$1/$2",        9 ),	
	Array ( "2_4",			"$2/$4",        13 ),	
	Array ( "3_6",			"$3/$6",        17 ),	
	Array ( "5_10",			"$5/$10",	26 ),	
	Array ( "10_20",		"$10/$20", 	30 )
);
Limit[ "limit" ][ "h_u" ] = Array (
	Array ( "05_1",			"$0.5/$1",      5 ),
	Array ( "1_2",			"$1/$2",        8 ),	
	Array ( "2_4",			"$2/$4",        12 ),	
	Array ( "3_6",			"$3/$6",        16 ),	
	Array ( "5_10",			"$5/$10",	23 ),	
	Array ( "10_20",		"$10/$20", 	26 )
);
Limit[ "no_limit" ] = new Array ( );
Limit[ "no_limit" ][ "full_table" ] = Array (

	Array ( "01_025",		"$0.1/$0.25",      2.4 ),
	Array ( "025_05",		"$0.25/$0.5",      3.6 ),	
	Array ( "05_1",			"$0.5/$1",      6 ),	
	Array ( "1_2",			"$1/$2",        8 ),	
	Array ( "2_4",			"$2/$4",        12 ),	
	Array ( "3_6",			"$3/$6",        16 ),	
	Array ( "5_10",			"$5/$10",	20 ),	
	Array ( "10_20",		"$10/$20", 	28 )
);
Limit[ "no_limit" ][ "short_handed" ] = Array (
	Array ( "01_025",		"$0.1/$0.25",      4 ),
	Array ( "025_05",		"$0.25/$0.5",      5.6 ),
	Array ( "05_1",			"$0.5/$1",      12 ),
	Array ( "1_2",			"$1/$2",        16 ),
	Array ( "2_4",			"$2/$4",        20 ),		
	Array ( "3_6",			"$3/$6",        24 ),	
	Array ( "5_10",			"$5/$10",	28 ),
	Array ( "10_20",		"$10/$20", 	28 )
);
Limit[ "no_limit" ][ "h_u" ] = Array (

	Array ( "01_025",		"$0.1/$0.25",      4 ),
	Array ( "025_05",		"$0.25/$0.5",      6 ),
	Array ( "05_1",			"$0.5/$1",      8 ),
	Array ( "1_2",			"$1/$2",        13 ),
	Array ( "2_4",			"$2/$4",        18 ),
	Array ( "3_6",			"$3/$6",        22 ),
	Array ( "5_10",			"$5/$10",	26 ),
	Array ( "10_20",		"$10/$20", 	27 )
);

function changeType ( valu )
{
	if ( valu )
		gameType = valu;
	changePlayers ( );
}

function changePlayers ( valu )
{
	if ( valu )
		playersType = valu;
	var array = Limit[ gameType ][ playersType ];
	var limitSelect = document.getElementById ( "limitSelect" );	
	var limSelect;
	if ( getCookie ( "limitselected" ) )
		limSelect = getCookie ( "limitselected" );
	else if ( limitSelect.value )
		limSelect = limitSelect.value;
	else 
	{
		//limSelect = "10_20";	
		if(gameType == "no_limit")
			limSelect = "01_025";	
		else if(gameType == "limit")
			limSelect = "05_1";
	}
	/*if(gameType == "no_limit")
		limSelect = "01_025";	
	else if(gameType == "limit")
		limSelect = "05_1";
	
	*/
	limitSelect.innerHTML = "";
	for ( var a = 0; a < array.length; a++ )
	{
		var opt = new Option ( );
		opt.value = array[ a ][ 0 ];
		opt.text = array[ a ][ 1 ];
		if ( limSelect == opt.value )
			opt.selected = true;
		if ( isIE )
			limitSelect.options.add ( opt );
		else
			limitSelect.options[ limitSelect.options.length ] = opt;
	}
	limitSelect.onchange = function ( )
	{
		setCookie ( "limitselected", this.value );
	}
	
	document.getElementById ( "rakesum" ).innerHTML = "";
	limitSelect.value = limSelect;
}

function getRakebackValue ( )
{
	var array = Limit[ gameType ][ playersType ];
	var limitSelect = document.getElementById ( "limitSelect" );
	for ( var a = 0; a < array.length; a++ )
	{
		if ( array[ a ][ 0 ] == limitSelect.value )
		{
			return ( array[ a ][ 2 ] );
		}
	}
	return 0;
}

function calculateRakeback ( )
{
	var hours = document.getElementById ( "hourselect" ).value;
	var tables = document.getElementById ( "tableselect" ).value;
	var rakeback = document.getElementById ( "rakebackvalue" ).value;
	rakeback++; rakeback--; rakeback = rakeback / 100;
	var val = getRakebackValue ( ); 
	val = Math.round ( ( val * hours * tables ) * rakeback );
	
	if ( 
		navigator.userAgent.indexOf ( "afari" ) >= 1 &&
		navigator.appName.indexOf ( "onqueror" ) >= 1 
	)
	{
		document.getElementById ( "rakesum" ).innerHTML = "<div class=\"container\" id=\"rakecalcdiv\"><div class=\"rakeback\">Daily rakeback: </div><div class=\"rakebackvalue\">$" + val + "</div><div class=\"rakeback\">Monthly rakeback: </div><div class=\"rakebackvalue\">$" + ( val * 31 ) + "</div><div class=\"rakeback\">Yearly rakeback: </div><div class=\"rakebackvalue\">$" + ( val * 365 ) + "</div></div>";
	}
	else
	{
		document.getElementById ( "rakesum" ).innerHTML = "<div class=\"container\" id=\"rakecalcdiv\"><div class=\"rakeback\">Daily rakeback: </div><div class=\"rakebackvalue\">$" + val + "</div><div class=\"rakeback\">Monthly rakeback: </div><div class=\"rakebackvalue\">$" + ( val * 31 ) + "</div><div class=\"rakeback\">Yearly rakeback: </div><div class=\"rakebackvalue\">$" + ( val * 365 ) + "</div></div>";
	}
}
changePlayers ( );