// reference for the images (preloading all nav images)
imagePath = "";

///// Cookie Dealing - BEGIN
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=/;"; //domain=" + document.domain + ";";
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

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;
}
///// Cookie Dealing - END

///////////////////
///// Cookie Enabled Check (Attempt to set a cookie on client) - BEGIN
createCookie('CasinoCookieTest', 'it works', 0);

//Attempt to get the cookie from client
if(!readCookie('CasinoCookieTest'))
{
    //Failed, display the error link
    document.write('<a href="WhatAreCookies.aspx"><img style="border-width:0px;" alt="Cookies Disabled" src="/casino/images/home/nocookies.gif" /></a>');
}
else
{
    //Succeed, delete the test cookie
    eraseCookie('CasinoCookieTest');
}
///// Cookie Enabled Check  - END


///WARNING: Do not rename this function, it is called inside GTS Flash games
function changeOpenerLocation(url) {
    if (window.opener && !window.opener.closed) {
        window.opener.location = url;
        window.opener.focus();
    }
    else {
        var win = window.open(url);
        win.focus();
    }
}
	
function DepositGuide(){

	try {
		//close current window and redirect to desposit page
		self.opener.location = "https://www.virgingames.com/casino/account/deposit.aspx";
		window.close();
	}
	catch (e) {}
	
}
                            
//Refreshes the Game menu screen 
////////////////////////////////////////////////////////////////////////////////
function refreshParentGameMenuScreen() 
{
  if(opener != null && !opener.closed){
  	try  {		
  		opener.location.reload();	
			//opener.history.go(0);
		}
		catch(e){			//if permission denied (different domain) just load default menu
			opener.location.href="https://www.virgingames.com/casino/Default.aspx";	
		}
 } 
     self.close();
}

function refreshGameMenuScreen() 
{
  if(window.mainWindow != null && !window.mainWindow){
  	try  {		
  		window.mainWindow.location.reload();
			//window.mainWindow.history.go(0);
		}
		catch(e){			//if permission denied (different domain) just load default menu
			window.mainWindow.location.href="https://www.virgingames.com/casino/Default.aspx";
		}
   } 
   self.close();
}

function refreshGameMenuNoClose() 
{
  if(opener != null && !opener.closed){
  	try  {		
  		opener.location.reload();	
			//opener.history.go(0);
		}
		catch(e){			//if permission denied (different domain) just load default menu
			opener.location.href="http://casino.virgingames.com/";	
		}	  	
   }
}

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 goThenClose(loc){
	if (opener != null && !opener.closed)
		opener.location.href=loc;
	else
		opener = window.open(loc, "parent");
		
window.blur();
self.setTimeout('self.close()', 1000); 
}

function refreshParent()
{
	//document.domain = "virgingames.com";
 	if (opener != null && !opener.closed)
 	{
  	try  {		
  		opener.location.reload();	
			//opener.history.go(0);
		}
		catch(e){			//if permission denied (different domain)
			//reload home;	
			opener.location.href = "https://www.virgingames.com/casino/Default.aspx";
		}
 	}
}