	/** ULTRA-SIMPLE EVENT ADDING **/
	
	function addEventSimple(obj,evt,fn) {
		if (obj.addEventListener)
			obj.addEventListener(evt,fn,false);
		else if (obj.attachEvent)
			obj.attachEvent('on'+evt,fn);
	}
	
	function removeEventSimple(obj,evt,fn) {
		if (obj.removeEventListener)
			obj.removeEventListener(evt,fn,false);
		else if (obj.detachEvent)
			obj.detachEvent('on'+evt,fn);
	}



// reference for the images
////////////////////////////////////////////////////////////////////////////////

imagePath = "";

// preloading all nav images
////////////////////////////////////////////////////////////////////////////////

// generic window
////////////////////////////////////////////////////////////////////////////////
var gamewindow;
function newWindow(file,windowName,features) {
  if (gamewindow && !gamewindow.closed)
    {
        gamewindow.close();
    }	
  self.name="parent";
  gamewindow=window.open(file,windowName,features);
}
function closeGame(){
	 try {
		if (gamewindow && !gamewindow.closed)
			gamewindow.close();
   }
   catch(e){			//if permission denied (different domain) 
			//do nothing
		}
}
// close window
////////////////////////////////////////////////////////////////////////////////
function closeWindow() {
  self.close();
}

// launch page in parent window
////////////////////////////////////////////////////////////////////////////////
function openParent(url){
  if(opener != null && !opener.closed){
  	opener.focus();
		opener.location=url;
	}
	else
	{
		opener = window.open(url, "parent");
	}
}
// launch page in parent's parent window
////////////////////////////////////////////////////////////////////////////////
function openParentsParent(url){
  if(opener.opener != null && !opener.opener.closed){
  	opener.opener.focus();
		opener.opener.location=url;
	}
	else
	{
		opener.opener = window.open(url, "wwwSiteWin");
	}
}

///// pop up window function for Open Account page 
///////////////////////////////////////////////////////////////////////////////
var popAcct;
function launchOpenAcct ()		{
		if (popAcct && !popAcct.closed)		//make sure it comes to focus 
				popAcct.focus();
		else
    		popAcct = window.open('/register/personal.do', 'OpenAcctWin', "location,status,resizable,scrollbars,width=760px,height=850px");
}
 	
// pop up windows
var popWin;
////////////////////////////////////////////////////////////////////////////////
function pop_up(file, w_name, width, height) {
		if (popWin && !popWin.closed)		//make sure it comes to focus 
				popWin.focus();
		else
  			popWin=window.open(file, w_name, "width="+width+",height="+height+",resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=no,menubar=no,status=no");
}

// pop up window with scrollbars, resizable, location bar & status bar
////////////////////////////////////////////////////////////////////////////////
function pop_upScroll(file, w_name, width, height) {
		if (popWin && !popWin.closed)		//make sure it comes to focus 
				popWin.focus();
		else
  			popWin=window.open(file, w_name, "width="+width+",height="+height+",resizable,location,scrollbars,status");
}
                            
//Refreshes the Game menu screen 
////////////////////////////////////////////////////////////////////////////////
function refreshParentGameMenuScreen() 
{
  if(opener != null && !opener.closed){
  	try  {		
			opener.history.go(0);												    			//for IE
			if  (navigator.userAgent.indexOf("Firefox")!=-1)
						opener.location.reload();								  			//for FF
		}
		catch(e){			//if permission denied (different domain) just load default menu
			opener.location.href="/game/menu.do";
		}
 } 
     self.close();

}

function refreshGameMenuScreen() 
{
  if(window.mainWindow != null && !window.mainWindow){
  	try  {		
			window.mainWindow.history.go(0); 											//for IE
			if  (navigator.userAgent.indexOf("Firefox")!=-1)
					window.mainWindow.location.reload();							//for FF
		}
		catch(e){			//if permission denied (different domain) just load default menu
			window.mainWindow.location.href="/game/menu.do";
		}	  	
 } 
     self.close();

}

function refreshGameMenuNoClose() 
{
  if(opener != null && !opener.closed){
  	try  {		
			opener.history.go(0);																	//for IE
			if  (navigator.userAgent.indexOf("Firefox")!=-1)
					opener.location.reload();													//for FF
		}
		catch(e){			//if permission denied (different domain) just load default menu
			opener.location.href="/game/menu.do";
		}
  }
}

