function dynamicSelect(id1, id2) {
	// Feature test to see if there is enough W3C DOM support
	if (document.getElementById && document.getElementsByTagName) {
		// Obtain references to both select boxes
		var sel1 = document.getElementById(id1);
		var sel2 = document.getElementById(id2);
		// Clone the dynamic select box
		var clone = sel2.cloneNode(true);
		// Obtain references to all cloned options 
		var clonedOptions = clone.getElementsByTagName("option");
		// Onload init: call a generic function to display the related options in the dynamic select box
		refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		// Onchange of the main select box: call a generic function to display the related options in the dynamic select box
//		if(navigator.userAgent.indexOf("MSIE") >0)
//		alert("IE");
		
		sel1.onchange = function() {
			refreshDynamicSelectOptions(sel1, sel2, clonedOptions);
		};
	}
}
function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) {
	// Delete all options of the dynamic select box
	while (sel2.options.length) {
		sel2.remove(0);
	}
	// Create regular expression objects for "select" and the value of the selected option of the main select box as class names
	var pattern1 = /( |^)(select)( |$)/;
	var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)");
	// Iterate through all cloned options
	for (var i = 0; i < clonedOptions.length; i++) {
		// If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box
		if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) {
			// Clone the option from the hidden option pool and append it to the dynamic select box
			sel2.appendChild(clonedOptions[i].cloneNode(true));
		}
	}

}

// show and hide advancet options
function ShowHide(elementId)
{
	var element = document.getElementById(elementId);
	if(element.style.display != "inline")
	{
		element.style.display = "inline";
	}
	else
	{
		element.style.display = "none";
	}
}
function UpdateText(element)
{
	if(element.innerHTML.indexOf("Show") != -1)
	{
		element.innerHTML = "Pokročilé možnosti";
	}
	else
	{
		element.innerHTML = "Pokročilé možnosti";
	}
}

function SetDefaultGameRate()
{

	//OnClick handler for gametype listbox, sets gamerate field with default value for that game type, i.e. 80 or 75
	//gives player a chance to modify before performing calculation
	var lboGameType=document.getElementById("gameType");
	var edtHandsperhour=document.getElementById("Handsperhour");
	var strValue=lboGameType.value;//
	if(strValue=='80') edtHandsperhour.value="80";
	if(strValue=='75') edtHandsperhour.value="75";
}

function SetDefaultGameRate6()
{

	//OnClick handler for gametype listbox, sets gamerate field with default value for that game type, i.e. 80 or 75
	//gives player a chance to modify before performing calculation
	var lboGameType6=document.getElementById("gameType6");
	var edtHandsperhour6=document.getElementById("Handsperhour6");
	var strValue=lboGameType6.value;//
	if(strValue=='80') edtHandsperhour6.value="80";
	if(strValue=='75') edtHandsperhour6.value="75";
}

function SetRingGameRate()
{	
	alert("SetRingGameRate()");	
	var lboSitGoHeadSpeed=document.getElementById("gameType");
	var strSpeed=lboSitGoHeadSpeed.value;
	var edtSitGoDuration=document.getElementById("SitAndGoDuration");
	edtSitGoDuration.value=strSpeed;
}


function SetDefaultSitAndGoRate()
{	
	var lboSitGoHeadSpeed=document.getElementById("sitGoSpeed");
	var strSpeed=lboSitGoHeadSpeed.value;
	var edtSitGoDuration=document.getElementById("SitAndGoDuration");
	edtSitGoDuration.value=strSpeed;
}

function SetDefaultSitAndGoHeadsUpRate()
{
	var lboSitGoHeadSpeed=document.getElementById("SitGoHeadSpeed");
	var edtHeadsUpDuration=document.getElementById("HeadsUpDuration");
	var strValue=lboSitGoHeadSpeed.value;//
	if(strValue=='4.5') edtHeadsUpDuration.value="4.5";
	if(strValue=='6') edtHeadsUpDuration.value="6";
}

