//Displays the different sections in the GameDetails page
function ShowGameInfoSection(id) {
    try {
        //get all info sections
        var infoSections = document.getElementById("GameInfoItems").getElementsByTagName("div");

        //hide all sections, displaying only the selected header.		    
        for (var i = 0; i < infoSections.length; i++) {
            infoSections[i].style.display = "none";

            if (infoSections[i].id == "div" + id) {
                infoSections[i].style.display = "block";
            }
        }
    }
    catch (e) { }
}

// reference for the images (preloading all nav images)
imagePath = "";

///// Cookie Dealing - BEGIN
function createCookie(name, value, days) {
    var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	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

//Internal function to launch a game from page javascript or Flash
//If cookies created then refresh executes dynamic javascript created by uc\GameLaunch.ascx.cs - RefreshParentAndRedirect
function LaunchGameInternal(gameCode, target, cookieFlag, cookieGame) {
    createCookie(cookieFlag, 1, 0);
    createCookie(cookieGame, gameCode + '-' + target, 0);
    RefreshMe();
}

///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/";	
		}
 } 
     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/";
		}
   } 
   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="9.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/";
		}
 	}
}

//If event is 'Enter' emulates a call to the element with 'buttonId'
function doClick(event, buttonId)
{
    //the purpose of this function is to allow the enter key to 
    //point to the correct button to click.
    var keynum = 0;
    if(event.keyCode) // IE
    {
      keynum = event.keyCode;
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
      keynum = event.which;
    }
    
    if (keynum == 13)
    {
        //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonId);
        if (btn != null)
        { //If we find the button click it
            btn.click();
            return false;
        }
    }
    return true;
}

var num = -1;
var timeDelay;

var winners = new Array();

function winners_loop()
{

    try
    {
        if (num < winners.length)
        {
            num++;

            //if last winner is reached,display the first image
            if (num == winners.length)
                num = 0;

            timeDelay = setTimeout("winners_loop()", 4000);

            document.getElementById(winners[num]).style.display = "block";
            if (num == 0)
            {
                document.getElementById(winners[winners.length - 1]).style.display = "none";
            }
            else
            {
                document.getElementById(winners[num - 1]).style.display = "none";
            }
        }
    }
    catch (e)
    {

    }
}