function init() {
	//startList();
	setFullscreenCheckbox();
}

// builds the dropdown menu hover states for IE (not needed for browsers that actually support CSS2)
startList = function() {
    if ( document.all && document.getElementById ) {
	navRoot = document.getElementById( "dropdown" );
	for ( i = 0; i < navRoot.childNodes.length; i++ ) {
		node = navRoot.childNodes[ i ];
		if ( node.nodeName == "LI" ) {
			node.onmouseover = function() {
				this.className += " over";
			}
			node.onmouseout = function() {
				this.className = this.className.replace( " over", "" );
			}
		}
	}
    }
}
window.onload = init;

var windowNameCounter = 0;
// launches games
function openGame(game,type,gameId){
	windowNameCounter++;
	if ( game == "CommonDrawSingleZeroRoulette" || game == "LotOBallsLobby" || game == "KrazyKubesLobby" || game == "HRLobby" || game == "MadMatterhorn" || game == "HiLo" || game == "CardSharks" || game == "Play4_Jacks_or_Better" || game == "Play4_Joker_Poker" || game == "Play4_Deuces_Wild" || game == "Play4_All_American" || game == "ChallengeVideoPoker" ) {
		if ( playerHandle == "999999" ) {
			alert( "Please log in to play this game." );
			return;
		}
	}
	var name = "gamewindow_" + windowNameCounter;
	var width = "700";
	var height = "525";
	var fullscreen = document.getElementById("fullscreen");
	if ( fullscreen == null ) fullscreen = "no";
	else fullscreen = ( fullscreen.checked == true ) ? "yes" : "no";
	if ( fullscreen == "yes" ) {
		width = screen.width - 60;
		height = screen.height - 60;
	}
	gameToLoad = gameServer+"?playerHandle="+playerHandle+"&gameName="+game+"&gameId="+gameId+"&gameType="+type+"&account="+account+"&gameSuite=flash&lang="+lang+"&src="+String(document.location).split('/')[2];
	window.open(gameToLoad, name, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,fullscreen='+ fullscreen +',width='+width+',height='+height);
}

function myAccount() {
	url = accountingServer + "/servlet/TaskServlet?taskId=5001&seq=1&formatType=cmahtml&playerHandle=" + playerHandle + "&jTransform=true&lang=" + lang;
	accountWin = window.open(url, "account", 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=550');
}

function setFullscreenCookie() {
	var fullscreen = document.getElementById("fullscreen");
	if ( fullscreen == null ) return;
	var d = new Date();
	d.setDate(d.getDate() + 365);
	SetCookie( "fullscreen", fullscreen.checked, d );
}

function setFullscreenCheckbox() {
	var fscookie = GetCookie( "fullscreen" );
	if ( fscookie == null ) return;
	var fullscreen = document.getElementById("fullscreen");
	if ( fullscreen == null ) return;
	fullscreen.checked = ( fscookie == "true" ) ? true : false;
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal(j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function DeleteCookie(name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}