function checkifempty(){
if (document.ringGamesform.ringGames.value=='no')
{
document.ringGamesform.Handsperhour.disabled=true;
document.ringGamesform.Handsperhour.value="80";
document.ringGamesform.noGames.disabled=true;
document.ringGamesform.noGames.value=1;
document.ringGamesform.hrsPerWeek.disabled=true;
document.ringGamesform.hrsPerWeek.value="0";
document.ringGamesform.stake.disabled=true;
document.ringGamesform.stake.value="0.38";
document.getElementById('ringDiv').style.display = "none";
}
else
{
document.ringGamesform.Handsperhour.disabled=false;
document.ringGamesform.noGames.disabled=false;
document.ringGamesform.hrsPerWeek.disabled=false;
document.ringGamesform.stake.disabled=false;
document.getElementById('ringDiv').style.display = "block";
}

if (document.ringGamesform.ringGames6.value=='no')
{
document.ringGamesform.Handsperhour6.disabled=true;
document.ringGamesform.Handsperhour6.value="80";
document.ringGamesform.noGames6.disabled=true;
document.ringGamesform.noGames6.value=1;
document.ringGamesform.hrsPerWeek6.disabled=true;
document.ringGamesform.hrsPerWeek6.value="0";
document.ringGamesform.stake6.disabled=true;
document.ringGamesform.stake6.value="0.38";
document.getElementById('ringDiv6').style.display = "none";
}
else
{
document.ringGamesform.Handsperhour6.disabled=false;
document.ringGamesform.noGames6.disabled=false;
document.ringGamesform.hrsPerWeek6.disabled=false;
document.ringGamesform.stake6.disabled=false;
document.getElementById('ringDiv6').style.display = "block";
}

if (document.ringGamesform.sitGos.value=='no')
{
document.ringGamesform.tableSeats.disabled=true;
document.ringGamesform.tableSeats.value="6";
document.ringGamesform.SitAndGoDuration.disabled=true;
document.ringGamesform.SitAndGoDuration.value="3";
document.ringGamesform.sitGoNoTables.disabled=true;
document.ringGamesform.sitGoNoTables.value="1";
document.ringGamesform.hrsPerWeekSitGo.disabled=true;
document.ringGamesform.hrsPerWeekSitGo.value="0";
document.ringGamesform.avgBuyIn.disabled=true;
document.ringGamesform.avgBuyIn.value="3";
document.getElementById('sitgoDiv').style.display = "none";
}
else
{
document.ringGamesform.tableSeats.disabled=false;
document.ringGamesform.SitAndGoDuration.disabled=false;
document.ringGamesform.sitGoNoTables.disabled=false;
document.ringGamesform.hrsPerWeekSitGo.disabled=false;
document.ringGamesform.avgBuyIn.disabled=false;
document.getElementById('sitgoDiv').style.display = "block";
}
if (document.ringGamesform.sitGoHead.value=='no')
{
document.ringGamesform.HeadsUpDuration.disabled=true;
document.ringGamesform.HeadsUpDuration.value=6;
document.ringGamesform.sitGoHeadsNoTables.disabled=true;
document.ringGamesform.sitGoHeadsNoTables.value=1;
document.ringGamesform.hrsPerWeekSitGoHead.disabled=true;
document.ringGamesform.hrsPerWeekSitGoHead.value="0";
document.ringGamesform.headAvgBuyIn.disabled=true;
document.ringGamesform.headAvgBuyIn.value=3;
document.getElementById('sitgoheadDiv').style.display = "none";
}
else
{
document.ringGamesform.HeadsUpDuration.disabled=false;
document.ringGamesform.sitGoHeadsNoTables.disabled=false;
document.ringGamesform.hrsPerWeekSitGoHead.disabled=false;
document.ringGamesform.headAvgBuyIn.disabled=false;
document.getElementById('sitgoheadDiv').style.display = "block";
}
if (document.ringGamesform.multiTableTourn.value=='no')
{
document.ringGamesform.hrsPerWeekMultiTable.disabled=true;
document.ringGamesform.hrsPerWeekMultiTable.value="";
document.ringGamesform.avgBuyInMulti.disabled=true;
document.ringGamesform.avgBuyInMulti.value=5;
document.getElementById('multiDiv').style.display = "none";
}
else
{
document.ringGamesform.hrsPerWeekMultiTable.disabled=false;
document.ringGamesform.avgBuyInMulti.disabled=false;
document.getElementById('multiDiv').style.display = "block";

}
}
if (document.all || document.getElementById)
{
	setInterval("checkifempty()",100);
}

