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 = "Advanced options";
	}
	else
	{
		element.innerHTML = "Advanced options";
	}
}

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 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.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 = (monthlyVipLevel);
document.getElementById('silvercontainer').innerHTML = (monthlyVipLevel);
document.getElementById('goldcontainer').innerHTML = (monthlyVipLevel);
document.getElementById('platinumcontainer').innerHTML = (monthlyVipLevel);
document.getElementById('supernovacontainer').innerHTML = (monthlyVipLevel);
document.getElementById('supernovaelitecontainer').innerHTML = (monthlyVipLevel);
document.getElementById('bronzefpp').innerHTML = (document.ringGamesform.monthlyFppLevel.value);
document.getElementById('silverfpp').innerHTML = (document.ringGamesform.monthlyFppLevel.value);
document.getElementById('goldfpp').innerHTML = (document.ringGamesform.monthlyFppLevel.value);
document.getElementById('platinumfpp').innerHTML = (document.ringGamesform.monthlyFppLevel.value);
document.getElementById('supernovafpp').innerHTML = (document.ringGamesform.monthlyFppLevel.value);
document.getElementById('supernovaelitefpp').innerHTML = (document.ringGamesform.monthlyFppLevel.value);
if (monthlyVipLevel > 1000 && monthlyVipLevel <= 1199)//changed to new figures
{
document.getElementById('bronzepromote').innerHTML = "<a href=\"http://www.pokerstars.com/no/vip/silver/\"><img src=\"http://www.pokerstars.com/graphics/fpp/vip_silver2.jpg\" alt=\"Belønninger for SilverStar\" class=\"imgAlignRight\"/></a><p>Hvis du opptjener " + (1200 - monthlyVipLevel) + " VPPs mer, vil du bli <span class=\"strong\"><a href=\"http://www.pokerstars.com/no/vip/silver/\">SilverStar</a></span> VIP. Tilpass informasjonen over for &aring; se hvor mye mer du skal spille for &aring; oppn&aring; statusen <span class=\"strong\">SilverStar</span>.</p>";
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.com/no/vip/gold/\"><img src=\"http://www.pokerstars.com/graphics/fpp/vip_gold2.jpg\" alt=\"Belønninger og bonuser for GoldStar\" class=\"imgAlignRight\"/></a><p>Hvis du opptjener " + (3000 - monthlyVipLevel) + " VPPs mer, vil du bli <span class=\"strong\"><a href=\"http://www.pokerstars.com/no/vip/gold/\">GoldStar</a></span> VIP. Tilpass informasjonen over for &aring; se hvor mye mer du skal spille for &aring; oppn&aring; statusen <span class=\"strong\">GoldStar</span> status.</p>";
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.com/no/vip/platinum/\"><img src=\"http://www.pokerstars.com/graphics/fpp/vip_platinum2.jpg\" alt=\"Kampanjer for PlatinumStar\" class=\"imgAlignRight\"/></a><p>Hvis du opptjener " + (7500 - monthlyVipLevel) + " VPPs mer, vil du bli <span class=\"strong\"><a href=\"http://www.pokerstars.com/no/vip/platinum/\">PlatinumStar</a></span> VIP. Tilpass informasjonen over for &aring; se hvor mye mer du skal spille for &aring; oppn&aring; statusen <span class=\"strong\">PlatinumStar</span> status.</p>"; 
}
else
{
document.getElementById('bronzepromote').innerHTML = "";
document.getElementById('silverpromote').innerHTML = "";
document.getElementById('goldpromote').innerHTML = "";
}
	}

var ringtot
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 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) + (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<1200)//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>=1200 && total<3000)//changed to new figures
{
var bronzetotal=1200;//changed to new figures
var silvertotal= (total-1200);//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=1200;//changed to new figures
var silvertotal= (1800);//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=1200;//changed to new figures
var silvertotal=1800;//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=1200;//changed to new figures
var silvertotal=1800;//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=1200;//changed to new figures
var silvertotal=1800;//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 > 999999)
{
document.ringGamesform.vipLevel.value ="supernovaelite";
}
else if (monthlyVipLevel > 99999 && monthlyVipLevel <= 999999)
{
document.ringGamesform.vipLevel.value ="supernova";
}
else if (monthlyVipLevel > 7499 && monthlyVipLevel <= 99999)//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 > 1199 && 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";
}