// logout
////////////////////////////////////////////////////////////////////////////////
function logOut()
{
    self.location.href="/security/logoff.do";
}


function closeGameWindow() {
 if (gamewindow && !gamewindow.closed)
  {
    gamewindow.close();
  }
}

function validateDropDown(fieldName,messageString)
{
  
 if (fieldName.value=='select') 
 {
    alert(messageString);
    return false;
 } 
 else
 {
    return true;
 }

}

// You must also have Dispatcher.js imported to call this function
function checkFlashVersion() {
  var contentURL="";
  var contentVersion="7.0";
  requireLatestRevision=false;
  var upgradeURL="";
  install=true;
  var installURL="";
  var altURL="";
  overridePluginsPage=false;

  MM_FlashDispatch(contentURL, contentVersion, requireLatestRevision,
			  upgradeURL, install, installURL, altURL,
			  overridePluginsPage)
}

function rdOpenerPop(rd_url){
//used by change denom button in game console
        window.location.replace(rd_url);

}

function rdOpener(rd_url){
  if(opener != null && !opener.closed){
		opener.location=rd_url;
	}
	else
	{
		opener = window.open(rd_url, "parent", "width=760,height=548,resizable,location,scrollbars=auto,status");
	}
	//window.close();
}

function goThenClose(loc){
	if (opener != null && !opener.closed)
		opener.location.href=loc;
	else
		opener = window.open(loc, "parent", "width=760,height=548,resizable,location,scrollbars=auto,status");
		
self.blur();
self.setTimeout('self.close()', 1000); 
}

function refreshParent()
{
 	if (opener != null && !opener.closed)
 	{
  	try  {		
			opener.history.go(0);																	//for IE
			if  (navigator.userAgent.indexOf("Firefox")!=-1)
					opener.location.reload();													//for FF
		}
		catch(e){			//if permission denied (different domain) just load default menu
			opener.location.href="/game/menu.do";
		}		 
 	} 
}

// used in game preview
function pop(width, height, file) {
				newWin = window.open("", 'pop_'+width+'_'+height, 'width='+width+',height='+height+',resizable=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no');
				newWin.document.writeln ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">');
				newWin.document.writeln ('<html>');
				newWin.document.writeln ('<head>');
				newWin.document.write ('<title>');
				newWin.document.write ('Game Preview');
				newWin.document.writeln ('</title>');
				newWin.document.writeln ('</head>');
				newWin.document.writeln ('<body onload="window.focus();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bottommargin="0">');
				newWin.document.writeln ('<img src="'+file+'">');
				newWin.document.writeln ('</body>');
				newWin.document.writeln ('</html>');
				newWin.document.close();
}

///// floating object (usually div) 
///// function floatDiv(id, sx, sy, scrollStart, topOffset)
///// all in pixels nut do not include 'px' in function
///////////////////////////////////////////////////////////////////////////////
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var dy;
var sysMessageHmElement = document.getElementById("errorSys_hm");
var sysMessageElement = document.getElementById("errorSys");
function floatObject(id, sx, sy, scrollStart, topMargin)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){
		this.style.left=x+px;this.style.top=y+px;
		};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0)
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		
		this.cx += (pX + this.sx - this.cx)/8;
		this.cy += (pY + this.sy - this.cy)/8;

		// updates the item location
		if (document.documentElement.scrollTop>scrollStart) {
			this.sP(this.cx, (this.cy-sy)-topMargin);
			// these if/thens turn off error messages if floating starts
			if (sysMessageElement != null || sysMessageHmElement != null) document.getElementById('errorSys_hm').style.display='none';
			if (sysMessageElement != null || sysMessageElement != null) document.getElementById('errorSys').style.display='none';
		}
		if (document.documentElement.scrollTop<scrollStart) this.sP(sx,sy);
		setTimeout(this.id + "_obj.floatIt()", 20);
	}
	return el;
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


//this updates the new message indicators on the site
function updateMsgCount(counter){
				      if (counter > 0){ 
											$('newCounter').innerHTML = counter; //update the left nav
											if ($('newCounter2')) {
													$('newCounter2').innerHTML = counter;  //update the main inbox count
													  //refreshing the page when the user is in inbox to get the new messages 
													window.location.reload();								
											}
							}
							else {
											$('newCounter').innerHTML = "";
											if ($('newCounter2'))	{
													$('newCounter2').innerHTML = "no";
													//refreshing the page when the user is in inbox to get the new messages
													window.location.reload();
											}
							}					
}   