function showBlock()
{
	document.getElementById('calc').style.display = "none";
	document.getElementById('recalc').style.display = "block";
	
	if (document.ringGamesform.vipLevel.value=='bronze')
  	{
		document.getElementById('bronze').style.display = "block";
		document.getElementById('silver').style.display = "none";
		document.getElementById('gold').style.display = "none";
		document.getElementById('platinum').style.display = "none";
		document.getElementById('supernova').style.display = "none";
		document.getElementById('supernovaelite').style.display = "none";
  	}
	else if (document.ringGamesform.vipLevel.value=='silver')
	{
		document.getElementById('bronze').style.display = "none";
		document.getElementById('silver').style.display = "block";
		document.getElementById('gold').style.display = "none";
		document.getElementById('platinum').style.display = "none";
		document.getElementById('supernova').style.display = "none";
		document.getElementById('supernovaelite').style.display = "none";
	}
	else if (document.ringGamesform.vipLevel.value=='gold')
	{
		document.getElementById('bronze').style.display = "none";
		document.getElementById('silver').style.display = "none";
		document.getElementById('gold').style.display = "block";
		document.getElementById('platinum').style.display = "none";
		document.getElementById('supernova').style.display = "none";
		document.getElementById('supernovaelite').style.display = "none";
	}
	else if (document.ringGamesform.vipLevel.value=='platinum')
	{
		document.getElementById('bronze').style.display = "none";
		document.getElementById('silver').style.display = "none";
		document.getElementById('gold').style.display = "none";
		document.getElementById('platinum').style.display = "block";
		document.getElementById('supernova').style.display = "none";
		document.getElementById('supernovaelite').style.display = "none";
	}
	else if (document.ringGamesform.vipLevel.value=='supernova')
	{
		document.getElementById('bronze').style.display = "none";
		document.getElementById('silver').style.display = "none";
		document.getElementById('gold').style.display = "none";
		document.getElementById('platinum').style.display = "none";
		document.getElementById('supernova').style.display = "block";
		document.getElementById('supernovaelite').style.display = "none";
	}
	else if (document.ringGamesform.vipLevel.value=='supernovaelite')
	{
		document.getElementById('bronze').style.display = "none";
		document.getElementById('silver').style.display = "none";
		document.getElementById('gold').style.display = "none";
		document.getElementById('platinum').style.display = "none";
		document.getElementById('supernova').style.display = "none";
		document.getElementById('supernovaelite').style.display = "block";
	}
	else
	{
		document.getElementById('bronze').style.display = "none";
		document.getElementById('silver').style.display = "none";
		document.getElementById('gold').style.display = "none";
		document.getElementById('platinum').style.display = "none";
		document.getElementById('supernova').style.display = "none";
		document.getElementById('supernovaelite').style.display = "none";
	}
	document.getElementById('bronzecontainer').innerHTML = (psFormatNumber(monthlyVipLevel,','));
	document.getElementById('silvercontainer').innerHTML = (psFormatNumber(monthlyVipLevel,','));
	document.getElementById('goldcontainer').innerHTML = (psFormatNumber(monthlyVipLevel,','));
	document.getElementById('platinumcontainer').innerHTML = (psFormatNumber(monthlyVipLevel,','));
	document.getElementById('supernovacontainer').innerHTML = (psFormatNumber(monthlyVipLevel,','));
	document.getElementById('supernovaelitecontainer').innerHTML = (psFormatNumber(monthlyVipLevel,','));
	document.getElementById('bronzefpp').innerHTML = (psFormatNumber(document.ringGamesform.monthlyFppLevel.value,','));
	document.getElementById('silverfpp').innerHTML = (psFormatNumber(document.ringGamesform.monthlyFppLevel.value,','));
	document.getElementById('goldfpp').innerHTML = (psFormatNumber(document.ringGamesform.monthlyFppLevel.value,','));
	document.getElementById('platinumfpp').innerHTML = (psFormatNumber(document.ringGamesform.monthlyFppLevel.value,','));
	document.getElementById('supernovafpp').innerHTML = (psFormatNumber(document.ringGamesform.monthlyFppLevel.value,','));
	document.getElementById('supernovaelitefpp').innerHTML = (psFormatNumber(document.ringGamesform.monthlyFppLevel.value,','));

	
	if (monthlyVipLevel > 100000)
	{
		document.getElementById('supernovaelitecontainer').innerHTML = ("Přes 100.000");
		document.getElementById('supernovaelitefpp').innerHTML = ("Přes 350.000");
	} 
	
	

	if (monthlyVipLevel > 600 && monthlyVipLevel <= 749)//changed to new figures
	{
	document.getElementById('bronzepromote').innerHTML = "<a href=\"http://www.pokerstars.cz/vip/silver/\"><img src=\"http://www.pokerstars.com/graphics/fpp/vip_silver2.jpg\" alt=\"Pokerové odměny pro SilverStar\" class=\"imgAlignRight\"/></a><p>Nasbírejte o " + (750 - monthlyVipLevel) + " více VPP a stanete se <span class=\"strong\"><a href=\"http://www.pokerstars.cz/vip/silver/\">SilverStar</a></span> VIP. Níže zadejte informace o vaší hře a zjistíte, kolik ještě potřebujete nahrát, abyste se stal <span class=\"strong\">SilverStar</span>.</p>";//changed to new figures
	document.getElementById('silverpromote').innerHTML = "";
	document.getElementById('goldpromote').innerHTML = "";
	}
	else if (monthlyVipLevel > 2200 && monthlyVipLevel <= 2999)//changed to new figures
	{
	document.getElementById('bronzepromote').innerHTML = "";
	document.getElementById('silverpromote').innerHTML = "<a href=\"http://www.pokerstars.cz/vip/gold/\"><img src=\"http://www.pokerstars.com/graphics/fpp/vip_gold2.jpg\" alt=\"Bonusy a odměny pro GoldStar\" class=\"imgAlignRight\"/></a><p>Nasbírejte o " + (3000 - monthlyVipLevel) + " více VPP a stanete se <span class=\"strong\"><a href=\"http://www.pokerstars.cz/vip/gold/\">GoldStar</a></span> VIP. Níže zadejte informace o vaší hře a zjistíte, kolik ještě potřebujete nahrát, abyste se stal <span class=\"strong\">GoldStar</span>.</p>";//changed to new figures
	document.getElementById('goldpromote').innerHTML = "";
	}
	else if (monthlyVipLevel > 6800 && monthlyVipLevel <= 7499)//changed to new figures
	{
		document.getElementById('bronzepromote').innerHTML = "";
		document.getElementById('silverpromote').innerHTML = "";
		document.getElementById('goldpromote').innerHTML = "<a href=\"http://www.pokerstars.cz/vip/platinum/\"><img src=\"http://www.pokerstars.com/graphics/fpp/vip_platinum2.jpg\" alt=\"Pokerové promotion pro PlatinumStar\" /></a><p>Nasbírejte o " + (7500 - monthlyVipLevel) + " více VPP a stanete se <span class=\"strong\"><a href=\"http://www.pokerstars.cz/vip/platinum/\">PlatinumStar</a></span> VIP. Níže zadejte informace o vaší hře a zjistíte, kolik ještě potřebujete nahrát, abyste se stal <span class=\"strong\">PlatinumStar</span>.</p>"; //changed to new figures
	}
	else
	{
	document.getElementById('bronzepromote').innerHTML = "";
	document.getElementById('silverpromote').innerHTML = "";
	document.getElementById('goldpromote').innerHTML = "";
	}
}

