// generic window
////////////////////////////////////////////////////////////////////////////////
function newWindow(file,windowName,features) {
  self.name="parent";
  gamewindow=window.open(file,windowName,features);
}

// close window
////////////////////////////////////////////////////////////////////////////////
function closeWindow() {
  if(window.parent != null && !window.parent.closed){
  	curloc = window.parent.location.href;
  	window.parent.location.replace(curloc);
  }
  self.close();
}

// pop up window
////////////////////////////////////////////////////////////////////////////////
function pop_up(file, w_name, width, height) {
  window.open(file, w_name, "width="+width+",height="+height+",resizable=no,toolbar=no,menubar=no,location=no,scrollbars=no,menubar=no,status=no");
}

// pop up window with scrollbars
////////////////////////////////////////////////////////////////////////////////
function pop_upScroll(file, w_name, width, height) {
  window.open(file, w_name, "width="+width+",height="+height+",resizable=no,toolbar=no,menubar=no,location=no,scrollbars=yes,menubar=no,status=no");
}


                            
//Refreshes the Game menu screen 
////////////////////////////////////////////////////////////////////////////////
function refreshParentGameMenuScreen() 
{
  if(opener != null && !opener.closed){
	 opener.location.href="/game/menu.do";
 } 
     self.close();


}

function refreshGameMenuScreen() 
{
  if(window.mainGenWindow != null && !window.mainGenWindow){
	 window.mainGenWindow.location.href="/game/menu.do";
 } 
     self.close();


}

function refreshGameMenuNoClose() 
{
  if(opener != null && !opener.closed){
	 opener.location.href="/game/menu.do";
 } 

}


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

function closeGame(){
	 try {
		if (gamewindow && !gamewindow.closed)
			gamewindow.close();
   }
   catch(e){			//if permission denied (different domain) 
			//do nothing
		}
}

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="6.0";
  requireLatestRevision=false;
  var upgradeURL="";
  install=true;
  var installURL="";
  var altURL="";
  overridePluginsPage=false;

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


function rdOpener(rd_url){
  if(window.mainGenWindow != null && !window.mainGenWindow.closed){
		window.mainGenWindow.location=rd_url;
	}
//	window.close();
}

function goThenClose(loc){
opener.location.href=loc;
window.blur();
self.setTimeout('self.close()', 1000); 
}

function refreshParent()
{
 	if (window.opener!=null)
 	{
    window.opener.location.reload();
		//	curloc = opener.parent.location.href;
    //	opener.parent.location.replace(curloc);
 	} 
}


/***********************************************
***
***	Basic Event handlers for Unobtrusive javascirpt
***
****************************************************/
	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);
	}
/********************************************
**
**	Get cookie script
**
********************************************/
function getCookie(name) 
	{
    var prefix = name + "=";
    var begin = document.cookie.indexOf(prefix);
    if (begin == -1) return null;
    var end = document.cookie.indexOf(";", begin);

    if (end == -1) end = document.cookie.length;
    return (unescape(document.cookie.substring(begin + prefix.length, end)));
	} 
	
function addAffToRegFrame()
	{
		if (getCookie("AFF_ID"))
		{
			affid = getCookie("AFF_ID");
	
			if(document.getElementById('registeriframe'))
			{
				document.getElementById('registeriframe').src = document.getElementById('registeriframe').src + "&AFF_ID=" + affid;
			}
		}	
	}
addEventSimple(window,"load",addAffToRegFrame);	
		
	