var ringtot
var ringtot6
var sittot
var sitheadtot
var multitot
var tot
var monthlyVipLevel

function calc()
{
	var ringone = document.ringGamesform.noGames.value;
	var ringtwo = document.ringGamesform.hrsPerWeek.value;
	var ringthree = document.ringGamesform.Handsperhour.value;
	var ringfour = document.ringGamesform.stake.value; 
	ringtot = ((ringone * 1) * (ringtwo * 1) * (ringthree * 1)) * (ringfour * 1);
	
	var ringone6 = document.ringGamesform.noGames6.value;
	var ringtwo6 = document.ringGamesform.hrsPerWeek6.value;
	var ringthree6 = document.ringGamesform.Handsperhour6.value;
	var ringfour6 = document.ringGamesform.stake6.value; 
	ringtot6 = ((ringone6 * 1) * (ringtwo6 * 1) * (ringthree6 * 1)) * (ringfour6 * 1);
	
	var sitone = document.ringGamesform.SitAndGoDuration.value;
	var sittwo = document.ringGamesform.sitGoNoTables.value;
	var sitthree = document.ringGamesform.avgBuyIn.value;
	var sitfour = document.ringGamesform.hrsPerWeekSitGo.value;
	sittot = ((sitone * 1) * (sittwo * 1) * (sitthree * 1)) * (sitfour * 1);
	
	var sitheadone = document.ringGamesform.HeadsUpDuration.value;
	var sitheadtwo = document.ringGamesform.sitGoHeadsNoTables.value;
	var sitheadthree = document.ringGamesform.hrsPerWeekSitGoHead.value;
	var sitheadfour = document.ringGamesform.headAvgBuyIn.value;
	sitheadtot = ((sitheadone * 1) * (sitheadtwo * 1) * (sitheadthree * 1)) * (sitheadfour * 1);
	
	var multione = document.ringGamesform.hrsPerWeekMultiTable.value;
	var multitwo = document.ringGamesform.avgBuyInMulti.value;
	multitot = (multione * 1) * (multitwo * 1);
	
	tot = (ringtot * 1) + (ringtot6 * 1) + (sittot * 1) + (sitheadtot * 1) + (multitot * 1);
	
	monthlyVipLevel = Math.round((tot)*4.3);
}
setInterval("calc()",1000);

//copy from here
function calcTotal()
{
	var total = monthlyVipLevel;

	if (total<750)//changed to new figures
	{
		var bronzetotal=total;
		var silvertotal=0;
		var goldtotal=0;
		var platinumtotal=0;
		var supernovatotal=0;
		var supernovaelitetotal=0;
	}
	else if (total>=750 && total<3000)//changed to new figures
	{
		var bronzetotal=750;//changed to new figures
		var silvertotal= (total-750);//changed to new figures
		var goldtotal=0
		var platinumtotal=0
		var supernovatotal=0;
		var supernovaelitetotal=0;
	}
	else if (total>=3000 && total<7500)//changed to new figures
	{
		var bronzetotal=750;//changed to new figures
		var silvertotal= (2250);//changed to new figures
		var goldtotal= (total-3000);//changed to new figures
		var platinumtotal=0
		var supernovatotal=0;
		var supernovaelitetotal=0;
	}
	else if (total>7500 && total<100000)//changed to new figures
	{
		var bronzetotal=750;//changed to new figures
		var silvertotal=2250;//changed to new figures
		var goldtotal=4500;//changed to new figures
		var platinumtotal=(total-7500);//changed to new figures
		var supernovatotal=0;
		var supernovaelitetotal=0;
	}
	else if (total>99999 && total<999999)
	{
		var bronzetotal=750;//changed to new figures
		var silvertotal=2250;//changed to new figures
		var goldtotal=4500;//changed to new figures
		var platinumtotal=90000;
		var supernovatotal=(total-100000);
		var supernovaelitetotal=0;
	}
	else if (total>999999)
	{
		var bronzetotal=750;//changed to new figures
		var silvertotal=2250;//changed to new figures
		var goldtotal=4500;//changed to new figures
		var platinumtotal=90000;
		var supernovatotal=900000;
		var supernovaelitetotal=(total-1000000);
	}
	else
	{
		var bronzetotal=0;
		var silvertotal=0;
		var goldtotal=0;
		var platinumtotal=0;
		var supernovatotal=0;
		var supernovaelitetotal=0;
	}

	var fppTotal = (bronzetotal * 1) + (silvertotal * 1.5) + (goldtotal * 2) + (platinumtotal * 2.5) + (supernovatotal * 3.5) + (supernovaelitetotal * 5);

document.ringGamesform.monthlyFppLevel.value = Math.round(fppTotal);
}

setInterval("calcTotal()",100);

function viptotal()
{
	if (monthlyVipLevel > 99999)
	{
		document.ringGamesform.vipLevel.value ="supernovaelite";
	}
	else if (monthlyVipLevel > 16999 && monthlyVipLevel <= 99999)
	{
		document.ringGamesform.vipLevel.value ="supernova";
	}
	else if (monthlyVipLevel > 7499 && monthlyVipLevel <= 16999)//changed to new figures
	{
		document.ringGamesform.vipLevel.value ="platinum";
	}
	else if (monthlyVipLevel > 2999 && monthlyVipLevel <= 7499)//changed to new figures
	{
		document.ringGamesform.vipLevel.value ="gold";
	}
	else if (monthlyVipLevel > 750 && monthlyVipLevel <= 2999)//changed to new figures
	{
		document.ringGamesform.vipLevel.value ="silver";
	}
	else
	{
		document.ringGamesform.vipLevel.value ="bronze";
	}
}

setInterval("viptotal()",100);
function assumptShow() {
	document.getElementById('assumptions').style.display = "block";
}

// format number
function psFormatNumber(intNumber, strSeperator)
{
	
	strSeperator = (strSeperator=='')?',':strSeperator;
	var strNumber = '' + intNumber;
	var x = strNumber.split('.');
	var x1 = x[0];
	var x2 = x.length > 1 ? '.' + x[1] : '';
	var objRegEx = /(\d+)(\d{3})/;
	while (objRegEx.test(x1)) {
		x1 = x1.replace(objRegEx, '$1' + strSeperator + '$2');
	}
	return x1 + x2;
}