// Avoid `console` errors in browsers that lack a console. wh-core wh-core
(function() {
    var method;
    var noop = function () {};
    var methods = [
        'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
        'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
        'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
        'timeStamp', 'trace', 'warn'
    ];
    var length = methods.length;
    var console = (window.console = window.console || {});

    while (length--) {
        method = methods[length];

        // Only stub undefined methods.
        if (!console[method]) {
            console[method] = noop;
        }
    }
}());

var serverDate = new Date(strServerTime*1000);
var version = navigator.appVersion;
var new_window;
var bingo_window;
var bingo_mini_window;
if (console === undefined) {
console = { log : function(){}};
}
if(!$chk($('sliderframe'))){
  document.domain = "williamhill.com";
}
var tempSplit = strLang.split("-");
strLang = tempSplit[0];
strUrlLang = '/'+strLang+'/';
var strCurrency = '&pound;';
//William Hill Core
var whHelp = {
  root: function() {
    void(0);

    var tempLang = strHelpLang;
    if (strHelpLang == 'at') {
      tempLang = 'de';
    }
    if (strHelpLang == 'br') {
      tempLang = 'pt';
    }
    if (strHelpLang == 'fi' || strHelpLang == 'no' || strHelpLang == 'ro' || strHelpLang == 'pt' || strHelpLang == 'ja' || strHelpLang == 'cs' || strHelpLang == 'hu' || strHelpLang == 'sl' || strHelpLang == 'sr' || strHelpLang == 'tr' || strHelpLang == 'br'  || strHelpLang == 'fr'  || strHelpLang == 'es'  || strHelpLang == 'sv'  || strHelpLang == 'ru'  || strHelpLang == 'cn'  || strHelpLang == 'zh' || strHelpLang == 'sp' || strHelpLang == 'lang-sch' || strHelpLang == 'lang-tch') {whHelp.newHelp();}else if (strLang == 'en' || strLang == 'ie' || strLang == 'ca' || strLang == 'pl' || strLang == 'de' || strLang == 'at') {whHelp.newHelp();} else {
      var temp = strHelpUrl.replace(/lang\.cfg/g, tempLang.replace(/-/g, "_")+'.cfg');
      window.open(temp.replace(/lang\.custhelp/g, tempLang+'.custhelp'), 'RightNow', 'width=664,height=440,scrollbars=yes');
    }

  },
  liveChat: function (viewMode,firstName,surname,email) {showLiveChat(viewMode,firstName,surname,email);},
  newHelp: function(metaID,anchor) {
    void(0);
    /**
     * VARIABLES;
     * whereFrom - should always be 'inline' here
     * productID - numerical value
     * metaID - ID of article to display (optional)
     * anchor - location in article to view (optional)
     * subFrame - show a specific sub frame tab (optional)
     * viewMode - load a specific view mode (optional)
     */
    switch(document.body.id) {
      default:
      case'root_site':
        productID = '1';
        break;
      case 'bingo_site':
        productID = '504';
        break;
      case 'casino_site':
        productID = '4';
        break;
      case 'poker_site':
        productID = '5';
        break;
      case 'liveDealer_site':
        productID = '1044';
        break;
      case 'vegas_site':
        productID = '739';
        break;
      case 'skill_site':
        productID = '503';
        break;
      case 'games_site':
        productID = '23';
        break;
    }
    showHelp('inline',productID,metaID,anchor);
  },
  load: function(metaID, anchor) {
    if (strLang == 'en') {whHelp.newHelp(metaID);} else {
      void(0);
      window.open('http://williamhill-' + strHelpLang + '.custhelp.com/cgi-bin/williamhill_' + strHelpLang.replace(/-/g, "_")+ '.cfg/php/enduser/std_alp.php?meta=' + metaID + '#' + anchor, 'RightNow', 'width=664,height=440,scrollbars=yes');
    }
  },
  faq: function(metaID) {
    void(0);
    window.open('http://williamhill-' + strHelpLang + '.custhelp.com/cgi-bin/williamhill_' + strHelpLang.replace(/-/g, "_") + '.cfg/php/enduser/meta_faq.php?meta=' + metaID, 'RightNow', 'width=664,height=440,scrollbars=yes');
  },
  faq2: function(metaID, langUK) {
    void(0);
    if (strLang == 'en' || strLang == 'ie' || strLang == 'ca' || strLang == 'pl' || strLang == 'de' || strLang == 'at' || strLang == 'ja' || strLang == 'fi' || strLang == 'pt' || strLang == 'ro' || strLang == 'sl' || strLang == 'hu' || strLang == 'cs' || strLang == 'sr' || strLang == 'no' || strLang == 'tr' || strLang == 'sp' || strLang == 'cn' || strLang == 'zh' || strLang == 'ru' || strLang == 'sv' || strLang == 'fr' || strLang == 'es' || strLang == 'lang-tch' || strLang == 'lang-sch') {whHelp.newHelp(metaID);} else {
      if(langUK != 'undefined' && langUK != undefined) {
        window.open('http://williamhill-lang-uk.custhelp.com/cgi-bin/williamhill_lang_uk.cfg/php/enduser/guided_adp.php?p_faqid=' + metaID, 'RightNow', 'width=664,height=440,scrollbars=yes');
      }
      else {
        window.open('http://williamhill-' + strHelpLang + '.custhelp.com/cgi-bin/williamhill_' + strHelpLang.replace(/-/g, "_") + '.cfg/php/enduser/std_adp.php?p_faqid=' + metaID, 'RightNow', 'width=664,height=440,scrollbars=yes');
      }
    }
  },
  ask: function(metaID) {
    void(0);
    window.open('http://williamhill-' + strHelpLang + '.custhelp.com/cgi-bin/williamhill_' + strHelpLang.replace(/-/g, "_") + '.cfg/php/enduser/ask.php?p_pv=1.5&p_prods=5&prod_lvl1=5', 'RightNow', 'width=664,height=440,scrollbars=yes');
  },
  contact: function() {
    void(0);
    switch(document.body.id){
              case 'casino_site':
      productId = 4;
                break;
              case 'poker_site':
                productId = 5;
                  break;
              case 'vegas_site':
                productId = 739;
                  break;
              default:
                  productId = '';
              }
    window.open('http://williamhill-' + strHelpLang + '.custhelp.com/cgi-bin/williamhill_' + strHelpLang.replace(/-/g, "_") + '.cfg/php/enduser/ask.php?p_prods=' + productId, 'RightNow', 'width=664,height=440,scrollbars=yes');
  },
  feedback: function() {
      void(0);
      var accNumb = '';
      if(WHX.authenticated == 'Y') accNumb = WHX.data.obAccountNumber;
            var url = 'https://secure.opinionlab.com/ccc01/o.asp?id=NTNVhiKQ&custom_var='+ accNumb +'&referer='+window.location.origin;
            var title = '';
            var settings = 'width=520,height=600,scrollbars=yes,resizable=yes';
      window.open(url, title, settings);
        }
};
// JSON SORTER
var sort_by = function(field, reverse, primer){
   reverse = (reverse) ? -1 : 1;
   return function(a,b){
       a = a[field];
       b = b[field];
       if (typeof(primer) != 'undefined'){
           a = primer(a);
           b = primer(b);
       }
       if (a<b) return reverse * -1;
       if (a>b) return reverse * 1;
       return 0;
   }
}
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}
function whShowHideDiv(id) {
  if (!document.getElementById(id)) {return;}
  element = document.getElementById(id);
  if (element.style.display=='block') {element.style.display='none';}
  else{element.style.display='block';};
  if (!document.getElementById('ico_' + id)) {return;}
  element = document.getElementById('ico_' + id);
  element.classList.toggle('pk_exp');
}
var hashTitle = window.location.hash.substring(1);
if (hashTitle == 'terms' && $chk($('tAndC'))) whShowHideDiv('tAndC');
function lang_change(value) {
  if (value == 'it') {
    //alert('display italian alert!');
    $('modalDimmer').setStyles({
      'display':'block',
      'height':'100%',
      'width':'100%',
      'position':'fixed'
    });
    if ($chk($$('.modalPopup3'))) {
      // popup exists, show it...
      $$('.modalPopup3').setStyle('display','block');

      $('yesBtn').addEvent('click', function() {
              $$('.modalPopup3').setStyle('display','none');
              $('modalDimmer').setStyle('display','none');
            });
    }
    //$('modalPopup2').setStyle('display','block');
    return false;
  } else {
    Cookie.write("cust_lang", value, {duration: 30, domain: '.williamhill.com', path: '/'});
    if(value != 'en') {
      if(Cookie.read('cust_prefs') != null){
        var temp = Cookie.read('cust_prefs');
        if(temp.search('ODDS') > 0){
          temp = temp.replace('ODDS', 'DECIMAL');
        }
        if(temp.search('AMERICAN') > 0){
          temp = temp.replace('AMERICAN', 'DECIMAL');
        }
        Cookie.write("cust_prefs", temp, {duration: 30, domain: '.williamhill.com', path: '/'});
      }
      else {
        Cookie.write("cust_prefs", 'en|DECIMAL|form|TYPE|||0|SB|0|0|', {duration: 30, domain: '.williamhill.com', path: '/'});
      }
    }
    else {
      if(Cookie.read('cust_prefs') != null){
        var temp = Cookie.read('cust_prefs');
        if(temp.search('DECIMAL') > 0){
          temp = temp.replace('DECIMAL', 'ODDS');
        }
        if(temp.search('AMERICAN') > 0){
          temp = temp.replace('AMERICAN', 'ODDS');
        }
        Cookie.write("cust_prefs", temp, {duration: 30, domain: '.williamhill.com', path: '/'});
      }
      else {
        Cookie.write("cust_prefs", 'en|ODDS|form|TYPE|||0|SB|0|0|', {duration: 30, domain: '.williamhill.com', path: '/'});
      }
    }
    whNews.dataStore.erase('selectedSports');
  }
}
function site_change(url) {
  Cookie.write("cust_defaultsite", url, {duration: 365, domain: '.williamhill.com', path: '/'});
}
radioWindow = null;
function launchRadio() {
  if (radioWindow && !radioWindow.closed) {radioWindow.focus();}
  else {
    radioWindow = window.open("/radio-popup/", 'radioWindow', "toolbar=no,width=323,height=280,resizable=no,scrollbars=no");
    radioWindow.focus();
  };
}
function launchBingo(gameName, gameType) {
  //console.log(gameName);
  if (!gameName || gameName=="") {gameName="Bingo";}
  if (!gameType) {gameType="";}
  var winName = gameName.replace(/ /g,"");
  if(strLang == 'en') {
    new_window = window.open("https://sports.williamhill.com/bet/EN?action=DoGameLaunch&systemName=VirtueFusion&base_url=https://williamhill.virtuefusion.com/igames/play/game_page.do&lang=EN&source=BN&gameType="+gameName+"&gameCode=BNEN&gameType="+gameType,winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  else {
    new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtueFusion&base_url=https://williamhill.virtuefusion.com/igames/play/game_page.do&lang="+strLang.toUpperCase()+"&source=BN&gameType="+gameName+"&gameCode=BN"+strLang.toUpperCase()+"&gameType="+gameType,winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  Cookie.write('bingoPlayed', '1', {duration: 30, path: '/'});
  new_window.focus();
}
function launchBingoATP(scheduleID) {
  var gameName = 'Community Room';
  var gameType = 'Bingo';
  winName = 'ATP';
  if(strLang == 'en') {
    new_window = window.open("https://sports.williamhill.com/bet/EN?action=DoGameLaunch&systemName=VirtueFusion&gameCode=BZEN&gameType="+gameType+"-"+gameName+"-"+scheduleID+"-"+gameName+"&gameName="+gameName+"&x="+Math.random(),winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  else {
    new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtueFusion&gameCode=BZES&gameType="+gameType+"-"+gameName+"-"+scheduleID+"-"+gameName+"&gameName="+gameName+"&x="+Math.random(),winName, "toolbar=no,width=410,height=480,resizable=yes,scrollbars=yes");
  }
  new_window.focus();
}
function openAdvancedTicketPurchaseWindow(scheduleKey, gameType, gameName) {
  if ($defined(gameType) == false) var gameType = 'Bingo';
  winName = 'ATP';
  if(strLang == 'en') {
    if ($defined(gameName) == false) var gameName = 'Community Room';
    new_window = window.open("https://sports.williamhill.com/bet/EN?action=DoGameLaunch&systemName=VirtueFusion&gameCode=BZEN&gameType="+gameType+"-"+gameName+"-N-"+gameName+"-"+scheduleKey+"&gameName="+gameName+"&scheduleKey="+scheduleKey+"&x="+Math.random(),winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  if(strLang == 'ie') {
    if ($defined(gameName) == false) var gameName = 'Community Room';
    new_window = window.open("https://sports.williamhill.com/bet/IE?action=DoGameLaunch&systemName=VirtueFusion&gameCode=BZIE&gameType="+gameType+"-"+gameName+"-N-"+gameName+"-"+scheduleKey+"&gameName="+gameName+"&scheduleKey="+scheduleKey+"&region=Ireland&x="+Math.random(),winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  if(strLang == 'es') {
    if ($defined(gameName) == false) var gameName = 'Community Room';
    new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtueFusion&gameCode=BZES&gameType="+gameType+"-"+gameName+"-N-"+gameName+"-"+scheduleKey+"&gameName="+gameName+"&scheduleKey="+scheduleKey+"&x="+Math.random(),winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  if(strLang == 'sv') {
    if ($defined(gameName) == false) var gameName = 'Community Room';
    new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtueFusion&gameCode=BZSE&gameType="+gameType+"-"+gameName+"-N-"+gameName+"-"+scheduleKey+"&gameName="+gameName+"&scheduleKey="+scheduleKey+"&x="+Math.random(),winName, "toolbar=no,width=800,height=550,resizable=yes,scrollbars=yes");
  }
  new_window.focus();
}
// bookmark site function
function addToFavorites(url, title){
  if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
  else if(window.opera && window.print){
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
  }
  else if(document.all)
    window.external.AddFavorite(url, title);
}
// launch casino and poker downloads or instant plays
var whLaunch = {
  target: '',
  frameKill: function() {
    if(window.location.hash == '#iframe')return;
    if (top !== self) top.location.href = self.location.href;
  },
  openCasino: function(down) {
    //console.log(window.location.hash);
    if(window.location.hash == '#download'){whLaunch.launchDownload();}else{
      if(strLang == 'en') {
        if($chk($('testModalDesktop'))){
          var cookieName = document.body.id+'_no_prompt';
          var cookieNoPop = Cookie.read('clickinfo');
          var cookieTest = '';
          if(cookieNoPop != '' && cookieNoPop != 'undefined' && cookieNoPop != undefined) {
            cookieNoPop = cookieNoPop.split('&');
            cookieNoPop.each(function(item, index){
              if(item.contains('member')) {
                cookieTest = item.split('=');
              }
            });
            var chkUsers = ['tbgfbktestcas','tbgfbktestvegas','tbgfbktestpoker','tbgfbktestsport','tbgfbktestbingo','tbgfbktestintc','tbgfbktestskill'];

            if (chkUsers.contains(cookieTest[1])) {return;}
          }
          if (Cookie.read(cookieName)) {return;}
          var container = $('contentCenter');
          var myDrag = new Drag.Move('modalPopup2', {'container': container});
          $('modalPopup2').setStyle('display', 'block');
          //$('modalDimmer').setStyle('display', 'block');
          //whLaunch.target='https://banner.casino.williamhill.com/cgi-bin/SetupCasino.exe';
          whLaunch.target='http://whdn.williamhill.com/cms/images/casino/William-Hill-Casino-Home-Page.exe?v1-00';
        }
      }
    }
  },
  openDesktopPrompt: function(down) {
    var siteId = document.body.id;
    if((down != '') && (down != 'undefined') && (down != undefined)) {
      imgEE = new Image();
      var srcURL = "http://serve.affutd.com/promoLoadDisplay?member=whclab&campaign=DEFAULT&zone=156063504&channel=vegasdesktopshortcut";
      imgEE.src = srcURL;
      console.log('sent');
    }
    switch(siteId){
        case 'games_site':
          whLaunch.target='http://whdn.williamhill.com/cms/images/games/William-Hill-Games-Shortcut.exe';
          break;
        case 'vegas_site':
          whLaunch.target='http://whdn.williamhill.com/cms/images/vegas/William-Hill-Vegas-Shortcut.exe';
          break;
        case 'casino_site':
          whLaunch.target='http://whdn.williamhill.com/cms/images/casino/William-Hill-Casino-Home-Page.exe';
          break;
    }
  },
  cryptoCasino: function(type) {
    //if (version=='usd') {target='http://whdn.williamhill.com/cms/images/casino/WilliamHillUSDCasinoInstall.exe';}
    if(type == 'instant') {window.open('https://www.ifunds.com/XP/00/index.ehtml','instant','width=800,height=600,toolbar=no,status=yes,scrollbars=yes');}
    else {window.location.href='http://whdn.williamhill.com/cms/images/casino/WilliamHillClassicCasinoInstall.exe';}
  },
  launchCasino: function(newCode, playfor, sourceTab) {
    //Playtech New Casino Download Launch
    if(sourceTab == '' || sourceTab == 'undefined' || sourceTab == undefined || sourceTab== ' ') sourceTab = 'CA';
    if(playfor == '' || playfor == 'undefined' || playfor == undefined || playfor== ' ') playfor = 'real';
    if(playfor == 'fun' ) playfor = 'offline';
    // serbian defaults to english (WEB-162)
    if (strLang == 'sr') {
      strLang = 'en';
    }
    if(strLang != 'en' && strLang != 'da'  && strLang != 'sr'  && strLang != 'sl') {
      if(strLang == 'at') {
        newLangCas = 'de';
      }
      else if (strLang == 'ca' || strLang == 'ie') {
        /* 666 : added to launch Casino Irish and Canadian games in English */
        newLangCas = 'en';
      }else if (strLang == 'cn' || strLang == 'zh') {
        newLangCas = 'ch';
      }
      else {
        newLangCas = strLang;
      }
      if(newCode != '' && newCode != 'undefined' && newCode != undefined) {
        //new_window = window.open('https://sports.williamhill.com/bet/'+newLangCas+'?action=DoGameLaunch&systemName=PlaytechCasino&gameCode=PTIC&lang='+newLangCas+'&mode='+playfor+'&module='+newCode+'&source='+sourceTab,'instant','toolbar=no,width=980,height=830,resizable=yes');
        if (window.CSW && window.CSW.isEnabled) {

          new_window = window.open('https://gaming.williamhill.com/launch/pt7/' + newCode + '?language=' + strLang, 'instant','toolbar=no,width=800,height=660,resizable=yes');
        } else {

          new_window = window.open('http://casino.williamhill.com/'+ strLang + '/launcher/?code=' + newCode + '&flashCheck=true&mode=' + playfor + '&source='+sourceTab,'instant','toolbar=no,width=980,height=830,resizable=yes');
        }
      }
      else {
        new_window = window.open('https://cachedownload2.williamhill.com/casinoclient.html?language='+newLangCas,'instant','width=980,height=830,toolbar=no,status=yes,resizable=yes');
      }
    }
    else {
      if(newCode != '' && newCode != 'undefined' && newCode != undefined) {

        if (window.CSW && window.CSW.isEnabled) {

          new_window = window.open('https://gaming.williamhill.com/launch/pt7/' + newCode +'?mode=' + playfor + '&language=' + strLang, 'instant','toolbar=no,width=800,height=660,resizable=yes');
        } else {

          new_window = window.open('https://sports.williamhill.com/bet/EN?action=DoGameLaunch&systemName=PlaytechCasino&gameCode=PTIC&lang='+strLang+'&mode='+playfor+'&module='+newCode+'&source='+sourceTab,'instant','toolbar=no,width=1152,height=744,resizable=yes');
        }
      }
      else {
        new_window = window.open('https://banner.casino.williamhill.com/casinoclient.html','instant','width=1152,height=744,toolbar=no,status=yes,resizable=yes');
      }
    }
    new_window.focus();
  },
  closeCasino: function() {
    //New Casino Instant Launch
    $('modalPopup2').setStyle('display', 'none');
    $('modalDimmer').setStyle('display', 'none');
    $('dragger').setStyle('display', 'none');
    whLaunch.dropPromptCookie();
  },
  delayRedirect: function(url, duration) {
    setTimeout(function () {
              document.location.pathname = url;
          }, duration);
  },
  gettingStarted: function(version, siteId) {
    if(siteId == undefined || siteId == ''){siteId = document.body.id;}
    var gettingStartedPage = '';
    switch(siteId){
              case 'poker_site':
                if (navigator.platform.indexOf('Mac') >=0){return;}
                if (strLang == 'br'){
                  // not sure if this code is ever executed
                  gettingStartedPage = strLang + '/download-gratis/';
                } else if(strLang == 'en'){
                  gettingStartedPage = '/download/';
                } else {
                  gettingStartedPage = strLang + '/download/';
                }
              break;
          }
          if (gettingStartedPage != '') {
            _gaq.push(['_trackEvent', 'Button', 'FreeDownload', 'Poker']);
      setTimeout(function () {
              document.location.pathname = gettingStartedPage;
          }, 2000);
    }
  },
  gettingStartedPop: function(version, siteId) {
    if(siteId == undefined || siteId == ''){siteId = document.body.id;}
    var gettingStartedPage = '';
    switch(siteId){
              case 'poker_site':
                if (navigator.platform.indexOf('Mac') >=0){return;}
                if(strLang == 'en'){
                  gettingStartedPage = 'download/';
                } else if (strLang != 'br') {
                  gettingStartedPage = strLang + '/download/';
                } else {
                  gettingStartedPage = strLang + '/download-gratis/';
                }
                gettingStartedPage = 'http://poker.williamhill.com/' + gettingStartedPage;
                var fakeLang = getQueryVariable('l');
                if (typeof fakeLang !== 'undefined' && fakeLang != null && fakeLang != 'at') {
                  gettingStartedPage += '?l=' + fakeLang;
                }
              break;
          }
          if (gettingStartedPage != '') {
            window.open(gettingStartedPage, '_blank');
    }
  },
  launchDownload: function(version, siteId) {
    var affID = "";
    if(Cookie.read('banner_click') != null){
      affID = Cookie.read('banner_click');
    }else{
      if(Cookie.read('NETREFER_COOKIE_BTAG') != null){
        affID = Cookie.read('NETREFER_COOKIE_BTAG').split('&')[0].split('=')[1]
      }
    }
    if(siteId == undefined || siteId == ''){siteId = document.body.id;}
    switch(siteId){
              case 'casino_site':
                if(strLang == 'at') {whLaunch.target='https://banner.casino.williamhill.com/cgi-bin/SetupCasino.exe?opt_lang=de&creferer=time:' + strServerTime + ';affiliate_id:' + affID;
      }
      else if (strLang == 'ca' || strLang == 'ie') {whLaunch.target='https://banner.casino.williamhill.com/cgi-bin/SetupCasino.exe?opt_lang=en&creferer=time:' + strServerTime + ';affiliate_id:' + affID;
      }
      else if (strLang == 'cn' || strLang == 'zh') {whLaunch.target='https://banner.casino.williamhill.com/cgi-bin/SetupCasino.exe?opt_lang=ch&creferer=time:' + strServerTime + ';affiliate_id:' + affID;
      }
      else {whLaunch.target='https://banner.casino.williamhill.com/cgi-bin/SetupCasino.exe?opt_lang='+strLang+'&creferer=time:' + strServerTime + ';affiliate_id:' + affID;
      }
      window.location.href = whLaunch.target;
      //console.log(' - Start Download: ' + whLaunch.target);
      //$('modalPopupIframe').src = whLaunch.target;
                break;
              case 'poker_site':
                if (navigator.platform.indexOf('Mac') >=0){
                  //alert("We are sorry but the William Hill Poker software is not compatible with Mac computers. Please try downloading the software using a PC. We apologise for the inconvenience.");
                  openInstantPlay(1280, 740);
                  break;
                }
                // whLaunch.target='http://banner.poker.williamhill.com/cgi-bin/SetupPoker.exe?opt_lang='+strLang+'&creferer=time:' + strServerTime + ';affiliate_id:' + affID;
                //international hardcoded see WEB-49
                //whLaunch.target='http://banner.poker.williamhill.com/cgi-bin/SetupPoker.exe?creferer=time:' + strServerTime + ';affiliate_id:' + affID; 
                whLaunch.target='https://banner.poker.williamhill.com/cgi-bin/SetupPoker.exe?creferer=time:' + strServerTime + ';affiliate_id:' + affID;
                  window.location.href = whLaunch.target;
                  break;
              }
  },
  close: function() {
    $('modalPopup').setStyle('display', 'none');
    $('modalDimmer').setStyle('display', 'none');
    $('dragger').setStyle('display', 'none');
  },
  launchInstant: function() {
    switch(document.body.id){
              case 'casino_site':
              window.open('https://www.ifunds.com/XP/00/index.ehtml','instant','width=800,height=600,toolbar=no,status=yes,scrollbars=yes');
              break;
              case 'poker_site':
              window.open('https://ndpoker.wagerlogic.com/Poker/PokerFlex.html','instant','width=800,height=600,toolbar=no,status=yes,scrollbars=yes');
              break;
              }
  },
  getFile: function() {
    console.log("File: " + whLaunch.target);
    window.location.href = whLaunch.target;
  },
  launchPrompt: function() {
    console.log(window.location.hash);
    if(window.location.hash == '#download'){
      //console.log('1');
      whLaunch.launchDownload();
    }else{
      //console.log('2');
      var cookieName = document.body.id+'_no_prompt';
      var cookieNoPop = Cookie.read('clickinfo');
      var cookieTest = '';

      if (Cookie.read(cookieName)) {return;}

      if(cookieNoPop != '' && cookieNoPop != 'undefined' && cookieNoPop != undefined) {
        cookieNoPop = cookieNoPop.split('&');

        cookieNoPop.each(function(item, index){
          if(item.contains('member')) {
            cookieTest = item.split('=');
          }
        });
        var chkUsers = ['facebookukWHP01','facebookukWHP02'];
        if (chkUsers.contains(cookieTest[1])) {return;}
      }

      if (document.body.id != 'poker_site'){
        var container = $('contentCenter');
        var myDrag = new Drag.Move('modalPopup2', {'container': container});
        //$('dragger').setStyle('display', 'block');
        $('modalPopup2').setStyle('display', 'block');
        $('modalDimmer').setStyle('display', 'block');
      }
    }
  },
  acceptPrompt: function() {
    whLaunch.dropPromptCookie();
    $('modalPopup2').setStyle('display', 'none');
    $('modalDimmer').setStyle('display', 'none');
    whLaunch.launchDownload();
  },
  cancelPrompt: function() {
    whLaunch.dropPromptCookie();
    $('modalPopup2').setStyle('display', 'none');
    $('modalDimmer').setStyle('display', 'none');
    $('dragger').setStyle('display', 'none');
  },
  dropPromptCookie: function() {
    var cookieName = document.body.id+'_no_prompt';
    Cookie.write(cookieName, '1', {duration: 365, path: '/'});
  },
  inParent: function(url) {
    if(opener && !opener.closed){
        opener.location.href = url;
        opener.focus();
        void(0);
    }else{
        var win = window.open(url, '', 'fullscreen=yes,scrollbars=auto,menubar=yes,status=yes,location=yes,toolbar=yes');
        win.focus();
        void(0);
    }
  }
};
var whTrack = {
  getCookie: function(c_name) {
    if (document.cookie.length > 0) {
      c_start = document.cookie.indexOf(c_name + "=");
      if (c_start != -1) {
        c_start = c_start + c_name.length + 1;
        c_end = document.cookie.indexOf(";", c_start);
        if (c_end == -1) c_end = document.cookie.length;
        return unescape(document.cookie.substring(c_start, c_end));
      }
    }
    return "";
  },
  getQuerystring: function(key, url){
    key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
      var qs = regex.exec(url);
      if(qs == null)
            return "nokey";
      else
            return qs[1];
  },
  getTag: function(strTag) {
  },
  getEETag: function(strTag) {
  },
  getAffTag: function(strTag, strLangSelect) {
  },
  getAffUtdTag: function(strSource, strZone, strProductUrl, strLP, varU) {
  },
  urlEncode: function(encodeHtml){
       encodedHtml = escape(encodeHtml);
       encodedHtml = encodedHtml.replace(/\//g,"%2F");
       encodedHtml = encodedHtml.replace(/\?/g,"%3F");
       encodedHtml = encodedHtml.replace(/=/g,"%3D");
       encodedHtml = encodedHtml.replace(/&/g,"%26");
       encodedHtml = encodedHtml.replace(/@/g,"%40");
       return encodedHtml;
  },
  getSERef: function(code){}}
var tip = new Class({
    Implements: [Options],
    options: {
        elLock: document.body,
        tipDelay: 0,
        tipDuration: 60000,
        tipBounce: 10000,
        msg: ''
    },
    initialize: function(options) {
        var tip = new Element('div', {
            'class': 'tipContainer',
            'style': 'margin-top: 35px;',
            'html': '<div class="tipText">' + options.msg + '</div><div class="tipCap">&nbsp;</div>'
        });
        tip.setOpacity(0);
        tip.inject(document.body, 'top');
        var tipFx = new Fx.Morph(tip, {duration: 1000, transition: Fx.Transitions.Bounce.easeOut});
        this.setTipPosition(options.elLock, tip);
        window.addEvent('resize', function(){
          setTipPosition(options.elLock, tip);
        });
        (function(){
            tipFx.start({
                'opacity': 1,
                'margin-top': 0
            });
            if(options.tipBounce > 0){
                var tipBounceStartFx = new Fx.Morph(tip, {duration: 250, transition: Fx.Transitions.Quad.easeInOut});
                var tipBounceEndFx = new Fx.Morph(tip, {duration: 1000, transition: Fx.Transitions.Bounce.easeOut});
                var bounceTmr = function(){
                    tipBounceStartFx.start({
                        'margin-top': [0 , 16]
                    }).chain(function(){
                    tipBounceEndFx.start({
                        'margin-top': [16 , 0]
                    })});
                }.periodical(options.tipBounce);
            };
            (function(){
                new Fx.Tween(tip).start('opacity', 0).chain(function(){
                    $clear(bounceTmr);
                    tip.destroy();
                })
            }).delay(options.tipDuration);
        }).delay(options.tipDelay);
    },
    setTipPosition: function(el, tip){
        var alignTo = $(el).getCoordinates();
        if(alignTo.left.toInt() + tip.getSize().x > 996){
            tip.setStyles({
                top: alignTo.top + alignTo.height + 7,
                left: (alignTo.left - tip.getSize().x) + alignTo.width,
                backgroundPosition: 'top right'
            });
        }else{
            tip.setStyles({
                top: alignTo.top + alignTo.height + 7,
                left: alignTo.left
            });
        }

    }
});
var SliderPromo = new Class({
    //implements
    Implements: [Options],
    //options
    options: {
        scrollArea: '',
        scrollControl: '',
        autoScroll: true
    },
    //initialization
    initialize: function(options) {
        var scrollAreas = $$(options.scrollArea);
        var scrollControls = $$(options.scrollControl);
        var itemCount = [];
        var itemCurrent = [];
        var navCount = [];
        var navCurrent = [];
        var scrollView = [];
        var scrollOffset = [];
        var scrollFx = [];
        var scrollBusy = [];
        var duration = 600;
        scrollAreas.each(function(item, index){
            var scrollItems =  item.getElements('li');
            scrollBusy[index] = false;
            itemCount[index] = scrollItems.length;
            navCurrent[index] = 0;
            scrollView[index] = itemCurrent[index];
            scrollOffset[index] = scrollItems[0].getSize().y;
            scrollFx[index] = new Fx.Scroll(item, {
              duration: 500,
                wheelStops : false,
                transition: Fx.Transitions.Quad.easeInOut
            });
            scrollItems.each(function(item, index){
              item.addEvent('click', function(event){
                selectScroll(item.get('id')+'-block');
                scrollItems.each(function(item){item.removeClass('activePromo');});
                item.addClass('activePromo');
              });
      });
        });
        scrollControls.each(function(navItems, conIndex){
          var upB = navItems.getElements('a.upButton');
          var downB = navItems.getElements('a.downButton');
    downB.addEvent('click', function(event){
      if(navCurrent[conIndex]+3<itemCount[conIndex]) {
        event.stop();
        scrollMe(navItems, conIndex, navCurrent[conIndex]+1);
      }
    });
    upB.addEvent('click', function(event){
      if(navCurrent[conIndex]>0) {
        event.stop();
        scrollMe(navItems, conIndex, navCurrent[conIndex]-1);
      }
    });
        });
        function scrollMe(navItems, conIndex, index){
    scrollFx[conIndex].start(0, (scrollOffset[conIndex]) * index).chain(function(){
      navCurrent[conIndex] = index;
      scrollBusy[conIndex] = false;
    });
        }
  function selectScroll(blockId) {
    $$('div.promosContent').each(function(item) {item.setStyle('display','none');});
    //console.log(blockId);
    $(blockId).setStyle('display','block');
  }
     }
});
var SliderNav = new Class({
    //implements
    Implements: [Options],
    //options
    options: {
        scrollArea: '',
        scrollControl: '',
        autoScroll: true
    },
    //initialization
    initialize: function(options) {
        var scrollAreas = $$(options.scrollArea);
        var scrollControls = $$(options.scrollControl);
        var itemCount = [];
        var itemCurrent = [];
        var navCount = [];
        var navCurrent = [];
        var scrollView = [];
        var scrollOffset = [];
        var scrollFx = [];
        var scrollBusy = [];
        var duration = 600;
        scrollAreas.each(function(item, index){
            var scrollItems =  item.getElements('li');
            scrollBusy[index] = false;
            itemCount[index] = scrollItems.length;
            navCount[index] = scrollControls[index].getElements('li.dot').length;
            navCurrent[index] = 0;
            scrollView[index] = itemCurrent[index];
            scrollOffset[index] = scrollItems[0].getSize().x -1;
            scrollFx[index] = new Fx.Scroll(item, {
              duration: 500,
                wheelStops : false,
                transition: Fx.Transitions.Quad.easeInOut
            });
        });
        scrollControls.each(function(navItems, conIndex){
          var navLinks = navItems.getElements('li');
    navLinks .each(function(item, index){
      if(index == 0){updateDots(navItems, 0);}
      item.addEvent('click', function(event){
        event.stop();
        if(navLinks .length > 1){
          scrollMe(navItems, conIndex, index);
        }
      });
    });

        });
        function scrollMe(navItems, conIndex, index){
          updateDots(navItems, index);
    scrollFx[conIndex].start((scrollOffset[conIndex]) * index+1, 0).chain(function(){
      navCurrent[conIndex] = index;
      scrollBusy[conIndex] = false;
    });
        }
        function updateDots(navItems, navCurrent){
            navItems.getElements('li.dot').each(function(item, index){
                if(index == navCurrent){item.addClass('on');}else{item.removeClass('on');}
            });
        }
    }
});
var FadeNav = new Class({
    //implements
    Implements: [Options],
    //options
    options: {
        scrollArea: ''
    },
    //initialization
    initialize: function(options) {
        var scrollAreas = $$(options.scrollArea);
        var pauseDuration = (options.duration)?(options.duration):4;
        pauseDuration = pauseDuration * 1000;
        var itemList = [];
        var itemCount = [];
        var itemCurrent = [];
        var navCurrent = [];
        var fadeDuration = 600;
        scrollAreas.each(function(item, index){
            itemList[index] =  item.getElements('li');
            itemCount[index] = itemList[index].length;
            navCurrent[index] = 0;
            if (itemList[index].length>1) {
        scrollNext.delay(pauseDuration, this, index);
      }
      itemList[index][0].setStyle('display','block');
        });
        function scrollNext(index){
    var fadeOut = new Fx.Tween(itemList[index][navCurrent[index]], {
      duration: fadeDuration,
                  transition: Fx.Transitions.Quad.easeIn
              });
    navCurrent[index]++;
    if (navCurrent[index]==itemCount[index]) {navCurrent[index]=0;}
    var fadeIn = new Fx.Tween(itemList[index][navCurrent[index]], {
      duration: fadeDuration,
                  transition: Fx.Transitions.Quad.easeOut
              });
    fadeOut.start('opacity', 1, 0).chain(
      function(){
        itemList[index][navCurrent[index]].setStyle('opacity', '0');
        itemList[index][navCurrent[index]].setStyle('display', 'block');
        fadeIn.start('opacity', 0, 1);
      }
    );
    scrollNext.delay(pauseDuration+2*fadeDuration, this, index);
        }
    }
});
var winners = new Class({
    Implements: [Options],
    options: {
        table: ''
    },
    initialize: function(options) {
  var tables = $$(options.table)
    if(tables.length > 0){
      var dataRows = $$(options.table)[0].getElements('li.dataRow');
      (function(){
        dataRows.each(function(item, index){
        if(item.getElement('.seconds')){
          var secDom = item.getElement('.seconds');
          var endDate = new Date(item.getElement('.timestamp').innerHTML*1000)
          var endMins = Math.round((endDate - serverDate)/(60*1000));
          if (!secDom) {return;}
          if (endMins > 0){
            if(endMins == 1){
              secDom.innerHTML = "< " + endMins;
            }else{
              secDom.innerHTML = endMins;
            }
          }else{
            item.fade(.3);
            item.getElement('.playNow a').href = "javascript:;";
            item.getElement('.playNow a').setStyle('cursor', 'default');
            (function(){
              item.dispose();
              if(dataRows.length > index + 5){
                dataRows[index + 5].setStyle('display', 'block');
              }
            }).delay(30000)
          }
        }
        });
      }).periodical(30000);
    }
    }
});
var whMessaging = {
  init: function() {
      var msgBar = $$('#contentCenter .headerBG .siteMessages');
      if(msgBar.length > 0){
        if(!Cookie.read('msg_'+msgBar[0].id)){
        msgBar[0].setStyle('display', 'block');
    msgBar[0].getElement('#rightMessage a').addEvent('click', function(event){
      Cookie.write('msg_'+msgBar.id, true, {duration: 1, path: ''});
      msgBar[0].setStyle('display', 'none');
    });
    }
      }
  }
};
var unicaVersion = 7;
var isVIP = false;
var whLogin = {
  init: function(events) {
      var defaultUserText = $('user').get('value');
      $('signinDetails').setStyle('display','none');
      console.log(' - Auth Request Sent');
      var obLang = 'en-gb';
      switch(strLang.toUpperCase()){
    case 'ES': obLang = 'es-es'; break;
    case 'FR': obLang = 'fr-fr'; break;
    case 'ZH': obLang = 'zh-hk'; break;
    case 'CN': obLang = 'zh-cn'; break;
    case 'DE': obLang = 'de-de'; break;
    case 'AT': obLang = 'de-at'; break;
    case 'IE': obLang = 'en-ie'; break;
    case 'CA': obLang = 'en-ca'; break;
    case 'AU': obLang = 'en-au'; break;
    case 'EN': obLang = 'en-gb'; break;
    case 'BR': obLang = 'PT'; break;
    default: obLang = strLang.toUpperCase(); break;
      }
      new Asset.javascript('http://sports.williamhill.com/bet/'+obLang+'/?action=GetXLoginForm&lang='+strLang+'&t=' + serverDate.getTime(), {
    onload: function(){
              //console.log(' - Response From Login Server - Auth: '+ WHX.authenticated);
                if(WHX.authenticated == 'Y'){
                  var endDate = new Date(2016, 01, 18, 24);
                  if (serverDate.getTime() < endDate.getTime()) {
                    if (document.body.id == 'vegas_site' && strLang == 'en') {
                    var script = document.createElement('script');
                    var head = document.getElementsByTagName('head')[0];
                    script.src = "http://whdn.williamhill.com/cms/site_js/vegas_site/soldiers?v=1-21";
                    script.type = "text/javascript";
                    head.appendChild(script);
                    }
                  }

                    $('signinLoader').setStyle('display','block');
              $('signinForm').setStyle('display','none');
              $('obGreetingLabel').innerHTML = WHX.data.obGreetingLabel;
              $('obClientName').innerHTML = WHX.data.obClientName;
              $('obAccountLabel').innerHTML = WHX.data.obAccountLabel;
          $('obAccountNumber').innerHTML = WHX.data.obAccountNumber;
          $('obBalanceLabel').innerHTML = WHX.data.obBalanceLabel;
          $('userBalance').innerHTML = WHX.data.obBalanceCurrency + WHX.data.obBalanceAmount;
          $('obDepositLabel').innerHTML = WHX.data.obDepositLabel;
          if (WHX.data.obUvsRating > 5) isVIP = true;
          //$('obMessageLabel').innerHTML = WHX.data.obMessageLabel;
          //$('obMessageNumber').innerHTML = WHX.data.obMessageNumber;
          if (WHX.data.obMessageNumber > 0) {
            $('obMessageNumber').innerHTML = WHX.data.obMessageNumber;
            $('obMessageNumber').removeClass('msg-icon-none');
            $('obMessageNumber').addClass('msg-icon');
          }
          if(Cookie.read('firstLogin') != 1) {
            Cookie.write("firstLogin", 1, {duration: 365, domain: '.williamhill.com', path: '/'});
          }
          if (!Cookie.read('__utmv')){
            Cookie.write("__utmv", "1=AccNum=" + WHX.data.obAccountNumber, {duration: 365, domain: '.williamhill.com', path: '/'});
          }
          Cookie.write("account_cookie", WHX.data.obAccountNumber, {duration: 365, domain: '.williamhill.com', path: '/'});
          strCurrency = WHX.data.obBalanceCurrency;
              if($chk($('jackpotCurr'))){
            //Loop through all euro jackpots
        $$('#jackpotCurr .EUR').each(function(item) {
          if(strCurrency != '&euro;') {
            item.setStyle('display', 'none');
          }
          if(strCurrency == '&euro;') {
            item.setStyle('display', 'block');
          }
        });
        //Loop through all sterling jackpots
        $$('#jackpotCurr .GBP').each(function(item) {
          if(strCurrency != '&pound;') {
            item.setStyle('display', 'none');
          }
          if(strCurrency == '&pound;') {
            item.setStyle('display', 'block');
          }
        });
        //Loop through all dollars jackpots
        $$('#jackpotCurr .DLR').each(function(item) {
          if(strCurrency != '$') {
            item.setStyle('display', 'none');
          }
          if(strCurrency == '$') {
            item.setStyle('display', 'block');
          }
        });
          }
          $('obLogoutValue').innerHTML = WHX.data.obLogoutValue;
          if($chk($('inSiteJoinButton'))){
                             $('inSiteJoinButton').setStyle('display', 'none');
                      }
                      if ($chk($('newQuickLinks'))){$('newQuickLinks').set('class','displayBlock');}
                      if($chk($('loggedOut'))){
                             $('loggedOut').setStyle('display', 'none');
                             if($chk($('loggedIn'))) $('loggedIn').setStyle('display', 'block');
                      }
                $('signinLoader').setStyle('display','none');
                    $('signinDetails').setStyle('display','block');
                    //Live Casino extra game
                    if($chk($('homeBox-newGame'))){
                             $('homeBox-newPlayer').setStyle('display', 'none');
                             $('homeBox-newGame').setStyle('display', 'block');
                      }
          loginListener.loggedIn();
          /*Delete HTML element where name=qsHold-2 in Casino site  -  #7099 */
          $$('.qsHold[name=qsHold-2]').dispose();
                    if((events != undefined) && (events != 'undefined') && (typeof(events.callback) != 'undefined') && (events.callback != 'undefined')){events.callback.run();}
                    // start unica code //
                    var ss = document.createElement('script');
          var scr = "var NTPT_PGEXTRA = \"un=" + WHX.data.obAccountNumber + "\";";
          ss.text = scr;
          var hh = document.getElementsByTagName('head')[0];
          hh.appendChild(ss);

          if (Cookie.read('vegasPlayed')!='1' && document.body.id == 'vegas_site' && $chk($("contentHead"))) {
        $("contentHead").setStyle('display', 'block');
          }
         if (document.body.id == 'games_site') {gameNav.conversionBanner();}

         if (window.CSW && window.CSW.isEnabled && document.body.id == 'casino_site') {

            $('casFrame').set('src', "https://gaming.williamhill.com/session/auth/login?cust_login=true&gateway=true&returnUrl=https%3A%2F%2Fgaming.williamhill.com%2Fsession%2Fuser%2Fsessioncheck-iframe%3FdocUrl%3D"+ encodeURIComponent(location.href));
         }

         if($chk($('quicklinks_toggle'))){
                             $$('.quicklinks_real').set('style', 'display:block');
                             $$('.quicklinks_fun').set('style', 'display:none');
                     }
                }else{
                    if (script) {head.removeChild(script);}
                    //console.log(' - Authenticated: N');
        /*
        if(Cookie.read('cust_login') != "" && Cookie.read('cust_login') != null){
          $('user').set('value', Cookie.read('username_cookie'));
          if($chk($('remember_me'))) $('remember_me').set('checked') == true;
          if($chk($('remember_me_value'))) $('remember_me_value').set('value', 1);
        }
        */
        if (document.body.id == 'vegas_site' && $chk($("contentHead"))) {
          $("contentHead").setStyle('display', 'block');
            }
            if($chk($('quicklinks_toggle'))){
                             $$('.quicklinks_real').set('style', 'display:none');
                             $$('.quicklinks_fun').set('style', 'display:block');
                        }
        loginListener.loggedOut();
        var loginBar = $('login');
        if(loginBar.length > 0){
              //$('password').addEvent('focus', function(event){
          //  this.clone().set('value', '').setProperty('type','password').setProperty('id','password').injectAfter(this);
          //  this.dispose();
          //  $('password').focus();
          //});
          $('user').addEvent('focus', function(event){
            if(defaultUserText == $('user').get('value')){
              this.set('value', '');
            }
          });
          $('login').addEvent('submit', function(e) {
            if (typeof e != 'undefined') {e.stop();}
            if(defaultUserText != $('user').get('value')){
              $('signinLoader').setStyle('display','block');
                      $('signinForm').setStyle('display','none');
                      //$('loadingMessage').innerHTML = "Signing in...";
                      var lgnForm = this;
              console.log(' - Login Request Sent');
              new Asset.javascript('http://sports.williamhill.com/bet/'+obLang+'?action=GetXLoginForm&lang='+strLang+'&t=' + serverDate.getTime(), {
                onload: function(){
                    console.log(' - Response From Login Server - Auth: '+ WHX.authenticated);
                            if(WHX.authenticated == 'N'){
                    new Element('div',{html: WHX.data.obFormHidden}).inject(lgnForm ,'bottom');
                    // virtual languages redirect
                    var urlParts = window.location.href.split('?')
                    var baseUrl = urlParts[0];
                    var langPar = '';
                    if (typeof urlParts[1] != "undefined") {
                      // look for language parameter (l=xx)
                      var langParIndex = urlParts[1].indexOf('l=');
                      if (langParIndex >=0 && urlParts[1].length >= langParIndex+3) {
                        langPar = urlParts[1].substring(langParIndex, langParIndex+4);
                      }
                    }
                    var redirUrl = baseUrl + ((langPar != '') ? '?' + langPar : '');
                    new Element('input', {type: 'hidden', name: 'target_page', value: redirUrl}).inject(lgnForm , 'top');
                    Cookie.write("firstLogin", 0, {duration: 365, domain: '.williamhill.com', path: '/'});
                    lgnForm.submit();
                            }
                },
                onFailure: function(){
                  console.log(' - Login Failed ');
                }
              });
            }else{
              $('user').set('value', '');
              $('password').set('value', '');
            }
          });
            }
            if((events != undefined) && (events != 'undefined') && (typeof(events.callback) != 'undefined') && (events.callback != 'undefined')){events.callback.run();}
            $('signinLoader').setStyle('display','none');
                $('signinForm').setStyle('display','block');
                  }
                  if($chk($('bonusCheck'))) {document.getElementById("bonusCheck").onclick();}
      },
      onFailure: function(){
        console.log(' - Login Failed ');
      }
    });
  },
  rememberCheck: function() {
    if ($('remember_me').get('checked') == true) {
      $('remember_me_value').value = 1;
    }
    else {
      $('remember_me_value').value = -1;
    }
  },
  showSimple: function() {
    $('signinLoader').setStyle('display','none');
    $('signinError').setStyle('display','block');
  },
  getBalance: function() {
    var request = new Request({
      url: '/getBalance/',
      onComplete: function(jsonObj) {
        var loginObj = JSON.decode(jsonObj);
        if((loginObj != 'null') && (loginObj != null)) {
          if(loginObj.result == 'OK'){
            $('userBalance').innerHTML = loginObj.amount;
          }else{
            $('userBalance').innerHTML = 'Error';
          }
        }
      }
    }).send();
  },
  // poker End of Year Bonus
  eoyPoker: function() {
    if($chk($('eoy-bonus-poker'))){
      if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
        $('eoy-bonus-poker').innerHTML = "<p>You must be logged in</p>";
      }
      else {
        cust_auth = Cookie.read('cust_auth');
        //console.log('http://www.williamhill.com/index.php/cdn/poker-promo-json/'+WHX.data.obAccountNumber+'/'+cust_auth+'/');
        new Asset.javascript('http://www.williamhill.com/index.php/cdn/poker-eoy-json/'+WHX.data.obAccountNumber+'/'+cust_auth+'/', {
          onload: function(){
            if(typeof pkrEoyPromo=="undefined") {
              $('eoy-bonus-poker').innerHTML = "No data";
            }
            else {
              eoyPkrCount = 0;
              eoyPkrContent = "<div style='float:left;'>";
              switch(strLang){
                default:
                      case 'en':
                        eoyPkrContent += "<table border=\"1\"><tr><td style=\"background-color: #FF0000;\"><strong>Nickname</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Points Generated</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Expected Bonus (Total)</strong><br></td></tr>";
                        var totalText = "Total";
                        var noData = "There is currently no data for your account";
                      break;
                      case 'es':
                        eoyPkrContent += "<table border=\"1\"><tr><td style=\"background-color: #FF0000;\"><strong>Nickname</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Puntos Acumulados</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Bono Esperado (Total)</strong><br></td></tr>";
                        var totalText = "Total";
                        var noData = "No Data";
                      break;
                      case 'at':
                      case 'de':
                        eoyPkrContent += "<table border=\"1\"><tr><td style=\"background-color: #FF0000;\"><strong>Nickname</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Generierte Punkte</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Erwarteter Bonus (Gesamt)</strong><br></td></tr>";
                        var totalText = "Total";
                        var noData = "No Data";
                      break;
                      case 'el':
                        eoyPkrContent += "<table border=\"1\"><tr><td style=\"background-color: #FF0000;\"><strong>Πόντοι που Δημιουργήθηκαν</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Προσωνύμιο</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Αναμενόμενο Μπόνους (Σύνολο)</strong><br></td></tr>";
                        var totalText = "Total";
                        var noData = "No Data";
                      break;
                      case 'ru':
                        eoyPkrContent += "<table border=\"1\"><tr><td style=\"background-color: #FF0000;\"><strong>Никнейм</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Собранные очки</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Ожидаемый бонус (Всего)</strong><br></td></tr>";
                        var totalText = "Total";
                        var noData = "No Data";
                      break;
                      case 'fr':
                        eoyPkrContent += "<table border=\"1\"><tr><td style=\"background-color: #FF0000;\"><strong>Nom d’utilisateur</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Points Produits</strong><strong><span style=\"color: white;\"><br></span></strong></td><td style=\"background-color: #FF0000;\"><strong>Bonus Attendu (Total)</strong><br></td></tr>";
                        var totalText = "Total";
                        var noData = "No Data";
                      break;
                    }
              pkrEoyPromo.each(function(item2) {
                eoyPkrCount = 1;
                eoyPkrContent += "<tr><td>"+item2.nickname+"</td><td>"+item2.points+"</td><td>"+item2.bonus+"</td></tr>";
              });
              if(eoyPkrCount == 0) {
                eoyPkrContent += "<tr><td colspan=\"3\">No data</td></tr>";
              }
              eoyPkrContent += "</table>";
              $('eoy-bonus-poker').innerHTML = eoyPkrContent;
            }
          },
          onFailure: function(){
            //console.log(' - Content Request Failed ');
            $('eoy-bonus-poker').innerHTML = "Log in?";
          }
        });
      }
    }
  },
  pokerRS: function() {
    if($chk($('poker-room-school'))){
      cust_auth = Cookie.read('cust_auth');
      //console.log('http://www.williamhill.com/index.php/cdn/pokerRSJSON/');
      new Asset.javascript('http://www.williamhill.com/index.php/cdn/pokerRSJSON/?v1-01', {
        onload: function(){
          pokerRoomSchool.sort(sort_by('points', true, parseInt));
          var PRSplace;
          var PRSuser;
          var PRSnick;
          var PRSpoints;
          var PRScurrency;
          promoContent = "<div style='float:left;'>";
          switch(strLang){
            case 'ru':
              promoContent += "<div class='th'>Место</div><div class='th'>Прозвище</div><div class='th'>PRS Очки</div><div class='th'>Приз</div><div class='clearBoth'>&nbsp;</div>";
            break;
            default:
              promoContent += "<div class='th'>Place</div><div class='th'>Nickname</div><div class='th'>PRS Points</div><div class='th'>Prize</div><div class='clearBoth'>&nbsp;</div>";
            break;
          }
          promoCount = 0;
          pokerRoomSchool.each(function(item1) {
            if(item1.points > 0) {
              promoCount++;
              if(promoCount > 100) {return;}
              PRSplace = item1.place;
              PRSuser = item1.username;
              PRSnick = item1.nickname;
              PRSpoints = item1.points;
              PRSprize = item1.prize;
              PRSNprize = item1.nprize;
              PRScurrency = item1.currency;
              promoContent += "<div class='td'>"+promoCount+"</div><div class='td'>"+PRSnick+"</div><div class='td'>"+PRSpoints+"</div><div class='td'>$"+PRSprize+"</div><div class='clearBoth'>&nbsp;</div>";
            }
          });
          promoContent += "</div>";
          $('poker-room-school').innerHTML = promoContent;
        },
        onFailure: function(){
          console.log(' - Content Request Failed ');
          $('poker-room-school').innerHTML = "Log in?";
        }
      });
    }
  },
  // poker leaderboard
  promoWarriors: function() {
    if($chk($('poker-warriors'))){
      new Asset.javascript('http://www.williamhill.com/index.php/cdn/pokerWarriors/?id=2', {
        onload: function(){
          if(typeof Warriors=="undefined") {
            $('poker-warriors').innerHTML = "No data";
          }
          else {
            var xmasContent;
            warContent = "<div>";
            switch(strLang){
                    case 'en':
                      warContent += "<div class='th'>Rank</div><div class='th'>Nickname</div><div class='th'>Points</div><div class='clearBoth'>&nbsp;</div>";
                    break;
                    case 'es':
                      warContent += "<div class='th'>Rank</div><div class='th'>Nickname</div><div class='th'>Puntos</div><div class='clearBoth'>&nbsp;</div>";
                    break;
                    case 'fr':
                      warContent += "<div class='th'>Classement</div><div class='th'>Nom</div><div class='th'>Points</div><div class='clearBoth'>&nbsp;</div>";
                    break;
                    case 'el':
                      warContent += "<div class='th'>ΘΕΣΗ</div><div class='th'>ΠΑΡΑΤΣΟΥΚΛΙ</div><div class='th'>ΒΑΘΜΟΙ</div><div class='clearBoth'>&nbsp;</div>";
                    break;
                    case 'de':
                      warContent += "<div class='th'>Rang</div><div class='th'>Spierlername</div><div class='th'>Punkte</div><div class='clearBoth'>&nbsp;</div>";
                    break;
                    default:
                      warContent += "<div class='th'>Rank</div><div class='th'>Nickname</div><div class='th'>Points</div><div class='clearBoth'>&nbsp;</div>";
                    break;
                  }
            warCount = 0;
            Warriors.each(function(item1) {
              warContent += "<div class='td'>"+item1.place+"</div><div class='td'>"+item1.nickname+"</div><div class='td'>"+item1.Points+"</div><div class='clearBoth'>&nbsp;</div>";
              xmasCount=1;
            });
            if(warCount == 0) {
              warContent += "<div class='td2'>There is currently no data for your account</div><div class='clearBoth'>&nbsp;</div>";
            }
            warContent += "</div>";
            $('poker-warriors').innerHTML = warContent;
          }
        },
        onFailure: function(){
          $('poker-warriors').innerHTML = "Log in?";
        }
      });
    }
  },
  logOut: function(outUrl, outDest) {
    var myIFrame = new IFrame({
        src: 'http://gaskill.williamhill.com/logout.do',
        styles: {
            width: 1,
            height: 1,
            border: 'none'
        },
        events: {
            load: function(){}}
    });
    myIFrame.inject('footer', 'top');
    Cookie.write("cust_ssl_login", "", {duration: 30, domain: '.williamhill.com', path: '/'});
    var langPartLogout = '';

    // changed INC0116055
    wLoc = document.location.href;

    try{
      // Try to use window location to capture hashtags
      wLoc = insertParam(wLoc, "t", serverDate.getTime());
    }
    catch(Err){
      // something went wrong lets fallback to the ee url
      wLoc = outDest;
    }

    window.location = outUrl + '?action=DoLogout&target_page=' + whTrack.urlEncode(wLoc);
    /*
    console.log("outDest " + outDest);
    if (outDest.indexOf('?l=') >= 0) {
      // virtual language site
      var langPartIndex = outDest.indexOf('?l=');
      langPartLogout = outDest.substring(langPartIndex);
      outDest = outDest.substring(0, langPartIndex);
    }
    if(strLang != 'en' || langPartLogout != ''){outDest += strLang + '/index/' + langPartLogout;}
    var getIdentifier = (langPartLogout != '') ? '&' : '?';
    //console.log("REDIR: " + outDest + getIdentifier + "t=" + serverDate.getTime());
    window.location = outUrl + '?action=DoLogout&target_page=' + whTrack.urlEncode(outDest + getIdentifier + "t=" + serverDate.getTime());    */
  }
};
var loginSubscribers = [];
var loginListener = {
  loggedIn: function() {
    switch(document.body.id){
            case 'bingo_site':
              Cookie.write('bingo_npb_loggedin', '1', {path: '/'});
              // npb flutter HPTO reset
              var url = window.location.pathname;
              if (strLang == 'en') {
                var theClock = $$('#theServerTime');
          var currenttime = theClock.get('html');
          currenttime = currenttime[0];
          var serverDate = new Date(currenttime);
                var year = serverDate.getFullYear();
                var month = serverDate.getMonth();
                var weekday = serverDate.getDay();
                var hour = serverDate.getHours();
                console.log('time:' + hour );
                if (year == 2013 && month == 9){ //October 0-11
            var hpto = '22529-HPTO-V2';
            if ((weekday == 5 && hour > '1') || (weekday == 6 && hour < '1')){
              hpto = '50k-guaranteed-prize-nights-oct';
            }else{
              if (hour > '2' && hour < '12' ){
                hpto = 'free-speed-bingo-hour';
              }else if (hour >= '12' && hour < '20'){
                hpto = '1million-guaranteed-october';
              }else{
                hpto = '1-million-jackpot-slots-prize-draws-2013';
              }
            }
            $(document.body).setStyle('background','url("http://whdn.williamhill.com/cms/images/bingo/library/en/npo/'+hpto+'.jpg") no-repeat fixed center top #0392c7');
            if ($chk($('promolinkleft'))) $('promolinkleft').setAttribute('onclick','window.location.href="http://bingo.williamhill.com/promotions/this-months-specials/'+hpto+'"');
            if($chk($('promolinkright'))) $('promolinkright').setAttribute('onclick','window.location.href="http://bingo.williamhill.com/promotions/this-months-specials/'+hpto+'"');
          }
                if($('npbLayer') && $('featuredPanel')) {
            $('npbLayer').setStyle('display','none');
            $('featuredPanel').setStyle('display','inline');
          }
          if ($('crossSellStaticBanner_open')) {
            $('crossSellStaticBanner_open').setStyle('display', 'block');
          }
        }
        // npb flutter HPTO reset
              if ($chk($("loggedInMsg"))) $("loggedInMsg").setStyle('display', 'block');
              if ($chk($("joinNow"))) $("joinNow").setStyle('display', 'none');
              if (Cookie.read('bingoPlayed')=='1') {
                if ($chk($("miniFeatureOther"))){
                  if ($chk($("miniFeatureNPB"))) $("miniFeatureNPB").setStyle('display', 'none');
                  $("miniFeatureOther").setStyle('display', 'block');
                }
              }else {
                if ($chk($("miniFeatureNPB"))) $("miniFeatureNPB").setStyle('display', 'block');
              };
              if ($chk($("jobBox"))) {
                $("jobBox").setStyle('display', 'block');
              }
              if ($chk($("helpBox"))) {
                $("helpBox").setStyle('display', 'none');
              }
            break;
            case 'games_site':
              if ($chk($$("div.conversion_items_in"))){
                $$("div.conversion-banner").setStyle('display', 'none');
                $$("div.conversion_items_in").setStyle('display', 'block');
                $$("div.slideshow-nav").setStyle('display', 'block');
              }
            break;
            case 'vegas_site':
              banner_items_toShow = 'banner_items_in';
              if ($("banner_items_in") && ($("banner_items_in").getChildren()).length > 0
              && $('banner_items_play-in-shop').getStyle('display') != 'block'
              && $('banner_items_scratch-cards').getStyle('display') != 'block'
              && $('banner_items_jackpots').getStyle('display') != 'block'){
          var controller = new MainBannerController({
                  status: 'in',
                  cookiePrefix: 'vegas_main_banner_',
                  loggedinArea: 'banner_items_in',
                  loggedoutArea: 'banner_items_out',
                  buttonArea: 'exp_bar',
                  navArea: 'nav_'
              });
        }
        displayHPTO('in');
              if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'none');
            break;
            case 'liveDealer_site':
              if ($("banner_items_in") && ($("banner_items_in").getChildren()).length > 0){
          var controller = new MainBannerController({
                  status: 'in',
                  cookiePrefix: 'vegas_main_banner_',
                  loggedinArea: 'banner_items_in',
                  loggedoutArea: 'banner_items_out',
                  buttonArea: 'exp_bar',
                  navArea: 'nav_'
              });
        }
              if ($("logged-out")) {
                $("logged-out").setStyle('display', 'none');
              }
              if ($("logged-in")) {
                $("logged-in").setStyle('display', 'block');
              }
              if ($("introduction-button")) {
                ($("introduction-button").getChildren()[0]).set('text', 'Play Now');
                $("introduction-button").set('href', "javascript:gameNav.load('105','LD');");
              }
              if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'none');
            break;
            case 'casino_site' :
              loginSubscribers.forEach(function(sub) {
          //Notify subscribed functions of logged in state
                sub(true);
        });
              $$(".demo").each(function(item){
                item.setStyle('display', 'none');
              });
              // enable live chat link
              if ($chk($('liveChat'))){
                $("liveChat").setStyle('display', 'block');
              }
              if ($chk($('downloadLive'))){
                if (!$("joinLive")) {return;}
                $("joinLive").setStyle('display', 'none');
                $("downloadLive").setStyle('display', 'block');
              }
              if (typeof whContent !== 'undefined') {whContent.init('most-popular');}
                  if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'none');
              if ($chk($('downloadBtn'))){
                $("downloadBtn").setStyle('float', 'left');
              }

              // happy hour js - present the happy hour campaign
              jQuery(function($){showHappyHour($);});

              var browser=navigator.appName;
        var b_version=navigator.appVersion;
        var version=parseFloat(b_version);
        if (browser=="Microsoft Internet Explorer"){

        if (version <= 7) {casinoTicker.Search();}
        }
              casinoTicker.Search();
            break;
            case 'skill_site':
              if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'none');
              $("playNowBtn").setStyle('display', 'block');
            break;
            case 'financials_site':
        document.getElementById('financialsSignUpTeaserBtn').remove();
            break;
    }
  },
  loggedOut: function() {
    switch(document.body.id){
            case 'bingo_site':
              Cookie.dispose('bingo_npb_loggedin');
              if ($("loggedInMsg")) {
                $("loggedInMsg").setStyle('display', 'none');
                //if (strLang != 'en') {
                  $("joinNow").setStyle('display', 'block');
                //}
                $("miniFeatureNPB").setStyle('display', 'block');
              }
            break;
            case 'vegas_site':
              banner_items_toShow = 'banner_items_out';
              if ($("banner_items_out") && ($("banner_items_out").getChildren()).length > 0
              && $('banner_items_play-in-shop').getStyle('display') != 'block'
              && $('banner_items_scratch-cards').getStyle('display') != 'block'
              && $('banner_items_jackpots').getStyle('display') != 'block')
              {
                var controller = new MainBannerController({
                  status: 'out',
                  cookiePrefix: 'vegas_main_banner_',
                  loggedinArea: 'banner_items_in',
                  loggedoutArea: 'banner_items_out',
                  buttonArea: 'exp_bar',
                  navArea: 'nav_'
              });
              }
              $$(".demo").each(function(item){
                item.setStyle('display', 'none');
              });
              $$(".jackpotVegasDemo").each(function(item){
                item.setStyle('display', 'none');
              });
              $$(".promoAddDemo").each(function(item){
                item.setStyle('display', 'none');
              });
              $$(".also-see-box-demo").each(function(item){
                item.setStyle('display', 'none');
              });
              $$(".vegas-lp-demo-button").each(function(item){
                item.setStyle('display', 'none');
              });
              displayHPTO('out');
              if (!$("joinNowBtn")) {return;}

              $("joinNowBtn").setStyle('display', 'block');
            break;
            case 'casino_site':
              loginSubscribers.forEach(function(sub) {
          //Notify subscribed functions of logged in state
                sub(false);
        });
              $$(".demo").each(function(item){
                item.setStyle('display', 'none');
              });
              if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'block');
            break;
            case 'liveDealer_site':
              if ($("banner_items_out") && ($("banner_items_out").getChildren()).length > 0){
                var controller = new MainBannerController({
                  status: 'out',
                  cookiePrefix: 'vegas_main_banner_',
                  loggedinArea: 'banner_items_in',
                  loggedoutArea: 'banner_items_out',
                  buttonArea: 'exp_bar',
                  navArea: 'nav_'
              });
              }
              if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'block');
            break;
            case 'games_site':
              $$(".gamesDemoLink").each(function(item){item.addClass('hide');});
              $$(".playDemoLine").each(function(item){item.addClass('hide');});
              if (!$("joinNowBtn")) {return;}
              $("joinNowBtn").setStyle('display', 'block');
            break;
    }
  },
  addSubscriber: function(sub) {
    //Pass a function that gets called once logged in
        loginSubscribers.push(sub);
  }
};
//Product Specific
var scheduleToday = {
  init:function() {if(!$("scheduleTodayContent")){return;}
    scheduleToday.select('All', null);
  },
  select:function(gameType) {
    var content='';
    if (gameType=='All') {style="scheduleTodayGamesSelected";}
    else {style="";};
    content+='<ul><li><a class="'+style+'" href="javascript:scheduleToday.select(\'All\');">All</a></li>';
    var flip=true;
    for (i=0; i<gameTypes.length; i++) {
      flip=!flip;
      if (gameTypes[i]==gameType) {style="scheduleTodayGamesSelected";}
      else if (flip) {style="";}
      else {style="scheduleTodayGamesAlt";};
      content+="<li><a class=\""+style+"\" href=\"javascript:scheduleToday.select('"+gameTypes[i]+"');\">"+gameTypes[i]+"</a></li>";
    }
    content+='</ul>';
    $('scheduleTodayGames').innerHTML=content;
    content='';
    for (i=0; i<tournaments.length; i++) {
      if (gameType=='All' || gameType==tournaments[i][0]) {
        content+='<ul>';
        content+='<li class="scheduleTodayGamesCol2"><a href="javascript:scheduleToday.detail('+i+');">'+tournaments[i][1]+'</a></li>';
        content+='<li class="scheduleTodayGamesCol3">'+tournaments[i][0]+'</li>';
        content+='<li class="scheduleTodayGamesCol4">'+tournaments[i][2]+'</li>';
        content+='<li class="scheduleTodayGamesCol5">'+tournaments[i][3]+'</li>';
        content+='<li class="scheduleTodayGamesCol6"><a class="smallBlueButton whpoker-link" href="whpoker://htcmd:opentourbycode?code='+tournaments[i][10]+'"> <span><strong>'+regColText+'</strong></span> </a></li>';
        content+='</ul>';
      }
    }
    $('scheduleTodayContent').innerHTML=content;
  },
  detail:function(id) {
    var content='';
    $('scheduleTodayDetail0').innerHTML = tournaments[id][1];
    $('scheduleTodayDetail1').innerHTML = tournaments[id][4];
    $('scheduleTodayDetail2').innerHTML = tournaments[id][3];
    $('scheduleTodayDetail3').innerHTML = tournaments[id][5];
    $('scheduleTodayDetail4').innerHTML = tournaments[id][6];
    $('scheduleTodayDetail5').innerHTML = tournaments[id][7];
    $('scheduleTodayDetail6').innerHTML = tournaments[id][8];
    $('scheduleTodayDetail7').innerHTML = tournaments[id][9];
    $('scheduleTodayDetail').setStyle('display', 'block');
    window.location='#scheduleToday';
  }
}
var whAnnouncementScroll = {
  items:[],
  selected:0,
  init: function() {
    if($chk('#contentHeadText')){
      $$('#contentHeadText li').each(function(item, index){
        whAnnouncementScroll.items.push(item);
        item.style.display='none';
      })
      switch(whAnnouncementScroll.items.length){
        case 0:
          return;
          break;
        case 1:
          whAnnouncementScroll.items[0].style.display = 'block';
          break;
        default:
          whAnnouncementScroll.nextItem();
          break;
      }
    }
  },
  nextItem: function() {
    var t = 1000;   // ms
    var d = 100;  //px
    var pause = 4;
    var element = whAnnouncementScroll.items[whAnnouncementScroll.selected];
    element.setOpacity(0);
    element.style.display = 'block';
    var myFx = new Fx.Morph(element,{duration:t,transition: Fx.Transitions.Cubic.easeOut});
    myFx.start({
      'opacity': [0, 1]
    }).chain(
      // set time to wait until the item is faded out
      function(){
        (function() {
          myFx.start({
            'opacity': [1, 0]
          });
        }).delay(t*pause);
      },
      // begin the next item
      function(){
        element.style.display = 'none';
        whAnnouncementScroll.selected++;
        if (whAnnouncementScroll.selected == whAnnouncementScroll.items.length) { whAnnouncementScroll.selected = 0; }
        whAnnouncementScroll.nextItem();
      }
    );
  }
}
var whNewsScroll = {
  items:[],
  selected:0,
  init: function() {
    if($chk('#news_ticker')){
      $$('#news_ticker li').each(function(item, index){
        whNewsScroll.items.push(item);
        item.style.display='none';
      })
      switch(whNewsScroll.items.length){
        case 0:
          return;
          break;
        case 1:
          whNewsScroll.items[0].style.display = 'block';
          break;
        default:
          whNewsScroll.nextItem();
          break;
      }
    }
  },
  nextItem: function() {
    var t = 1000;   // ms
    var d = 20;   //px
    var pause = 3;
    var element = whNewsScroll.items[whNewsScroll.selected];
    element.setOpacity(0);
    element.style.display = 'block';
    var myFx = new Fx.Morph(element,{duration:t,transition: Fx.Transitions.Cubic.easeOut});
    myFx.start({
      'opacity': [0, 1],
      'margin-top':[d, 0]
    }).chain(
      // set time to wait until the item is faded out
      function(){
        (function() {
          myFx.start({
            'opacity': [1, 0],
            'margin-top':[0, -1*d]
          });
        }).delay(t*pause);
      },
      // begin the next item
      function(){
        element.style.display = 'none';
        whNewsScroll.selected++;
        if (whNewsScroll.selected == whNewsScroll.items.length) { whNewsScroll.selected = 0; }
        whNewsScroll.nextItem();
      }
    );
  }
}
var rewardClaimNow = {
  send: function(promo, errorMsg, reward, respId, multiple) {
    if(typeof(respId) === 'undefined' || respId == '') {
                   respId = 'claimNow';
                }
                // multiple claims for the same user/promotion (true|false)
                if(typeof(multiple) === 'undefined' || multiple == '') {
                   multiple = 'false';
                }
    if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
      $(respId).innerHTML = '<p class="errorMsg">You must log in to claim this promotion</p>';
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/poker-reward-claim/', data:'promo='+promo+'&reward='+reward+'&uid='+WHX.data.obAccountNumber+'&multiple='+multiple+'&n='+Math.random(),
      onRequest: function() {
        $(respId).innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $(respId).innerHTML = txt;
        if (promo != 'Points2token' && promo != 'Points2bonus' && promo != 'Points2cash' && promo != 'new_Points2token' && promo != 'new_Points2bonus' && promo != 'new_Points2cash' && (promo.indexOf('game_pred_line') === -1) ) {
          alert("All conversion requests are subject to William Hill Poker's approval. Please refer to our Terms & Conditions for further details");
        }
      },
      onFailure: function(){
        $(respId).innerHTML = 'Failed';
      }
    }).send();

  },
  noLoginSend: function(promo, successMsg, accNo) {
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/poker-reward-claim/', data:'promo='+promo+'&msg='+successMsg+'&uid='+accNo+'&n='+Math.random(),
      onRequest: function() {
        $("claimBtn").innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $("claimBtn").innerHTML = txt;
      },
      onFailure: function(){
        $("claimBtn").innerHTML = 'Failed';
      }
    }).send();
  }
}
var casinoClaimNow = {
  send: function(promo, hours) {
    if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
      $("claimNow").innerHTML = '<p class="errorMsg">You must log in to claim this promotion</p>';
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-now/', data:'promo='+promo+'&hours='+hours+'&uid='+WHX.data.obAccountNumber+'&n='+Math.random(),
      onRequest: function() {
        $("claimNow").innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $("claimNow").innerHTML = txt;
      },
      onFailure: function(){
        $("claimNow").innerHTML = 'Failed';
      }
    }).send();
  }
}
var promotionsClaimNow = {
  send: function(promo, errorMsg, successMsg) {
    if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
      $("claimNow").innerHTML = '<p class="errorMsg">'+errorMsg+'</p>';
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-now/', data:'promo='+promo+'&msg='+successMsg+'&uid='+WHX.data.obAccountNumber+'&n='+Math.random(),
      onRequest: function() {
        $("claimNow").innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $("claimNow").innerHTML = txt;
      },
      onFailure: function(){
        $("claimNow").innerHTML = 'Failed';
      }
    }).send();

  },
  noLoginSend: function(promo, successMsg, accNo) {
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-auto/', data:'promo='+promo+'&msg='+successMsg+'&uid='+accNo+'&n='+Math.random(),
      onRequest: function() {
        $("emailClaim").innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $("emailClaim").innerHTML = txt;
      },
      onFailure: function(){
        $("emailClaim").innerHTML = 'Failed';
      }
    }).send();
  }
}
var promotionsClaimNowBig = {
  send: function(promo, errorMsg, successMsg, hourMsg) {
    if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
      if ($("claimNowBig")) {
        $("claimNowBig").innerHTML = '<p class="errorMsg">'+errorMsg+'</p>';
      }
      if ($("claimBtn")) {
        $("claimBtn").innerHTML = '<p class="errorMsg">'+errorMsg+'</p>';
      }
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-now/', data:'promo='+promo+'&hours='+hourMsg+'&msg='+successMsg+'&uid='+WHX.data.obAccountNumber+'&n='+Math.random(),
      onRequest: function() {
        if ($("claimNowBig")) {
          $("claimNowBig").innerHTML = 'Sending claim...';
        }
        if ($("claimBtn")) {
          $("claimBtn").innerHTML = 'Sending claim...';
        }
      },
      onSuccess: function(txt){
        if ($("claimNowBig")) {
          $("claimNowBig").innerHTML = txt;
        }
        if ($("claimBtn")) {
          $("claimBtn").innerHTML = txt;
        }
        if($chk($('playNowButton')) && document.body.id == 'casino_site')
          $('playNowButton').setStyle('display','block');
      },
      onFailure: function(){
        if ($("claimNowBig")) {
          $("claimNowBig").innerHTML = 'Failed';
        }
        if ($("claimBtn")) {
          $("claimBtn").innerHTML = 'Failed';
        }
      }
    }).send();

  }
}

var promotionsClaimNowCasino = {
  send: function(promo, errorMsg, successMsg, hourMsg, gameCode) {
    if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
      if ($("claimNowBig")) {
        $("claimNowBig").innerHTML = '<p class="errorMsg">'+errorMsg+'</p>';
      }
      if ($("claimBtn")) {
        $("claimBtn").innerHTML = '<p class="errorMsg">'+errorMsg+'</p>';
      }
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-now/', data:'promo='+promo+'&hours='+hourMsg+'&msg='+successMsg+'&uid='+WHX.data.obAccountNumber+'&n='+Math.random(),
      onRequest: function() {
        if ($("claimNowBig")) {
          $("claimNowBig").innerHTML = 'Sending claim...';
        }
        if ($("claimBtn")) {
          $("claimBtn").innerHTML = 'Sending claim...';
        }
      },
      onSuccess: function(txt){
        if ($("claimNowBig")) {
          $("claimNowBig").innerHTML = txt;
        }
        if ($("claimBtn")) {
          $("claimBtn").innerHTML = txt;
        }
        var redirectUrl = 'http://casino.williamhill.com/';
        if (strLang != 'en') {
          redirectUrl += strLang + '/index/';
          var fakeLang = getURLParameter('l');
          if (typeof fakeLang !== "undefined" && fakeLang != null && fakeLang != 'at') {
            redirectUrl += '?l=' + fakeLang;
          }
        }
        if (typeof gameCode != 'undefined') {
          setTimeout("javascript:whLaunch.launchCasino('" + gameCode + "','','');",1500);
        } else {
          setTimeout("location.href = '" + redirectUrl + "';",1500);
        }
      },
      onFailure: function(){
        if ($("claimNowBig")) {
          $("claimNowBig").innerHTML = 'Failed';
        }
        if ($("claimBtn")) {
          $("claimBtn").innerHTML = 'Failed';
        }
      }
    }).send();

  },

  noLoginSend: function(promo, successMsg, accNo) {
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-auto/', data:'promo='+promo+'&msg='+successMsg+'&uid='+accNo+'&n='+Math.random(),
      onRequest: function() {
        $("emailClaim").innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $("emailClaim").innerHTML = txt;
        var redirectUrl = 'http://casino.williamhill.com/';
        if (strLang != 'en') {
          redirectUrl += strLang + '/index/';
        }
        if (typeof gameCode != 'undefined') {
          setTimeout("javascript:whLaunch.launchCasino('" + gameCode + "','','');",1500);
        } else {
          setTimeout("location.href = '" + redirectUrl + "';",1500);
        }
      },
      onFailure: function(){
        $("emailClaim").innerHTML = 'Failed';
      }
    }).send();
  }
}

var promotionsClaimNowBig2 = {
  send: function(promo, errorMsg, successMsg, hourMsg) {
    if(typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') {
      $("claimNowBig2").innerHTML = '<p class="errorMsg">'+errorMsg+'</p>';
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotions-claim-now/', data:'promo='+promo+'&hours='+hourMsg+'&msg='+successMsg+'&uid='+WHX.data.obAccountNumber+'&n='+Math.random(),
      onRequest: function() {
        $("claimNowBig2").innerHTML = 'Sending claim...';
      },
      onSuccess: function(txt){
        $("claimNowBig2").innerHTML = txt;
      },
      onFailure: function(){
        $("claimNowBig2").innerHTML = 'Failed';
      }
    }).send();
  }
}
var promotionsClaimNowMars = {
  send: function(promo, user, claimDiv) {
          claimDiv = (typeof(claimDiv) === 'undefined') ? 'claimNow' : claimDiv;
    if((typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined') && (user == undefined || user == '')) {
      $(claimDiv).innerHTML = '<p class="errorMsg">You must log in to claim</p>';
      return;
    }
    if (typeof(WHX) !== 'undefined' && typeof(WHX.data.obAccountNumber) !== 'undefined') user = WHX.data.obAccountNumber;
    var claimreq = new Request({
      method:'get',
      url:'/'+strLang+'/promotion-bonus/', data:'promo='+promo+'&uid='+user+'&n='+Math.random(),
      onRequest: function() {
        if ($(claimDiv)) {
          $(claimDiv).innerHTML = 'Sending request...';
        }
      },
      onSuccess: function(txt){
        if ($(claimDiv)) {
          $(claimDiv).innerHTML = txt;
        }
      },
      onFailure: function(){
        if ($(claimDiv)) {
          $(claimDiv).innerHTML = 'Failed';
        }
      }
    }).send();

  }
}
var promotionsClaimMars = {
  send: function(promo) {
    if((typeof(WHX) === 'undefined' || typeof(WHX.data.obAccountNumber) === 'undefined')) {
      $("bonusCheck").innerHTML = '<p class="errorMsg">You must log in to check your status</p>';
      return;
    }
    var claimreq = new Request({
      method:'get',
      url:'/promotion-bonus/', data:'promo='+promo+'&uid='+WHX.data.obAccountNumber+'&status&n='+Math.random(),
      onRequest: function() {
        if ($("bonusCheck")) {
          $("bonusCheck").innerHTML = 'Sending request...';
        }
      },
      onSuccess: function(txt){
        if ($("bonusCheck")) {
          $("bonusCheck").innerHTML = txt;
        }
      },
      onFailure: function(){
        if ($("bonusCheck")) {
          $("bonusCheck").innerHTML = 'Failed';
        }
      }
    }).send();

  }
}
var whNext3Races = {
  intServerTime:parseInt(strServerTime),
  init: function() {
    if($chk('#next3Races')){
      var count = 0;
      $$('#next3Races li').each(function(item, index){
        startTime = item.getElement('p.raceTime').innerHTML;
        if (startTime > whNext3Races.intServerTime && count<10) {
          item.style.display = 'block';
          count++;
        }
        else { item.style.display = 'none'; };
      });
      (function() {
        whNext3Races.intServerTime+=60;
        whNext3Races.init();
      }).delay(60000);
    }
  }
}
var whNews = {
  dataStore: new Hash.Cookie('newsStore', {path: '/', duration: 365}),
  dataRequest: new Hash(),
  init: function() {
    if($chk($('allSportsBtn'))){
      //Setup Sports Slide Nav
      var sportsNavSlide = new Fx.Slide('subNavSports');
      sportsNavSlide.hide(); sportsNavSlide.element.setStyle('display', 'block');

      $('allSportsBtn').addEvent('click', function(e){
        e.stop();
        sportsNavSlide.toggle();
      });
      whNews.dataStore.load();
      if(whNews.dataStore.getLength() == 0){
        sportsNavSlide.toggle();
        console.log(' - Setting Up Page for the first time');
        switch (strLang)
        {
        case 'fr':
          whNews.dataStore.extend({
              'selectedSports': [
            {'id': 'football', 'name': 'Football', 'layout':[
              {'view': 'newsImgList', 'content': 'Récent'},
              {'view': 'newsSingle', 'content': 'Ce qui Figure'},
              {'view': 'newsImgList', 'content': 'Populaire'}
            ]}
              ]
          });
        break;
        case 'es':
          whNews.dataStore.extend({
              'selectedSports': [
            {'id': 'football', 'name': 'Fútbol', 'layout':[
              {'view': 'newsImgList', 'content': 'Recientes'},
              {'view': 'newsSingle', 'content': 'Destacadas'},
              {'view': 'newsImgList', 'content': 'Populares'}
            ]}
              ]
          });
        break;
        case 'pl':
          whNews.dataStore.extend({
              'selectedSports': [
            {'id': 'ogolne', 'name': 'Ogólne', 'layout':[
              {'view': 'newsImgList', 'content': 'Latest'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsImgList', 'content': 'Popular'}
            ]}
              ]
          });
        break;
        default:
          whNews.dataStore.extend({
              'selectedSports': [
            {'id': 'horse-racing', 'name': 'Horse Racing', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsImgList', 'content': 'Trackside Live'}
            ]},
            {'id': '2010-cheltenham-festival', 'name': 'Cheltenham 2010', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsImgList', 'content': 'Popular'}
            ]},
            {'id': 'football', 'name': 'Football', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsImgList', 'content': 'Popular'}
            ]},
            {'id': '2010-world-cup', 'name': '2010 World Cup', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsImgList', 'content': 'Popular'}
            ]},
            {'id': 'tennis', 'name': 'Tennis', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsImgList', 'content': 'Popular'}
            ]},
            {'id': 'golf', 'name': 'Golf', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsList', 'content': 'Popular'}
            ]},
            {'id': 'cricket', 'name': 'Cricket', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsList', 'content': 'Popular'}
            ]},
            {'id': 'radio', 'name': 'Radio', 'layout':[
              {'view': 'newsImgList', 'content': 'Recent'},
              {'view': 'newsSingle', 'content': 'Featured'},
              {'view': 'newsList', 'content': 'Popular'}
            ]}
              ]
          });
        }
      }
      //Setup Sports Inputs
      $$('#subNavSports input').each(function(input, index){
        input.checked = false;
        input.addEvent('change', function(e){
          var chkCount = $('subNavSports').getElements('input[checked]').length;
          var dataArray = whNews.dataStore.get('selectedSports');
          if(chkCount >= 1){
            if(this.checked){
              //Add
              var sportId = input.get('name').split('_')[1];
              var sportName = input.getParent().getElement('a').get('text');
              switch (strLang)
              {
              case 'fr':
                dataArray.include({'id' : sportId, 'name': sportName, 'layout':[
                  {'view': 'newsImgList', 'content': 'Récent'},
                  {'view': 'newsSingle', 'content': 'Ce qui Figure'},
                  {'view': 'newsList', 'content': 'Populaire'}
                ]});
              break;
              case 'es':
                dataArray.include({'id' : sportId, 'name': sportName, 'layout':[
                  {'view': 'newsImgList', 'content': 'Recientes'},
                  {'view': 'newsSingle', 'content': 'Destacadas'},
                  {'view': 'newsList', 'content': 'Populares'}
                ]});
              break;
              default:
                dataArray.include({'id' : sportId, 'name': sportName, 'layout':[
                  {'view': 'newsImgList', 'content': 'Recent'},
                  {'view': 'newsSingle', 'content': 'Featured'},
                  {'view': 'newsList', 'content': 'Popular'}
                ]});
              }
              whNews.addTab(dataArray.getLast());
              if($('newsHolder') != null){whNews.addPanel(dataArray.getLast());}
            }else{
              //Remove
              dataArray.each(function(item, index){
                if(item.id == input.get('name').split('_')[1]){
                  dataArray.splice(index, 1);
                  if($('newsHolder') != null){$('panel_'+item.id).destroy();}
                  $('subnav_'+item.id).destroy();
                }
              });
            }
            $$('#subNavSports input').each(function(input, index){
              if(chkCount > 7 && !input.checked){
                input.disabled = true;
              }else{
                input.disabled = false;
              }
            });
            whNews.dataStore.set('selectedSports', dataArray);
          }else{
            this.checked = true;
          }
        });
      });
      //News Homepage Navigation
      whNews.dataStore.get('selectedSports').each(function(item, index){
        if((item.id!='2010-cheltenham-festival') && (item.id!='2010-world-cup')) {
          $('subNavSports').getElement('input[name=sport_'+item.id+']').checked = true;
          whNews.addTab(item);
          if($('feature') != null){whNews.addPanel(item);}
        }
      });
      var sort = new Sortables('ul#newsHolder', {
        handle: 'div.newsAreaControl a',
        constrain: true,
        clone: true,
        opacity: 0.1,
        revert: false,
        snap: 0,
        onComplete: function(){
          var serializeFunction = function(el) { return el; };
          var orderTxt = sort.serialize(serializeFunction);
          //Match Arrays
          whNews.dataStore.get('selectedSports').sort(function(a, b){
            var aNum = 0; var bNum = 0;
            orderTxt.each(function(el, index){
              if(el.id.split('_')[1] == a.id) aNum = index+1;
              if(el.id.split('_')[1] == b.id) bNum = index+1;
            });
            return  aNum - bNum;
          })
          whNews.dataStore.save();
        }
      });
    }
  },
  addTab: function(item){
    if(strLang=='en') {strUrlLang='/';}
    new Element('li', {
        'id': 'subnav_'+item.id,
        'html': '<a href="'+strUrlLang+'c/'+item.id+'/">'+item.name+'</a>'
    }).inject($('selectedSports'), 'bottom');
  },
  addPanel: function(item){
    var panel = new Element('li', {
        'class': 'newsArea',
        'id': 'panel_' + item.id,
        'html': '<div class="newsAreaControl">' +
          '<a href="#" title="Move">Move</a>' +
        '</div>' +
        '<div class="articleHeader"><h2><a href="'+strUrlLang+'c/'+item.id+'/">'+item.name+'</a></h2><div class="newsTopBlue">&nbsp;</div></div>' +
        '<div class="newsAreaInner">' +
          '<div class="block0 newsBlockHolder"><h3>Loading...</h3><div class="newsBlockControl"><a href="#" class="newsMore">Edit</a></div><div class="editDD"><div class="top">&nbsp;</div><div class="list">&nbsp;</div></div></div>' +
          '<div class="block1 newsBlockHolder"><h3>Loading...</h3><div class="newsBlockControl"><a href="#" class="newsMore">Edit</a></div><div class="editDD"><div class="top">&nbsp;</div><div class="list">&nbsp;</div></div></div>' +
          '<div class="block2 newsBlockHolder"><h3>Loading...</h3><div class="newsBlockControl"><a href="#" class="newsMore">Edit</a></div><div class="editDD"><div class="top">&nbsp;</div><div class="list">&nbsp;</div></div></div>' +
        '</div>' +
        '</div>' +
        '<div class="newsTail">&nbsp;</div>'
    });
    var newPanel = panel.inject($('newsHolder'), 'bottom');
    var delay = 1000;
    item.layout.each(function(layout, index){
      whNews.requestContent(newPanel, 'block'+index, item.id, layout.view, layout.content);
    });
    panel.getElements('.newsBlockHolder').each(function(block, blockindex){
      block.addEvents({
          'mouseover': function(){
              this.getElement('.newsBlockControl').setStyle('display', 'block');
          },
          'mouseleave': function(){
              this.getElement('.newsBlockControl').setStyle('display', 'none');
              new Fx.Morph(this.getElement('.editDD'), {duration: 300, transition: Fx.Transitions.Quad.easeIn}).start({
                'margin-top': 23,
                  'opacity': 0
              });
          }
      });
      block.getElement('.newsBlockControl a').addEvents({
          'click': function(event){
            event.stop();
            var dd = block.getElement('.editDD')
            dd.setStyle('display', 'block');
            if(dd.getElement('ul') == null){
              if((item.id == 'horse-racing') && (strLang == 'en') && (blockindex== '2')){
                dd.setStyle('display', 'none');
              }else{
                switch (strLang)
              {
              case 'fr':
                    new Element('ul', {
                      'html': '<li><a href="#"><span class="newsSingle">Article Simple</span></a></li>' +
                        '<li><a href="#"><span class="newsImgGrid">Le Grid de l&#39;Image</span></a></li>' +
                        '<li><a href="#"><span class="newsImgList">Liste d&#39;Image</span></a></li>' +
                        '<li><a href="#"><span class="newsList">Liste Simple</span></a></li>'
                    }).inject(dd.getElement('.list'), 'top');
                  break;
                  case 'es':
                    new Element('ul', {
                      'html': '<li><a href="#"><span class="newsSingle">ArtÃ­culo individual</span></a></li>' +
                        '<li><a href="#"><span class="newsImgGrid">CuadrÃ­cula de imÃ¡genes</span></a></li>' +
                        '<li><a href="#"><span class="newsImgList">Lista de imÃ¡genes</span></a></li>' +
                        '<li><a href="#"><span class="newsList">Lista simple</span></a></li>'
                    }).inject(dd.getElement('.list'), 'top');
                  break;
                  default:
                    new Element('ul', {
                      'html': '<li><a href="#"><span class="newsSingle">Single Article</span></a></li>' +
                        '<li><a href="#"><span class="newsImgGrid">Image Grid</span></a></li>' +
                        '<li><a href="#"><span class="newsImgList">Image List</span></a></li>' +
                        '<li><a href="#"><span class="newsList">Simple List</span></a></li>'
                    }).inject(dd.getElement('.list'), 'top');
                  break;
                  }
              }
            }
            dd.getElements('a').each(function(option, index){
              option.addEvents({
                'click': function(event){
                  event.stop();
                  whNews.dataStore.get('selectedSports').every(function(filter, index){
                  if(item.id == filter.id){
                    item.layout[blockindex].view = option.getElement('span').get('class');
                whNews.dataStore.save();
                  }
              });
                  whNews.requestContent(panel, block.get('class').split(' ')[0], item.id, option.getElement('span').get('class'), block.getElement('h3').get('text'));
                }
              });
            });
            new Fx.Morph(block.getElement('.editDD'), {duration: 300, transition: Fx.Transitions.Quad.easeIn}).start({
                'margin-top': 0,
                  'opacity': 1
              });
          }
      });
    });
  },
  clickclear: function(thisfield, defaulttext) {
    if (thisfield.value == defaulttext) {
      thisfield.value = "";
    }
  },
  clickrecall: function(thisfield, defaulttext) {
    if (thisfield.value == "") {
      thisfield.value = defaulttext;
    }
  },
  requestContent: function(panel, col, id, view, content){
    var data = panel.getElement('div.'+col).getElement('div.data');
    if($chk(data)){data.dispose();}
    if((id == 'horse-racing') && (strLang == 'en') && (col == 'block2')){
      Element('div', {'html': '', 'id': 'trackside-live', 'class': 'data'}).inject(panel.getElement('div.'+col), 'bottom');
      panel.getElement('div.'+col+' h3').set('text', content);
      whNews.dataRequest.erase(strLang+'-'+view+id+content);
    }
    else {
      new Asset.javascript('http://whdn.williamhill.com/index.php/cdn/'+view+'/'+strLang+'/'+id+'/'+content+'/?v=1', {
        onload: function(){
          //en-newsSinglehorse-racingFeatured
              Element('div', {'html': whNews.dataRequest.get(strLang+'-'+view+id+content), 'class': 'data'}).inject(panel.getElement('div.'+col), 'bottom');
              panel.getElement('div.'+col+' h3').set('text', content);
              whNews.dataRequest.erase(strLang+'-'+view+id+content)
        },
        onFailure: function(){
          console.log(' - Content Request Failed ');
        }
      });
    }
  },
  loadPartial: function(id, view) {
    new Asset.javascript('http://whdn.williamhill.com/index.php/cdn/'+view+'/'+strLang+'/?v=4', {
      onload: function(){
        console.log('loaded ' + id + ' - ' + view);
            Element('div', {'html': whNews.dataRequest.get(id)}).inject($(id), 'bottom');
            whNews.dataRequest.erase(id);
      },
      onFailure: function(){
        console.log(' - News Partial Content Request Failed ');
      }
    });
  }
}
// Class for controlling MiniFeed
var miniFeed = {
  // options
  right     : 0,
  slideDistance : 80,
  slideDuration : 200,
  counter   : 0,
  clicks    : 0,
  visibleItems  : 6,
  selectedItem  : '',
  init: function() {
    var items = $$('#scroller li');
    // Count Items
    items.each(function() {
      miniFeed.counter ++;
    });
    // Compensate for the items in view
    miniFeed.counter = (miniFeed.counter - miniFeed.visibleItems);
    // If theres 6 or less Items
    if (miniFeed.counter <= 0) {
      $$('#r_arrow').setStyle('display', 'none');
      $$('#l_arrow').setStyle('display', 'none');
    }else{
    // If theres more than 6 Items
    // Disable/ Enable Arrows
      if (miniFeed.clicks <= 0) {
        $$('#l_arrow').setStyle('opacity', '0.4');
      }else{
        $$('#l_arrow').setStyle('opacity', '1.0');
      }
      if (miniFeed.clicks == miniFeed.counter) {
        $$('#r_arrow').setStyle('opacity', '0.4');
      }else{
        $$('#r_arrow').setStyle('opacity', '1.0');
      }
      // Easing Object
      var EaseTransition = new Fx.Transition(Fx.Transitions.Quad, 999);
      // Tween Setup
      $('scroller').set('tween', { duration: miniFeed.slideDuration, transition: EaseTransition.easeOut });
      // Hover Action
      $$('#scroller li a').addEvent('mouseenter', function() {
        var myFx = new Fx.Tween(this);
        myFx.set('opacity', .5);
        myFx.start('opacity', 1);
      });
      // Right
      $('r_arrow').addEvent('click', function(e) {
        e.stop();
        if (miniFeed.clicks < miniFeed.counter) {
          miniFeed.clicks ++;
          miniFeed.right = (miniFeed.slideDistance + miniFeed.right);
          $('scroller').tween('right', miniFeed.right);
        }else{
          miniFeed.clicks = miniFeed.counter;
        }
        // Hide/ Show Arrows
        if (miniFeed.clicks == miniFeed.counter) {
          $$('#r_arrow').setStyle('opacity', '0.4');
        }
        if (miniFeed.clicks > 0) {
          $$('#l_arrow').setStyle('opacity', '1.0');
        }
      });
      // Left
      $('l_arrow').addEvent('click', function(e) {
        e.stop();
        if (miniFeed.clicks > 0) {
          $$('#l_arrow').setStyle('display', 'block');
          miniFeed.clicks --;
          miniFeed.right = (miniFeed.right - miniFeed.slideDistance);
          $('scroller').tween('right', miniFeed.right);
        }else{
          miniFeed.clicks = 0;
        }
        if (miniFeed.clicks < miniFeed.counter) {
          $$('#r_arrow').setStyle('opacity', '1.0');
        }
        if (miniFeed.clicks == 0) {
          $$('#l_arrow').setStyle('opacity', '0.4');
        }
      });

    }
    // Add Select Arrow
    $$('#scroller li a').addEvent('click', function(e) {
      // If we are on the bingo site, and the games already open,
      // then we dont want to re-open it.
      $$('#scroller li a').setStyle('background-position', 'top left');
      $(this).setStyle('background-position', '0 -57px');
    });
  },
  clearArrows: function() {
    var items   = $$('#scroller li a');
    items.each(function(item) {
      item.setStyle('background-position', 'top left');
    });
  },
  scrollTo: function (gameCode) {
    var gameId    = 'game-'+gameCode;
    var element   = $(gameId);
    var count   = 0;
    var counter   = 0;
    var right   = 0;
    var items   = $$('#scroller li a');
    miniFeed.selectedItem = gameCode;
    if (gameCode) {
      if ($chk(element)) {
        items.each(function(item) {
          counter ++;
          if (item.id == gameId) {
            if (counter > miniFeed.visibleItems) {
              miniFeed.clicks = counter - miniFeed.visibleItems;
            }
            count = counter;
          }
          // Take away the arrows
          item.setStyle('background-position', '0 0');
        });
        // Add the arrow
        element.setStyle('background-position', '0 -57px');
        if (count < miniFeed.visibleItems) {
          // If its in View
          $$('#l_arrow').setStyle('opacity', '0.4');
          if (counter <= miniFeed.visibleItems) {
            $$('#r_arrow').setStyle('opacity', '0.4');
          }else{
            $$('#r_arrow').setStyle('opacity', '1.0');
          }
          miniFeed.right  = 0;
          miniFeed.clicks = 0;
        }
        if (count == counter) {
          if (miniFeed.clicks == 0) {
            // If its not in the minifeed
            $$('#r_arrow').setStyle('opacity', '0.4');
            $$('#l_arrow').setStyle('opacity', '1.0');
          }else{
            // If its the last entry
            $$('#l_arrow').setStyle('opacity', '1.0');
            $$('#r_arrow').setStyle('opacity', '0.4');
            miniFeed.right  = miniFeed.slideDistance * (count - miniFeed.visibleItems);
            miniFeed.clicks =  counter - miniFeed.visibleItems;
          }
        }
        if (count > miniFeed.visibleItems) {
          // If its out of view
          miniFeed.right = miniFeed.slideDistance * (count - miniFeed.visibleItems);
          $$('#l_arrow').setStyle('opacity', '1.0');
          $$('#r_arrow').setStyle('opacity', '1.0');
        }
        // Set Right Location
        $('scroller').setStyle('right', miniFeed.right+'px');

      }else{
        $$('#l_arrow').setStyle('opacity', '0.4');
      }
    }
  }
};
var ScrollSidebar = new Class({
  Implements: [Options],
  options: {
    offsets: { x:0, y:0 },
    mode: 'vertical',
    positionVertical: 'top',
    positionHorizontal: 'right',
    speed: 300
  },
  initialize: function(menu,options) {
    /* initial options */
    //console.log(menu);
    this.setOptions(options);
    this.menu = $(menu);
    this.move = this.options.mode == 'vertical' ? 'y' : 'x';
    this.property = this.move == 'y' ? 'positionVertical' : 'positionHorizontal';
    /* ensure a few things */
    var css = { position: 'relative', display:'block' };
    css[this.options.positionVertical] = this.options.offsets.y;
    css[this.options.positionHorizontal] = this.options.offsets.x;
    this.menu.setStyles(css).set('tween',{ duration: this.options.speed });
    /* start listening */
    this.startListeners();
  },
  startListeners: function() {
    var action = function() {
      var enableScroll = true;
      if ($('newQuickLinks')) {
        tempH = $('newQuickLinks').getPosition();
      }
      if ($('news_ticker')) {
        tempH = $('news_ticker').getPosition();
      }
      var tempS = $(document.body).getScroll()[this.move] + this.options.offsets[this.move];
      var tempT = tempS+379-51;
      var sPixels = 149;
      var hPixels = 529;
      if (document.body.id == 'casino_site'){
        var tempT = tempS+381;
        sPixels = 350;
        //hPixels 38px to Tell us waht you think button
        hPixels = 652+50+38;
        //enableScroll = false;
      }
      if (document.body.id == 'vegas_site'){
        var tempT = tempS+750;
        sPixels = 350;
        var leftBlockHeight = $('productsLeftBlock').getSize().y;
        var productsBlockHeight = $('products').getSize().y;
        // disable menu scrolling if products box contains only 3 lines (height: 450px)
        if (productsBlockHeight <= 450) { enableScroll = false; }
        //hPixels 38px to Tell us waht you think button
        if ($('banner_items_in') && $('banner_items_out') && ($('banner_items_in').getStyle('display') == 'block' || $('banner_items_out').getStyle('display') == 'block')) {
                        hPixels = leftBlockHeight + 400;
                    } else {
                        hPixels = leftBlockHeight + 262;
                    }
      }
      if (enableScroll) {
        if((tempT < tempH.y) && (tempS > sPixels)) {
          //console.log($(document.body).getScroll()[this.move] + this.options.offsets[this.move])
          tempD = tempS - sPixels ;
          this.setDivPosition(tempD);
          //console.log(this);
          //this.menu.setStyle('top',tempD);
        }
        if(tempS < sPixels) {this.setDivPosition(0);}
        if(tempT > tempH.y) {
          this.setDivPosition(tempH.y - hPixels );
        }
      }
    }.bind(this);
    window.addEvent('scroll',action);
    window.addEvent('load',action);
  },
  setDivPosition: function(move) {
    this.menu.tween(this.options[this.property],move);
    return this;
  }
});
var banner_items_toShow = '';
var gameNav = {
  init: new Class({
      initialize: function(options) {
        if($chk($('productsContainer'))){
      var cats = [];
      var catCount = 0;
      var catArr = $$('#category li a');
      catArr.each(function(item, index){
        var hashTitle = window.location.hash.substring(1);
        cats.push(item.id);
        if(hashTitle != '' && hashTitle != undefined) {
          hashTitle = 'nav-'+hashTitle;
          setTimeout(function(){
            window.scrollTo(0, 0);
          },100)
          if(item.get('id') == hashTitle) {
            item.addClass('sel');
            gameNav.leftTabs(item.id, cats);
            catCount = 1;
          }
        }
        else {
          if(index == 0){
            item.addClass('sel');
            var tempCat = item.get('id').substring(4);
            if($chk($(tempCat))){
              $(tempCat).setStyle('display', 'block');
            }
            if($chk($('page-'+tempCat))) {
              $('pagingHolder').setStyle('display','block');
              $$('#pagingHolder div').each(function(item2) {item2.setStyle('display','none');});
              $('page-'+tempCat).setStyle('display','block');
              pageBlock = $$('#page-'+tempCat+' a');
              gameBlock = $$('#' + tempCat + ' li');
              pageBlock.each(function(item, id) {
                item.addEvent('click', function(event){
                  gameNav.paging(gameBlock, pageBlock, item, item.get('html'));
                });
              });
            }
            else {
              if($chk($('pagingHolderDef'))) {$('pagingHolderDef').setStyle('display','block');}
            }
            gameNav.leftTabs(item.id, cats);
            catCount = 1;
          }
        }
        item.addEvent('click', function(event) {
          event.stop();
          gameNav.leftTabs(item.id, cats);
          window.scrollTo(0, 0);
        });
        checker = index+1;
        if((catArr.length == checker) && (catCount == 0)) {
          gameNav.leftTabs(catArr[0].id, cats);
        }
      });
        }
        if($chk($('miniLobby'))){
      var cats = [];
      try{
        if($chk($('bingo_minilobby'))){
          var gameCode = getQueryVariable("gameCode");
        }else if ($chk($('games_minilobby'))){
          var gameCode = window.location.hash.substring(1);
        }else{
          var gameCode = window.location.hash.substring(1,3);
        }
      }catch(e){
        var gameCode = 'R2';
      }
      console.log(' - Game Code: ' + gameCode);
      if(gameCode == null){gameCode = 'R2';}
      $$('#gameNav li').each(function(item, index){
        if(item.id.split('#')[0] == 'game'){
          cats.push(item.id);
          item.addEvent('click', function(event){
            event.stop();
            var sel = this.id;
            cats.each(function(cat, index){
              if(sel == cat){
                $(cat).addClass('sel');
                gameNav.load($(cat).id.split('#')[1], 'ML')
              }else{$(cat).removeClass('sel');}
            });
          });
          item.addEvent('mouseover', function(event){
            var sel = this.id;
            var myFx = new Fx.Tween(sel);
            myFx.set('opacity', .5);
            myFx.start('opacity', 1);
          });
        }
      });
      var found = 0;
      cats.each(function(cat, index){
        if($(cat).id.split('#')[1] == gameCode){
          found++;
          $(cat).addClass('sel');
          gameNav.load($(cat).id.split('#')[1], 'ML')
        }
      });
      if(found == 0 ){
        gameNav.load(gameCode, 'ML');
      }
         }
         if($chk($('newQuickLinksTabs'))){
          $$('#newQuickLinksTabs a').each(function(item, index){
            item.addEvent('click', function(event){gameNav.whShowHideQuick(item.get('class'));});
          });
         }
      }
  }),
  whShowHideQuick: function(tempClass) {
    $$('#newQuickLinksTabs a').each(function(game, index){
      if(game.get('class') == tempClass) {
        game.getParent('li').set('id', 'selectedQLtab');
      }
      else {game.getParent('li').removeProperty('id');}
    });
    newId = 'quick-'+tempClass.replace('Links','');
    console.log(newId);
    $$('#newQuickLinksCtnt div').each(function(game, index){
      if(game.get('id') == newId) {
        game.setStyle('display', 'block');
      }
      else {
        game.setStyle('display', 'none');
      }
    });
  },
  paging: function(listId, butt, buttC, pageNo) {
    //console.log(buttC);
    if((buttC.get('class').test('next')) || (buttC.get('class').test('normal'))) {
      //console.log(pageNo);
      switch(pageNo){
        case '2': pageSel = 'Two'; break;
        case '3': pageSel = 'Three'; break;
        case '4': pageSel = 'Four'; break;
        case '5': pageSel = 'Five'; break;
        case '6': pageSel = 'Six'; break;
        case '7': pageSel = 'Seven'; break;
        default: pageSel = 'One'; break;
      }

      var catN = listId[0].getParent().get('id');
      //console.log(pageSel);
      swapList = $$('#' + catN + ' li.'+pageSel);
      listId.setStyle('display', 'none');
      swapList.each(function(itemGame, index2) {
        if(itemGame.getStyle('display') == 'none') {pageChange=0;} else {pageChange=1;}
        if(pageChange == 0) {(function(){gameNav.opaGames(itemGame);}).delay(index2*100);
        }
      });

      butt.each(function(item, id) {
        if(item.get('html') == buttC.get('html')) {
          item.set('class', 'pagingbtn selected');
        }
        else {
          if(id == 0) {
            item.set('class', 'pagingbtn next');
          }
          else {
            item.set('class', 'pagingbtn normal');
          }
        }
      });
    }
  },
  conversionBanner : function() {
    if ( typeof(WHX) !== 'undefined') {
      if ( !!WHX.authenticated && WHX.authenticated == 'Y' ) {
        var hide = Cookie.read('hide_conversion_banner');
        if ( hide != null ) {
          $$('div.conversion-banner').each(function(el){el.setStyle('display','none');});
        }
        $$('.gameBox a').each(function(item, index){
          item.addEvent('click', function(event){
            if( hide == null ) {
              Cookie.write('hide_conversion_banner', '1', {duration: 365, domain: '.williamhill.com', path: '/'});
            }
          });
        });
      }
    }
  },
  opaGames: function(game) {
    var myFx = new Fx.Tween(game);
        myFx.set('opacity', 0);
        game.setStyle('display', 'block');
                myFx.start('opacity', 1);
  },
  gamesPromoClose: function(cat) {
    if(Cookie.read('fogPlayer')!=1) {
      var tempBox = $(cat).getParent().getParent().get('id');
      if($$('#' + tempBox + ' .gameBoxFeatured').length > 1) {
        $$('#' + tempBox + ' .gameBoxFeatured')[0].setStyle('display', 'none');
        $$('#' + tempBox + ' .gameBoxFeatured')[1].setStyle('display', 'block');
      }
      else {
        $(cat).getParent().setStyle('display', 'none');
      }
    }else{
      var tempBox = $(cat).getParent().getParent().get('id');
      if($$('#' + tempBox + ' .gameBoxFeatured').length > 1) {
        $$('#' + tempBox + ' .gameBoxFeatured')[1].setStyle('display', 'none');
      }
      Cookie.write("fogPlayer2", "1", {duration: 365, domain: '.williamhill.com', path: '/'});
    }
    Cookie.write("fogPlayer", "1", {duration: 365, domain: '.williamhill.com', path: '/'});
  },
  leftTabs: function(itemId, cats) {
    var sel = itemId;
    var pageCheck = '';
    var changed = 0;

    // vegas xsell banners available only for favourite category
    if($chk($('games_xsell'))) {
      if (itemId == 'nav-favourite') {$('games_xsell').setStyle('display','block');} else {$('games_xsell').setStyle('display','none');}
    }
                if ($chk($('banner_items_out'))){
                  if ($('banner_items_in').getStyle('display') == 'block')  banner_items_toShow = 'banner_items_in';
                  if ($('banner_items_out').getStyle('display') == 'block') banner_items_toShow = 'banner_items_out';
                  $('banner_items_in').setStyle('display', 'none');
                  $('banner_items_out').setStyle('display', 'none');
                }
    cats.each(function(cat, index){
      var tempCat = cat.substring(4);
      if(sel == cat){
              if (tempCat == 'scratch-cards' || tempCat == 'jackpots') {
                $$('.contentHead').setStyle('display', 'none');
                $$('.slideshow-nav').setStyle('display', 'none');
                                        $('banner_items_' + tempCat).setStyle('display', 'block');
        }
        else if (tempCat == 'play-in-shop') {
          $$('.contentHead').setStyle('display', 'none');
          $$('.slideshow-nav').setStyle('display', 'none');
                $('nav_out_play_shop').setStyle('display', 'block');
                                        $('banner_items_' + tempCat).setStyle('display', 'block');
        }else {
                                        if ($chk($('banner_items_out'))){
                                          $$('.staticBanner').setStyle('display', 'none');
                                          if (banner_items_toShow != ''){
                                              $$('.slideshow-nav').setStyle('display', 'block');
                                              $(banner_items_toShow).setStyle('display', 'block')
                                          };
                                        }
              }
        if (sel == 'calendar'){
          location.href = $('calendar').href;
        }
        if($chk($('pagingHolder'))){
          $(cat).addClass('sel');
          if(sel != 'nav-favourite' && window.location.hash != '')
            window.location.hash = sel.replace('nav-', '');
          gameBlock = $$('#' + tempCat + ' li');

          if($(tempCat).get('class').test('pages')) {
            if($chk($('page-'+tempCat))) {
              $('pagingHolder').setStyle('display','block');
              if($chk($('pagingHolderDef'))) {$('pagingHolderDef').setStyle('display','none');}
              $$('#pagingHolder div').each(function(item) {item.setStyle('display','none');});
              $('page-'+tempCat).setStyle('display','block');
            }
            pageBlock = $$('#page-'+tempCat+' a');
            pageBlock.each(function(item, id) {
              item.removeEvent('click');
              item.addEvent('click', function(event){
                gameNav.paging(gameBlock, pageBlock, item, item.get('html'));
              });
            });
          }
          else {
            $('pagingHolder').setStyle('display','none');
            if($chk($('pagingHolderDef'))) {$('pagingHolderDef').setStyle('display','block');}
          }
          $(tempCat).setStyle('display', 'block');
          swapList = $$('#' + tempCat + ' li.One');
          swapList.each(function(game, index){

              game.setStyle('display', 'none');
              if((pageCheck != game.get('class')) && (index!=0) && (game.get('class').test('swap'))) {changed = 1;}
              if(changed == 0) {gameNav.opaGames(game);}
              pageCheck = game.get('class');
          });
        }
        else {
          if($chk($(tempCat))){
            $(tempCat).setStyle('display', 'block');
          }
          if((document.body.id == 'casino_site' && strLang == 'en') || (document.body.id == 'games_site' && ((strLang == 'en') || (strLang == 'es') || (strLang == 'de') || (strLang == 'el') || (strLang == 'fr')))) {
            if(Cookie.read('fogPlayer') !=1) {
              if($$('#' + tempCat + ' .gameBoxFeatured').length > 0) {
                $$('#' + tempCat + ' .gameBoxFeatured')[0].setStyle('display', 'block');
              }
            }
            else {
              if (document.body.id == 'games_site'){
                if($$('#' + tempCat + ' .gameBoxFeatured').length > 1) {
                  //console.log('Box there');
                  $$('#' + tempCat + ' .gameBoxFeatured')[0].setStyle('display', 'none');
                  if(Cookie.read('fogPlayer2') != 1) {
                    $$('#' + tempCat + ' .gameBoxFeatured')[1].setStyle('display', 'block');
                  }
                }
                /*
                else {
                  //console.log('Box here');
                  if($$('#' + tempCat + ' .gameBoxFeatured').length > 0) {
                    $$('#' + tempCat + ' .gameBoxFeatured')[0].setStyle('display', 'none');
                  }
                  //$$('#' + tempCat + ' .gameBoxColumn').setStyle('width','auto');
                  $$('#' + tempCat + ' .gameBoxColumn').setStyle('height','auto');
                  $$('#' + tempCat + ' .gameBoxColumn').setStyle('border-bottom','none');
                  $$('#' + tempCat + ' .gameBoxColumn .gameBox')[0].setStyle('border-right','4px solid #F1F1F1');
                }
                */
              }
            }
            $(cat).getParent('li').addClass('active');
            if((document.body.id == 'games_site' || document.body.id == 'games_site') && (sel != 'nav-favourites' && window.location.hash != ''))
              window.location.hash = sel.replace('nav-', '');
            $$('#' + tempCat + ' div.gameBox').each(function(game, index){
                game.setStyle('display', 'none');
                gameNav.opaGames(game);
            });
          }
          else {
            $(cat).addClass('sel');
            $$('#' + tempCat + ' li').each(function(game, index){
                game.setStyle('display', 'none');
                gameNav.opaGames(game);
            });
          }
        }
      }else{
        if((document.body.id == 'casino_site' && strLang == 'en') || (document.body.id == 'games_site' && ((strLang == 'en') || (strLang == 'es') || (strLang == 'de') || (strLang == 'el') || (strLang == 'fr')))) {
          $(cat).getParent('li').removeClass('active');
          $(tempCat).setStyle('display', 'none');
          if($chk($('newLobbyLeftNav'))){
            $('newLobbyLeftNav').position({y: 0});
          }
        }
        else {
          $(cat).removeClass('sel');
          if($chk($(tempCat))){ $(tempCat).setStyle('display', 'none');}
        }
      }
    });
  },
  gamesPopup: function(type, strGameCode, langLong, gamePath) {
    if(Cookie.read('gameAgree')) {
      gameNav.gamesVRPLaunch(type, strGameCode, langLong, gamePath);
    }
    else {
      $('gameVegasRedirect').set('href', 'javascript:gameNav.load(\''+strGameCode+'\', \''+type+'\', 1)');
            $('warning dialog').setStyle('display', 'block');
      $('modalDimmer').setStyle('display', 'block');
    }
  },
  gamesClose: function() {
    var temp = $('gamesLaunchCheck').get('checked');
    if(temp) { Cookie.write('gameAgree', '1', {duration: 30, path: '/'}); }
          $('warning dialog').setStyle('display', 'none');
    $('modalDimmer').setStyle('display', 'none');
  },
  gamesVRPLaunch: function(type, strGameCode, langLong, gamePath) {
    var new_window;
    var temp = $('gamesLaunchCheck').get('checked');
    if(temp) { Cookie.write('gameAgree', '1', {duration: 30, path: '/'}); }
          $('warning dialog').setStyle('display', 'none');
    $('modalDimmer').setStyle('display', 'none');
    windowName = 'vegasGame';
    if(type=='RP') {
      if(strLang == 'en'){
        new_window = window.open("http://vegas.williamhill.com/minilobby/#"+strGameCode ,windowName, "toolbar=no,width=800,height=663,resizable=yes,scrollbars=0");
        if(!new_window || new_window.closed){
          // do nothing
        }
        else {
          new_window.close();
          new_window = window.open("http://vegas.williamhill.com/minilobby/#"+strGameCode ,windowName, "toolbar=no,width=800,height=663,resizable=yes,scrollbars=0");
        }
                new_window.focus();
              }
              else {
        new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Games&base_url=http://games-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=GM","", "toolbar=no,width=800,height=550,resizable=yes");
      }
    }
    else {
      new_window = window.open("http://demo.williamhill.com/FOBredirectFun.asp?gamecode=" + strGameCode + "&product=" + productCode + "&langCode=" + strLang +  "&source=GM", "", "toolbar=no,width=800,height=550,resizable=yes");
    }
    if(strLang == 'en') {
      window.location = "http://vegas.williamhill.com/";
    }
    else {
      window.location = "http://vegas.williamhill.com/"+strLang+"/index/";
    }
  },
  load: function(strGameCode, type, vegasRedirect, provider) {
  strGameCode = strGameCode.constructor === Array ? strGameCode[Math.floor(Math.random() * strGameCode.length)] : strGameCode;
    void(0);
    var gamePath = "";
    var nektan = false;
    if(strLang == 'en') currency = 'GBP';
    else if(strLang == 'ru' || strLang == 'ca') currency = 'USD';
    else currency = 'EUR';
    var strLangUp = strLang.toUpperCase();
    if(strLangUp === 'BR') strLangUp = 'EN';

    switch(strLang){
      case 'el': langLong = 'Greek'; break;
      case 'es': langLong = 'Spanish'; break;
      case 'fr': langLong = 'French'; break;
      case 'zh': langLong = 'Chinese'; break;
      case 'de': langLong = 'German'; break;
      case 'tr': langLong = 'Turkish'; break;
      case 'it': langLong = 'Italian'; break;
      case 'at': langLong = 'Austrian'; break;
      case 'ru': langLong = 'Russian'; break;
      case 'pl': langLong = 'Polish'; break;
      case 'cn': langLong = 'Simpchinese'; break;
      case 'ie': langLong = 'English'; //strLang = 'en'; break;
      default:   langLong = 'English'; break;
    }
    if(strLang == 'en') currency = 'EUR';
    else if(strLang == 'ru' || strLang == 'ca') currency = 'USD';
    else currency = 'EUR';
    var nektan = false;
    var nextGenDemo = false;
    var gameloader = false;
    var gameloader2 = false;
    var gameloader3 = false;
    switch(strGameCode){
       //Games
      case 'QW': gamePath = 'quick_bet_wheel/quick_bet_wheel_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'QC': gamePath = 'quick_bet_cards/quickbet_cards_54_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'QD': gamePath = 'quick_bet_darts/gameloader.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'HL': gamePath = 'quick_bet_hilo_cards/gameloader.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'QT': gamePath = 'quick_bet_triple_hi_lo/quick_bet_triple_hi_lo_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'QH': gamePath = 'quick_bet_hexagons/quick_bet_hexagons_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BR': gamePath = 'bagatelle_roulette/bagatelle_roulette_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'PT': gamePath = 'quick_bet_poker/quick_bet_poker_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FW': gamePath = 'final_score_worldCup/finalscore_worldcup_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'HP': gamePath = 'poker_holdem/poker_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RO': gamePath = 'quick_bet_roulette/roulette_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'KE': gamePath = 'quick_bet_keno/keno_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'KI': gamePath = 'quick_bet_keno/keno_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FS': gamePath = 'finalscore_multi-league/finalscore_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'QF': gamePath = 'quick_bet_final_score/gameloader.asp&gameCode='+'FS'+strLangUp+'&'; break;
      case 'GO': gamePath = 'quick_bet_golf/golf_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RE': gamePath = 'viva_las_vegas/vegas_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'QS': gamePath = 'quick_bet_spoof/quickbet_spoof_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'VD': gamePath = 'virtual_dogs/virtual_dogs_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'KA': gamePath = 'KingArthur/king_arthur_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'TS': gamePath = 'TopOfTheSlots/top_slots_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BJ': gamePath = 'SuperBlackJack/gameloader.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RF': gamePath = 'RichAndFamous/rich_and_famous_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'AW': gamePath = 'AroundTheWorld/around_the_world_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'VH': gamePath = 'virtual_horses/virtual_horses_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'WF': gamePath = 'WhaleOfFortune/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'ZZ': gamePath = 'ZodiacZillions/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'HD': gamePath = 'HouseOfDragons/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RC': gamePath = 'racingcards/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'B1': gamePath = 'BlackJackPPP/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '3P': gamePath = '3CardBrag/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'JP': gamePath = 'JokerPoker/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'JB': gamePath = 'Jacks_or_Better_multihand/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'R2': gamePath = '3DRoulette/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CW': gamePath = 'BeatTheDealer/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CS': gamePath = 'CasinoPoker/game_load.asp&gameCode=CS'+strLangUp+'&'; break;
      case 'PO': gamePath = 'PharaohsTreasure/game_load.asp&gameCode=PO'+strLangUp+'&'; break;
      case 'GR': gamePath = 'GoldRush/game_load.asp&gameCode=GR'+strLangUp+'&'; break;
      case 'GG': gamePath = 'GoForGold/game_load.asp&gameCode=GG'+strLangUp+'&'; break;
      case 'LR': gamePath = 'KeepEmGoing/game_load.asp&gameCode=LR'+strLangUp+'&'; break;
      case 'JA': gamePath = 'JewelsOfAtlantis/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FM': gamePath = 'FruitMadness/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CC': gamePath = 'CoffinUpTheCash/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'VS': gamePath = 'VegasSolitaire/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'AZ': gamePath = 'AmazonWild/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SB': gamePath = 'Slotris/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'HU': gamePath = 'HeadsUpPoker/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BA': gamePath = 'LightningBalls/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'L8': gamePath = 'Lucky8/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'TM': gamePath = 'TimeMachine/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'GJ': gamePath = 'GinJointJackpot/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SL': gamePath = 'stakesandladders/gameloader.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RU': gamePath = 'Rubiks/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'AL': gamePath = 'AlicesWonderland/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BX': gamePath = 'MultiBarX/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BC': gamePath = 'Baccarat/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'R3': gamePath = 'highstakesroulette/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CP': gamePath = 'Craps/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RG': gamePath = 'Reelgems/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SC': gamePath = 'leprechaunsluck/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CT': gamePath = 'chestsofplenty/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'VL': gamePath = 'viva_las_vegas/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RG': gamePath = 'ReelGems/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'WW': gamePath = 'waroftheworlds/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SR': gamePath = 'slottolette/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'S1': gamePath = 'thebigone/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'S2': gamePath = 'fruitscratch/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RS': gamePath = 'ReSpinner/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'LL': gamePath = 'LeprechaunsLuckSlot/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'OS': gamePath = 'OpenSesame/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'KM': gamePath = 'MidasMillions/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SS': gamePath = 'SensibleSoccer/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'R4': gamePath = '3DRoulette_sportsbook/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'B4': gamePath = 'BlackJack_sportsbook/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CI': gamePath = 'CircusSlot/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'N2': gamePath = 'nagstoriches/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SE': gamePath = 'sensiblesoccereurocupppp/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'GT': gamePath = 'JackpotGT/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'MD': gamePath = 'Madness/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'HT': gamePath = 'HawaiianTreasure/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'WG': gamePath = 'WildGambler/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CL': gamePath = 'CopTheLot/CopTheLotLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RH': gamePath = 'RedHotFruits/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SD': gamePath = 'superdiamonddeluxe/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BL': gamePath = 'BruceLee/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'TI': gamePath = 'TripleInferno/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SX': gamePath = 'SuperSpinsBarXGold/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'AG': gamePath = 'AmigosGold/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'AD': gamePath = 'AngelorDevil/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CB': gamePath = 'CashBangWallop/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'WO': gamePath = 'Worms/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'AD': gamePath = 'AngelOrDevil/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CO': gamePath = 'CashOfTheTitans/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'SW': gamePath = 'SnowWhite/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'TR': gamePath = 'HarryTrotter/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'GC': gamePath = 'GoldLeafClover/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'GN': gamePath = 'GenieJackpots/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FA': gamePath = 'FASlot/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'V1': gamePath = 'VegasSlots/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'V3': gamePath = 'VegasSlots3Line/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'V5': gamePath = 'VegasSlots5Line/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'EG': gamePath = 'EgyptianGoddess/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'GS': gamePath = 'TheGlassSlipper/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'F5': gamePath = 'FASlot_Bingo/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RL': gamePath = 'Richforlife/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5E': gamePath = 'EgyptianGoddessVM/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5G': gamePath = 'GenieJackpotsVM/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5H': gamePath = 'HarryTrotterVM/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5V': gamePath = '5ReelVegasSlotsPayItAgainVM/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5W': gamePath = 'WormsVM/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'WZ': gamePath = 'WinningsofOz/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'WJ': gamePath = 'WishUponAJackpot/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CR': gamePath = 'ClassicRoulette/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'C4': gamePath = 'ClassicRoulette_sportsbook/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BB': gamePath = 'Blackjack/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'B6': gamePath = 'BlackjackMobile/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'C4': gamePath = 'ClassicRoulette_Sportsbook/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      //case 'BV': gamePath = 'BlackjackVIP/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BV': gamePath = 'MayfairBlackjackVIP/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'B8': gamePath = 'Blackjack_Poker/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'C8': gamePath = 'ClassicRoulette_Poker/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5L': gamePath = 'LuckyDuck/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'VK': gamePath = 'VikingsOfFortune/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'PR': gamePath = 'PokerRoyale/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '5L': gamePath = 'LuckyDuck/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'ZA': gamePath = 'AztecGold/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FO': gamePath = 'FortuneSpinner/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'OU': gamePath = 'OnceUponARhyme/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BD': gamePath = 'JackpotGems/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BG': gamePath = 'SugarRush/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BK': gamePath = 'ThaiPrincess/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'IG': gamePath = 'IndianDream/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'ZX': gamePath = 'MayfairRoulette/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'ZW': gamePath = 'MayfairBlackJack/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FG': gamePath = 'FortuneOfTheGods/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'B3': gamePath = 'MayfairBlackJackSportsbook/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'R7': gamePath = 'MayfairRouletteSportsbook/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'KT': gamePath = 'KindomOfWealth/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'BW': gamePath = 'MacauBaccaratDesktop/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CX': gamePath = 'ColorsDesktop/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'LO': gamePath = 'LuckofTheIrish/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CU': gamePath = 'Cuckoo/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CM': gamePath = 'Cuckoo/gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'RP': gamePath = 'RiseOfThePhoenix/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FF': gamePath = 'FairyFortunes/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case '1D': gamePath = 'ThePigWizardVM/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'MB': gamePath = 'MacauBigWheelDesktop/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'MC': gamePath = 'MacauRouletteDesktop/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'CF': gamePath = 'volcanodesktop/Gameload.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'TO': gamePath = 'ToyFactory/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'TQ': gamePath = 'ToyFactory/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'MW': gamePath = 'MagicalWood/GameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'FL': gamePath = 'FestivalOfLights/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'MU': gamePath = 'MayfairMagicDesktop/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;
      case 'PB': gamePath = 'Prospector/gameLoad.asp&gameCode='+strGameCode+strLangUp+'&'; break;

      //Nektan Games
      case 'SM': gamePath = 'Nektan/ShowMeTheBunny/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&'; nektan = true; break;
      case 'LD': gamePath = 'Nektan/LeagueOfDragons/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'BU': gamePath = 'Inspired/BubbleAgent/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'SH': gamePath = 'Nektan/SeasideCash/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'ID': gamePath = 'Inspired/WhiteKnight/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'IA': gamePath = 'Inspired/GoddessOfTheAmazon/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case '3E': gamePath = 'Nektan/CashOfTheDay/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case '3G': gamePath = 'Nektan/CashFromThePast/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case '3E': gamePath = 'Nektan/CashOfTheDay/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case '3C': gamePath = 'Nektan/CashToTheFuture/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'ST': gamePath = 'Inspired/SpiritoftheSamurai/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'CJ': gamePath = 'Inspired/Centurion/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'CN': gamePath = 'Inspired/Centurion/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'GU': gamePath = 'Inspired/TheGuardians/Desktop/gameload.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'RI': gamePath = 'Inspired/20pRoulette/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'GU': gamePath = 'Inspired/TheGuardians/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;
      case 'TT': gamePath = 'Inspired/TikiTastic/Desktop/game_load.asp&gameCode='+strGameCode+strLangUp+'&';  nektan = true; break;


      //nextGen Games
      case 'IE':
      case 'DL':
      case 'FX':
      case 'EI':
      case 'ME':
      case 'MM':
      case 'RR':
      case 'EM':
      case 'HH':
      case 'VR':
      case 'RR':
      case 'TC':
      case 'DV':
      case 'JJ':
      case 'GW':
      case 'MA':
      case 'OM':
      case 'TH':
      case 'BI':
      case 'CA':
      case 'CH':
      case 'ED':
      case 'PA':
      case 'LU':
      case 'NA':
      case 'BE':
      case 'CD':
      case 'QO':
      case 'RB':
      case 'WE':
      case 'WT':
      case 'ZO':
      case 'YR':
      case 'YQ':
      case 'NA':
      case 'YS':
      case 'YT':
      case 'YU':
      case 'YW':
      case 'YX':
      case 'YY':
      case 'YZ':
      case 'YV':
      case 'Y0':
      case 'Y1':
      case 'Y2':
      case 'MN':
      case 'NN':
      case 'DJ':
      case 'NP':
      case 'WP':
        gamePath = 'nextgen-server/gameloader&gameCode='+strGameCode+strLangUp+'&CurrCode='+currency+'&'; nektan = true; break;

        //Default
            default: gamePath = '3DRoulette/game_load.asp&gameCode=R2'+strLang+'&'; break;
    }
    //console.log('- gamePath : '+gamePath );

    var theWidth = 800;
    var theHeight = 663;
    var newStrGameCode = '';
    if (gamePath.indexOf('3DRoulette') == 0 && strGameCode != 'R2' && strGameCode != 'R4'){
      newStrGameCode = window.location.hash.substring(1);
      switch (newStrGameCode){
        //GameLoader
        case 'tcp':
        case 'uth':
          newGamePath = 'shfl-desktop/'; gameloader2 = true;
          break;
        case 'reelrichdevil':
        case 'plataea':
        case 'valiantknight':
        case 'lilred':
        case 'hercules':
        case 'fairysfortune':
          newGamePath = 'williams/'; gameloader = true;
          break;
        case 'koiprincess':
          newStrGameCode = 'koiprincess_not_mobile';
        case 'starburst':
        case 'jimihendrix_not_mobile':
          newGamePath = 'netentnative/'; gameloader3 = true;
          break;
        case 'fabric-4':
        case 'atlantis':
        case 'lightning-squad':
        case 'super-crazy-races':
        case 'delhi-the-elephant':
          newGamePath = 'inspirednative/'; gameloader3 = true;
          break;
        case 'DinoWorldDesktop':
        case 'JellyBearAthleticsDesktop':
        case 'HanselAndGretelDesktop':
        case 'prospector':
        case 'cashbangwallop':
        case 'HawaiianTreasure':
        case 'MidasMillions':
        case 'Respinner':
        case 'ThePigWizardScratchcardVM':
        case 'ToyFactoryScratchcard':
        case 'GenieJackpotsScratchcardVM':
        case 'LuckyDuckScratchcardVM':
        case 'VegasPoolPartyDesktop':
        case 'KenoLottoDesktop':
        case 'PenguinsWorldTour':
          newGamePath = 'vegas2/'; gameloader3 = true;
          break;
        case 'WishUponAJackpot':
        case 'MayfairBlackjack':
        case 'MayfairBlackJack':
        case 'mayfairblackjack':
        case 'MayfairRoulette':
        case 'MayfairBlackjackVIP':
        case 'SenorBurrito':
        case 'EgyptianGoddessvm':
        case 'ToyFactory':
        case 'ThePigWizardVM':
        case 'LuckofTheirish':
        case 'KingdomofWealth':
          newGamePath = 'vegas-gs5/'; gameloader3 = true;
          break;
        case 'congobongo':
          newGamePath = 'realsports/'; gameloader3 = true;
          break;
        default:
          newGamePath = 'nextgennative/';
          if (provider != undefined && provider != '')  newGamePath = provider + '/';
          gameloader3 = true;
      }
    }

  switch (strGameCode){
  case 'PB':
    theHeight = 600;
    theWidth = 920;
    break;
  case 'IE':
  case 'FX':
  case 'DV':
  case 'TC':
  case 'OM':
  case 'PA':
  case 'NA':
  case 'KT':
  case 'DJ':
  case 'NP':
  case 'WP':
  case 'koiprincess':
    theWidth = 1025;
    break;
  case 'YR':
  case 'YS':
  case 'YT':
  case 'YU':
  case 'YW':
  case 'YX':
  case 'YY':
  case 'YZ':
    theWidth = 1097;
    theHeight = 637;
    break;
  case 'PenguinsWorldTour':
  case 'SenorBurrito':
    theWidth = 1097;
    theHeight = 727;
    break;
  case 'Y0':
  case 'Y1':
  case 'Y2':
  case 'FL':
  case 'TO':
  case 'MW':
        case 'DinoWorldDesktop':
        case 'HanselAndGretelDesktop':
        case 'CF':
        case 'MU':
        case 'CU':
    theWidth = 975;
    theHeight = 637;
    break;
  case 'tcp':
  case 'uth':
    theHeight = 618;
    theWidth = 832;
    gameloader2 = true;
    newStrGameCode = strGameCode;
    break;
  case 'reelrichdevil':
  case 'plataea':
    theHeight = 700;
    theWidth = 800;
    gameloader = true;
    newStrGameCode = strGameCode;
    break;
  case 'valiantknight':
  case 'hercules':
  case 'fairysfortune':
    theHeight = 702;
    theWidth = 960;
    gameloader = true;
    newStrGameCode = strGameCode;
    break;
  case 'lilred':
    theHeight = 600;
    theWidth = 806;
    gameloader = true;
    newStrGameCode = strGameCode;
    break;
  }
    var gameLang = strLang;
    if (strLang == 'at') gameLang = "de";
    var new_window;
    if (new_window != null && !new_window.closed) {new_window.focus();}else{
        switch(type){
      case 'realplay':
            Cookie.write("fogPlayer", "1", {duration: 365, domain: '.williamhill.com', path: '/'});
            windowName = 'fogGame';
        if (new_window == null || new_window.closed) {
          if(strLang == 'en'){
            if(strGameCode == 'WCUP') {
                  new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtualFootball&base_url=http://f1x2.williamhill.com/f1x2games/?game=WorldCup&gameTranslationLang="+strLang+"&mode=realplay&gameCode=VFWC" ,windowName, "toolbar=no,width=800,height=500,resizable=yes,scrollbars=0");
                } else if (strGameCode == 'DONDRoulette' || strGameCode == 'DONDBlackjack' || strGameCode == 'WI_ZEUS3') {
                  new_window = window.open("http://games.williamhill.com/v1/minilobby/#!/minilobby?gc="+strGameCode+"&type=realplay" ,windowName, "toolbar=no,width=895,height=700,resizable=yes,scrollbars=0");
                }else{
                  new_window = window.open("http://games.williamhill.com/minilobby#!/minilobby?launchUrl=https:%2F%2Fgaming.williamhill.com%2Flaunch%2Ffog-desktop%2F"+strGameCode+"%3FreturnUrl%3Dhttps%253A%252F%252Fgames.williamhill.com%26clientId%3Dgames%26channel%3Ddesktop%26joinin_link%3Dhttps%253A%252F%252Fsports.williamhill.com%252Facc%252Fen-gb%252Fregister%252FGM%252Fregister.html%253Fsource%253DGM%26freePlay%3Dfalse" ,windowName, "toolbar=no,width=800,height=706,resizable=yes,scrollbars=0");
                }
          }else{
            //new_window = window.open("http://games.williamhill.com/" +strLang+ "/minilobby/#"+strGameCode ,windowName, "toolbar=no,width=820,height=593,resizable=yes,scrollbars=0");
            if(strGameCode == 'WCUP') {
                new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtualFootball&base_url=http://f1x2.williamhill.com/f1x2games/?game=WorldCup&gameTranslationLang="+strLang+"&mode=realplay&gameCode=VFWC" ,windowName, "toolbar=no,width=800,height=500,resizable=yes,scrollbars=0");
            }else if (!provider || provider == ''){
                new_window = window.open("https://fogaccounts.williamhill.com/game_loader?action=go_game_popup&game="+strGameCode+"&mode="+type+"&skip=true&lang="+gameLang+"&source="+productCode ,windowName, "toolbar=no,width=800,height=495,resizable=yes,scrollbars=0");
            }else{
                new_window = window.open("https://gaming.williamhill.com/launch/"+provider+"/"+strGameCode+"?channel=desktop&language="+strLang ,windowName, "toolbar=no,width=800,height=495,resizable=yes,scrollbars=0");
            }
          }
        }else {
                  new_window.clearArrows();
          new_window.scrollTo(strGameCode);
          if(strGameCode == 'WCUP') {
                new_window.frames['gameFrame'].location = "https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtualFootball&base_url=http://f1x2.williamhill.com/f1x2games/?game=WorldCup&gameTranslationLang="+strLang+"&mode=realplay&gameCode=VFWC";
              }else{
                      new_window.frames['gameFrame'].location = "https://fogaccounts.williamhill.com/game_loader?action=go_game_popup&game="+strGameCode+"&mode="+type+"&skip=true&lang="+strLang;
                    }
                    new_window.focus();
                }
            break;
          case 'realplay1':
            Cookie.write("fogPlayer", "1", {duration: 365, domain: '.williamhill.com', path: '/'});
            windowName = 'fogGame';
        if(strGameCode == 'WCUP') {
              new_window = window.open("https://sports.williamhill.com/bet/"+strLang+"?action=DoGameLaunch&systemName=VirtualFootball&base_url=http://f1x2.williamhill.com/f1x2games/?game=WorldCup&gameTranslationLang="+strLang+"&mode=realplay&gameCode=VFWC" ,windowName, "toolbar=no,width=800,height=500,resizable=yes,scrollbars=0");
            } else if (strGameCode == 'MGS_Thunderstruck' || strGameCode == 'MGS_Avalon' || strGameCode == 'MGS_Burning_Desire') {
          new_window = window.open("https://fogaccounts.williamhill.com/game_loader?action=go_game_popup&game="+strGameCode+"&mode="+type+"&skip=true&lang="+strLang+"&source="+productCode ,windowName, "toolbar=no,width=800,height=600,resizable=yes,scrollbars=0");
            } else {
          new_window = window.open("https://fogaccounts.williamhill.com/game_loader?action=go_game_popup&game="+strGameCode+"&mode="+type+"&skip=true&lang="+strLang+"&source="+productCode ,windowName, "toolbar=no,width=800,height=495,resizable=yes,scrollbars=0");
        }
            break;
          case 'freeplay':
            windowName = 'fogDemoGame';
            var GamePath = '';
            if(strGameCode == 'WCUP') {
              GamePath = "https://sports.williamhill.com/bet/en-gb?action=DoGameLaunch&systemName=VirtualFootball&base_url=http://f1x2.williamhill.com/f1x2games/?game=WorldCup&gameTranslationLang=en&mode=freeplay&gameCode=VFWC";
            } else {
                    GamePath = "https://fogaccounts.williamhill.com/game_loader?action=go_game_popup&game="+strGameCode+"&mode="+type+"&skip=true&lang="+strLang;+"&source=GM";
                  }

        if (!vegasRedirect) {
          var width = 800;
          var height = 585;
          if (strGameCode == 'DONDRoulette' || strGameCode == 'DONDBlackjack') {
            var width = 988;
            var height = 810;
          }
          if (Cookie.read('fogPlayer') == '1' && WHX.authenticated == 'Y') {
            GamePopup(GamePath, windowName, width, height);
          }else{
            if(strLang == 'en' || strLang == 'br'){GamePopup('http://games.williamhill.com/demo/#'+strGameCode, windowName, width, height);
            }else{GamePopup('http://games.williamhill.com/' +strLang+ '/demo/#'+strGameCode, windowName, width, height);
            }
          }
        }
        else {
                  window.frames['gameFrame'].location = GamePath;
                    window.focus();
                }
            break;
        /*  case 'freeplay':
            windowName = 'fogGame';
        if(strGameCode == 'WCUP') {
              new_window = window.open("https://sports.williamhill.com/bet/en-gb?action=DoGameLaunch&systemName=VirtualFootball&base_url=http://f1x2.williamhill.com/f1x2games/?game=WorldCup&gameTranslationLang=en&mode=freeplay&gameCode=VFWC" ,windowName, "toolbar=no,width=800,height=500,resizable=yes,scrollbars=0");
            }
            else {
          new_window = window.open("https://fogaccounts.williamhill.com/game_loader?action=go_game_popup&game="+strGameCode+"&mode="+type+"&skip=true&lang="+strLang+"&source="+productCode ,windowName, "toolbar=no,width=800,height=495,resizable=yes,scrollbars=0");
        }
            break; */
                  case 'LD':
      /*
        windowName = 'vegasGame';
        switch (strGameCode){
          case '103D':
            var gtype = 'baccarat';
            var tid = 'z5ws3do7pjxfjdob'; //the same for test and live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '103VIP':
            var gtype = 'baccarat';
            var tid = '6m8kzvqqbyu6ss9b';//Baccarat VIP live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '104D': //roulette UK
            var gtype = 'roulette';
            var tid = '7nyiaws9tgqrzaz3'; //live
            //var tid = '4wozampuy9qumuv5';//test
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '104SD': //Sports roulette
            var gtype = 'roulette';
            var tid = '5wmfs4314km2f93g'; //'ys7npvrcpip0rmya';//live
            //var tid = 'k2fknpwnsohkavy7';//test
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '108D':
            var gtype = 'holdem';
            var tid = 'z3npsp5n9ikvnju1';//dedicate WH table - the same for test and live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=108&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '104VD':
            var gtype = 'roulette';
            var tid = 'mxv0sun301yvtf6i';//Vegas Roulette live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '104VIP':
            var gtype = 'roulette';
            var tid = 'wzg6kdkad1oe7m5k';//Roulette VIP live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '105VD':
            var gtype = 'blackjack';
            var tid = 'ahjco4w5q0pqezky';//Vegas Blackjack live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '105GD':
            var gtype = 'blackjack';
            var tid = '1uc3h76ybeu5aoog';//Genie Blackjack live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '105VIP':
            var gtype = 'blackjack';
            var tid = 'h463tlq1rhl1lfr2';//Platinum VIP Blackjack live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '109CSP':
            var gtype = 'csp';
            var tid = 'CSPTable00000001';//Carribbean Stud Poker live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=hd1&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          case '109D':
            var gtype = 'poker';
            var tid = 'm8vvzow8f2ns0qnh'; //'qc395utoe3s1casx'; old one //Three card Poker live
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://williamhill.evolutiongaming.com/cgibin/UserAuthentication&page=106&lang=" +strLang+ "&source=VA&gameCode=105&gif=fullscreen&evo_game_code=106&gtype=" + gtype + "&tid=" + tid ,windowName, "toolbar=no,width=1000,height=650,resizable=yes");
            break;
          default:
            new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Evolution&base_url=https://willhill.evolutiongaming.com/cgibin/UserAuthentication&lang=" +strLang+ "&source=VA&gameCode=" + strGameCode + "&evo_game_code=" + strGameCode ,windowName, "toolbar=no,width=1004,height=619,resizable=yes,scrolling=no");
        }
                if (window.focus) {new_window.focus();}
          */
    //RIGA LAUNCHER
    windowName = 'vegasGame';
    EvoURL = "https://gaming.williamhill.com/launch/evolutionriga/";
    directLaunch = true;
    tid = "";
    switch (strGameCode){
      case '103D'://baccarat
        tid = 'z5ws3do7pjxfjdob'; //the same for test and live
        break;
      case '103VIP'://baccarat
        tid = '6m8kzvqqbyu6ss9b';//Baccarat VIP live
        break;
      case '103SQ'://baccarat
        tid = 'k2oswnib7jjaaznw';//Baccarat Squeeze
        break;
      case '104D': //roulette UK
        tid = '7nyiaws9tgqrzaz3';
        break;
      case '104SD': //Sports roulette
        tid = '5wmfs4314km2f93g';
        break;
      case '104VD'://Vegas Roulette live
        tid = 'mxv0sun301yvtf6i';
        break;
      case '104VIP'://Roulette VIP live
        tid = 'wzg6kdkad1oe7m5k';
        break;
      case '105VD'://Vegas Blackjack live
        tid = 'o5oaw3h10hin6ksb';
        break;
      case '105GD'://Genie Blackjack live
        tid = '1hhnw5y5x3n09apn';
        break;
      case '105VIP'://Platinum VIP Blackjack live
        tid = 'h463tlq1rhl1lfr2';
        break;
      case '108D'://Holdem dedicate WH table
        tid = 'z3npsp5n9ikvnju1';
        break;
      case '108UD'://Ultimate Holdem table
        tid = 'k4cmp7fhfceqaqfx';
        break;
      case '109CSP'://Carribbean Stud Poker live
        tid = 'CSPTable00000001';
        break;
      case '109D'://Three card Poker live
        tid = 'm8vvzow8f2ns0qnh';
        break;
      default:
        directLaunch = false;
    }
    if (directLaunch){
      EvoURL += "106?table=" + tid + "&channel=desktop&clientId=liveCasinoSA&language=" + strLang;
    }else{
      EvoURL += strGameCode + "?channel=desktop&clientId=liveCasinoSA&language=" + strLang;
    }
    if (isVIP){
      new_window = window.open("http://vegas.williamhill.com/vip-launcher?launch="+encodeURIComponent(EvoURL.replace('?','--')), windowName, "toolbar=no,width=1309,height=619,scrollbars=no,resizable=yes");
    }else{
      new_window = window.open(EvoURL, windowName, "toolbar=no,width=1004,height=619,resizable=yes,scrolling=no");
    }

    if (window.focus) new_window.focus();

                break;
            case 'RP':
                windowName = 'vegasGame';
                switch(document.body.id){
                    case 'vegas_site':
                      if(strGameCode == '00' && strLang == 'en'){
            if(typeof(WHX) !== 'undefined' && typeof(WHX.data.obAccountNumber) !== 'undefined') {
              new_window = window.open("http://vegas.williamhill.com/spin-to-win/?uid="+WHX.data.obAccountNumber, 'SpinToWin', "toolbar=no,width=570,height=550,resizable=yes,scrollbars=0");
                  }else{
                    alert("Please log-in");
                  }
          }else if (new_window == null || new_window.closed) {
            theHeight += 37;
                        if(strLang == 'en' || strLang == 'br' || strLang == 'fi'){
              new_window = window.open("http://vegas.williamhill.com/minilobby/?ref=vegas&12#"+strGameCode ,windowName, "toolbar=no,width="+theWidth+",height="+theHeight+",resizable=yes,scrollbars=0");
            }else{
              new_window = window.open("http://vegas.williamhill.com/" +strLang+ "/minilobby/?ref=vegas&12#"+strGameCode ,windowName, "toolbar=no,width="+theWidth+",height="+theHeight+",resizable=yes,scrollbars=0");
            }
          }
          else {
                    new_window.clearArrows();
                  new_window.scrollTo(strGameCode);
                      if ( nektan ){
                        new_window.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+ gamePath + "lang=" +strLang + "&source=VA" ,"", "toolbar=no,width="+theWidth+",height=550,resizable=yes";
                      }else if (gameloader){
                        new_window.frames['gameFrame'].location = "https://gaming.williamhill.com/launch/"+ newGamePath + strGameCode + "?channel=desktop&returnUrl="+encodeURIComponent('http://vegas.williamhill.com')+"&joinin_link="+encodeURIComponent('https://sports.williamhill.com/acc/' +strLang+ '/register/VA/register.html');
                      }else if (gameloader2){
                        new_window.frames['gameFrame'].location = "https://gaming.williamhill.com/launch/"+ newGamePath + strGameCode + "?channel=desktop&returnUrl="+encodeURIComponent('http://vegas.williamhill.com')+"&joinin_link="+encodeURIComponent('https://sports.williamhill.com/acc/' +strLang+ '/register/VA/register.html');
                  }else if (gameloader3){
                             new_window.frames['gameFrame'].location = "https://gaming.williamhill.com/launch/"+ newGamePath + strGameCode + "?channel=desktop&language=" + gameLang;

                      }else{
                        new_window.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA" ,"", "toolbar=no,width="+theWidth+",height=550,resizable=yes";
                      }
                      new_window.focus();
                  }

                  Cookie.write('vegasPlayed', '1', {duration: 30, path: '/'});
                break;
              case 'poker_site':
                      if(strLang == 'en' || strLang == 'br'){
            if (new_window == null || new_window.closed) {
              new_window = window.open("http://vegas.williamhill.com/minilobby/#"+strGameCode ,windowName, "toolbar=no,width=800,height=663,resizable=yes,scrollbars=0");
            }
            else {
                      new_window.clearArrows();
                    new_window.scrollTo(strGameCode);
                        new_window.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA" ,"", "toolbar=no,width=800,height=550,resizable=yes";
                        new_window.focus();
                    }
                  }else{
                    //new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA" ,windowName, "toolbar=no,width=800,height=550,resizable=yes");
                    new_window = window.open("http://vegas.williamhill.com/" +strLang+ "/minilobby/?ref=poker#"+strGameCode ,windowName, "toolbar=no,width=800,height=663,resizable=yes,scrollbars=0");
                  }
                break;
                    case 'games_site':
                      if(vegasRedirect) {
            if(vegasRedirect == 2) {
                          if (new_window == null || new_window.closed) {
                            if(strLang == 'en'){
                              new_window = window.open("http://vegas.williamhill.com/minilobby/#"+strGameCode ,windowName, "toolbar=no,width=800,height=663,resizable=yes,scrollbars=0");
                            }else{
                              new_window = window.open("http://vegas.williamhill.com/" +strLang+ "/minilobby/?ref=games#"+strGameCode ,windowName, "toolbar=no,width=800,height=663,resizable=yes,scrollbars=0");
                            }
              }
              else {
                        new_window.clearArrows();
                      new_window.scrollTo(strGameCode);
                          new_window.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA" ,"", "toolbar=no,width=800,height=550,resizable=yes";
                          new_window.focus();
                      }
                        }
                        if(vegasRedirect == 3) {
                          new_window = window.open("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA" ,windowName, "toolbar=no,width=800,height=550,resizable=yes");
                        }
                        if((vegasRedirect != 2) && (vegasRedirect != 3)) {
                          gameNav.gamesVRPLaunch(type, strGameCode, langLong, gamePath);
                        }
                      }
                      else {
                        gameNav.gamesPopup(type, strGameCode, langLong, gamePath);
                      }
                      break;
                }
                if (typeof(new_window) != 'undefined') {new_window.focus();}
          break;
      case 'FP1':
                windowName = 'vegasGame';
                switch(document.body.id){
              case 'vegas_demo':
                productCode = "VA";
              case 'vegas_site':
                if (strLang == 'en' || strLang == 'br'){
                  var realPlay = "http://vegas.williamhill.com/minilobby/";
                }else{
                  var realPlay = "http://vegas.williamhill.com/"+strLang+"/minilobby/";
                }
                var GamePath = "http://demo.williamhill.com/FOBredirectFun.asp?gamecode=" + strGameCode + "&product=" + productCode + "&langCode=" + strLang + "&source=VA&realPlayURL="+realPlay;

                if (Cookie.read('vegasPlayed') == '1' && Cookie.read('cust_login') != '') {
            new_window = GamePopup(GamePath, windowName, 800, 550);
          }else{
            if (strLang == 'en' || strLang == 'br'){
                    new_window = GamePopup('http://vegas.williamhill.com/demo/?ref=vegas#'+strGameCode, windowName, 800, 585);
                  }else{
                    new_window = GamePopup('http://vegas.williamhill.com/' +strLang+ 'demo/?ref=vegas#'+strGameCode, windowName, 800, 585);
                  }
                }
                new_window.frames['gameFrame'].location = GamePath;
                break;
              case 'games_site':
                      //new_window = window.open("http://demo.williamhill.com/"+strLang+"/FOBredirectFun.asp?gamecode=" + strGameCode + "&product=" + productCode + "&source=GM", "", "toolbar=no,width=800,height=550,resizable=yes"); break;
                      if(vegasRedirect) {
                        gameNav.gamesVRPLaunch(type, strGameCode, langLong, gamePath);
                      }
                      else {
                        gameNav.gamesPopup(type, strGameCode, langLong, gamePath);
                      }
                      break;
                }
                if (typeof(new_window) != 'undefined') {new_window.focus();}
                break;
              case 'FP':
                windowName = 'vegasGame';
                switch(document.body.id){
              case 'vegas_site':
                if (strLang == 'en'){
                var realPlay = "http://vegas.williamhill.com/minilobby/";
                }else{
                var realPlay = "http://vegas.williamhill.com/"+strLang+"/minilobby/";
                }
                if(nextGenDemo){
                  new_window = window.open("http://vegas-gs3.williamhill.com/nextgen-demo-server/gameloader?GameCode=" + strGameCode + "_" + realPlay + "%23" + strGameCode, windowName, "toolbar=no,width="+theWidth+",height=550,resizable=yes");
                }else if(gameloader){
                  new_window = window.open("https://gaming.williamhill.com/launch/demo-" + newGamePath + newStrGameCode + "?channel=desktop", windowName, "toolbar=no,width="+theWidth+",height=" + (theHeight - 66) + " ,resizable=yes");
                }else if(gameloader2){
                  new_window = window.open("https://gaming.williamhill.com/launch/demo-" + newGamePath + newStrGameCode + "?channel=desktop", windowName, "toolbar=no,width="+theWidth+",height=" + (theHeight - 66) + " ,resizable=yes");
          }else if(gameloader3){
                        new_window = window.open("https://gaming.williamhill.com/launch/demo-" + newGamePath + newStrGameCode + "?channel=desktop&language="+gameLang, windowName, "toolbar=no,width="+theWidth+",height=" + (theHeight - 66) + " ,resizable=yes");

                }else{
                  new_window = window.open("http://demo.williamhill.com/FOBredirectFun.asp?gamecode=" + strGameCode + "&product=" + productCode + "&langCode=" + strLang + "&source=VA&realPlayURL="+realPlay, windowName, "toolbar=no,width="+theWidth+",height=550,resizable=yes");
                  }
                  break;
                    case 'games_site':
                      //new_window = window.open("http://demo.williamhill.com/"+strLang+"/FOBredirectFun.asp?gamecode=" + strGameCode + "&product=" + productCode + "&source=GM", "", "toolbar=no,width=800,height=550,resizable=yes"); break;
                      if(vegasRedirect) {
                        gameNav.gamesVRPLaunch(type, strGameCode, langLong, gamePath);
                      }
                      else {
                        gameNav.gamesPopup(type, strGameCode, langLong, gamePath);
                      }
                      break;
                }
                if (typeof(new_window) != 'undefined') {new_window.focus();}
                break;
            case 'ML':
                switch(document.body.id){
                  case 'games_minilobby':
                    parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=FOG&gameCode=" + strGameCode + "&lang=" +strLang + "&skip=true&mode=realplay&source=GM";
                    //parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Games&base_url=http://games-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=GM";
            break;
                  case 'vegas_minilobby':
                    if ( nektan ){
                      parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/"+ gamePath + "lang=" +strLang + "&source=VA";
                    }else if (gameloader){
                      parent.frames['gameFrame'].location = "https://gaming.williamhill.com/launch/"+ newGamePath + newStrGameCode + "?channel=desktop&returnUrl="+encodeURIComponent('http://vegas.williamhill.com')+"&joinin_link="+encodeURIComponent('https://sports.williamhill.com/acc/' +strLang+ '/register/VA/register.html');
                    }else if (gameloader2){
                      parent.frames['gameFrame'].location = "https://gaming.williamhill.com/launch/"+ newGamePath + newStrGameCode + "?channel=desktop&language=" +gameLang +"&returnUrl="+encodeURIComponent('http://vegas.williamhill.com')+"&joinin_link="+encodeURIComponent('https://sports.williamhill.com/acc/' +strLang+ '/register/VA/register.html');
                }else if (gameloader3){
                      parent.frames['gameFrame'].location = "https://gaming.williamhill.com/launch/"+ newGamePath + newStrGameCode + "?channel=desktop&language=" +gameLang;
                    }else{
                      parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA";
                    }
                    //console.log("https://sports.williamhill.com/bet/" +strLang+ "?action=DoGameLaunch&systemName=Vegas&base_url=http://vegas-gs.williamhill.com/FOB/"+langLong+"/"+ gamePath + "lang=" +strLang + "&source=VA");
              break;
              case 'bingo_minilobby':
                    var param = window.location.href.split('?');
                    if(strLang == 'en') {
                    parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/EN?action=DoGameLaunch&systemName=VirtueFusion&base_url=https://williamhill.virtuefusion.com/igames/play/game_page.do&lang=EN&source=BN&"+param[1];
          }else{
            if (strLang == "ie") {
                        parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/IE?action=DoGameLaunch&systemName=VirtueFusion&region=Ireland&base_url=https://williamhill.virtuefusion.com/igames/play/game_page.do&lang=EN&source=BN&"+param[1];
                  }
                  else {
                    parent.frames['gameFrame'].location = "https://sports.williamhill.com/bet/" +strLang.toUpperCase()+ "?action=DoGameLaunch&systemName=VirtueFusion&base_url=https://williamhill.virtuefusion.com/igames/play/game_page.do&lang="+strLang.toUpperCase() +"&source=BN&"+param[1];
                  }
                    }
              break;
           }
        }
    }
  },
  skillLobby: function(defaultset,width,height,table) {
    if((typeof(height) === 'undefined') && (typeof(width) === 'undefined')) {
      var w = 950;
      var h = 650;
    }
    else {
      var w = width;
      var h = height;
    }
    if(width == 950) {
      var type = 'lobby';
      var win = 'bigSkill';
    }
    else {
      var type = 'single';
      var win = 'smallSkill';
    }
    var nL = (screen.width - w) / 2 ;
    var nT = (screen.height - h) / 2 ;
    var prms = 'height='+h+',width='+w+',resizable=no,';
    prms += 'scrollbars=no,location=no,menubar=no,top='+nT+',left='+nL;
    var url = 'https://login.williamhill.com/seamless_login.asp?game='+defaultset+'&type='+type+'&table='+table;
    window.open(url,win,prms);
  }
};
function GamePopup(pageURL, title, w, h){
  var targetWin = window.open(pageURL, title, 'toolbar=no,width='+w+',height='+h+',resizable=yes,scrollbars=0');
  targetWin.focus();
}
var transformVegasTables = new Class ({
  initialize: function(name){
    this.name = name;
    if($chk(this.name)){
      $$('table.'+this.name).each(function(item, index){
        item.getElements('tr').each(function(item2, index){
          if (index%2 == 1 ) {item2.addClass("On");}
        });
      });
    }
  }
});

// requires md5 encription library
var MainBannerController = new Class({

    Implements: [Options],

    options: {
        status: 'out',
        cookiePrefix: 'dummy_',
        loggedinArea: 'banner_items_in',
        loggedoutArea: 'banner_items_out',
        buttonArea: 'exp_bar',
        navArea: 'nav_'
    },

    initialize: function(options) {
        /* initial options */
        this.setOptions(options);
        this.area = (this.options.status == 'out') ? $(this.options.loggedoutArea) : $(this.options.loggedinArea);
        this.nav = $(this.options.navArea + this.options.status);
        var hiddenNav = this.options.status == 'out' ? 'in' : 'out';
        $('nav_' + hiddenNav).setStyle('display', 'none');
        this.button = $(this.options.buttonArea);
        this.button.addEvent('click', function(){this.showHideBanner();}.bind(this));

        /* check if a cookie exists */
        var currentCookie = Cookie.read(this.options.cookiePrefix + this.options.status);
        if (currentCookie != null) {
            // cookie exists
            var hash = this.getBannerHash();
            //console.log ('cookie exists' + currentCookie);
            //console.log ('hash' + hash);
            if (hash != currentCookie) {
                this.showBanner();
                this.deleteCookie();
            } else {this.hideBanner();}
        } else {
            // cookie doesn't esist show the banner
            //console.log ('cookie doesn\'t exist');
            this.showBanner();
        }
    },

    showHideBanner: function() {
        if (this.area.getStyle('display') == 'block') {
            //should hide banner
            this.hideBanner();
            this.createCookie();
        } else {
            this.showBanner();
            this.deleteCookie();
        }
    },

    showBanner: function() {
        this.area.setStyle('display', 'block');
        this.nav.setStyle('display', 'block');
        this.button.set('class', 'expanded');
    },

    hideBanner: function() {
        //console.log(this.area);
        this.area.setStyle('display', 'none');
        this.nav.setStyle('display', 'none');
        this.button.set('class', 'not_expanded');
    },

    getBannerHash: function() {
        // check if the banner content has changed since the last visit
        var bannerItems = this.area.getElements('img').getProperty('src');
        var singleString = '';
        for (var i = 0; i < bannerItems.length; i++) {
            singleString += bannerItems[i];
        }
        //console.log(singleString);
        var hash = this.hashString(singleString);
        return hash;
    },

    deleteCookie: function() {
        //console.log('deleting cookie');
        Cookie.write(this.options.cookiePrefix + this.options.status, '', {domain: '.williamhill.com', path: '/', duration:300});
    },

    createCookie: function() {
        var hash = this.getBannerHash();
        //console.log('creating cookie');
        Cookie.write(this.options.cookiePrefix + this.options.status, hash, {domain: '.williamhill.com', path: '/', duration:300});
    },

    hashString: function(str) {
        return hex_md5(str);
    }
});

//Mobile Popup
function returnInfo(){
  var clickinfo = '';
  if (Cookie.read('clickinfo') != null){
    var values = Cookie.read('clickinfo').split('&');
    for(var i=0; i< values.length; i++){
      if (values[i].indexOf('member') != -1){
        var member = values[i].split('=');
        clickinfo = member[1];
        break;
      }
    }
  }
  return clickinfo;
}
// * Casino Site
/* Jackpots */
// * Casino Ticker Class
// Look through page and find tickers, then animate...
var casinoTicker = {
  subtract: 200,
  // * Class Reader Method
  // Get the number we are on from the class name
  readClass : function(el) {
    var oldClass  = el.get('class');
    oldClass    = oldClass.toString();
    var newClass  = oldClass.split(" ");
    newClass    = newClass[1].match(/\d/);
    return newClass;
  },
  // * Search Method
  // Search for Tickers on the Page
  Search : function() {
    switch (strCurrency) {
    case "&pound;":
      var currClass = '.GBP';
      var dest = ['.EUR', '.DLR'];
    break;
    case "&euro;":
      var currClass = '.EUR';
      var dest = ['.GBP', '.DLR'];
    break;
    case "$":
      var currClass = '.DLR';
      var dest = ['.GBP', '.EUR'];
    break;
    default:
      var currClass = '.GBP';
      var dest = ['.EUR'];
    }
    // Destroy unused...
    dest.each(function(d) {$$(d).destroy();});
    // * Find the tickers
    var tickers = $$('.jackpotDigits'+currClass);
    // Loop through
    tickers.each(function(ticker) {
      // This id
      var tid     = ticker.get('id');
      var this_ticker = $$('#'+tid);
      // Get all the digits
      var digits    = $$('#'+tid+' span.jackpot-tick');
      var digit_count = digits.length;
      // Find last three digits
      var start_at  = digit_count - 3;
      // * Remove 100 from the count & Seperate Hundreds, Tens, Units
      var cursor    = 0;
      var current_no  = 0;
      var n_cursor  = 0;
      digits.each(function(digit) {
        cursor ++;
        if (cursor > start_at) {
          n_cursor ++;
          current_no += casinoTicker.readClass(digit);
          switch (n_cursor) {
            case 1:
              digit.addClass('hundred');
            break;
            case 2:
              digit.addClass('ten');
            break;
            case 3:
              digit.addClass('unit');
            break;
          }
        }
      });
      // Current & New Number
      current_no  = parseFloat(current_no);
      new_no    = current_no - casinoTicker.subtract;
      if (new_no < 200) {new_no = 100;}
      // Select Digit Elements
      var str_current_no  = current_no.toString();
      var numbers     = str_current_no.split("");
      var hundreds    = $$('#'+tid+' span.hundred');
      var tens      = $$('#'+tid+' span.ten');
      var units       = $$('#'+tid+' span.unit');
      // Pre-get Classes
      var unitClass   = units.get('class');
      var tenClass    = tens.get('class');
      var hundredClass  = hundreds.get('class');
      // * Drop by subtract value
      var str_new_no    = new_no.toString();
      var new_numbers   = str_new_no.split("");
      hundreds.removeClass(hundredClass);
      tens.removeClass(tenClass);
      units.removeClass(unitClass);
      hundreds.addClass('jackpot-tick');
      hundreds.addClass('no-'+new_numbers[0]);
      hundreds.addClass('hundred');
      tens.addClass('jackpot-tick');
      tens.addClass('no-'+new_numbers[1]);
      tens.addClass('ten');
      units.addClass('jackpot-tick');
      units.addClass('no-'+new_numbers[2]);
      units.addClass('unit');
      // * Give information to the Animator, and relax
      casinoTicker.Animator(tid, ticker, hundreds, tens, units, current_no, new_no);
    });
  },
  // * Animator Method
  // Takes information from the Searcher, and animates certain tickers
  Animator : function (tid, ticker, h, t, u, from, to) {
    var period;
    var scoreArray  = new Array();
    var counter   = 0;
    // * Animate Functions
    // Flip Functions
    var firstHalfFlip = function (el, to) {
      var elClass = el.get('class');
      el.removeClass(elClass);
      el.addClass('unit');
      el.addClass('jackpot-tick');
      el.addClass('no-'+to+'-5');
    }
    var secondHalfFlip = function (el, to) {
      var elClass = el.get('class');
      el.removeClass(elClass);
      el.addClass('unit');
      el.addClass('jackpot-tick');
      el.addClass('no-'+to);
    }
    // Units
    var animate_units = function () {
      if (!scoreArray[tid+'-unit']) {
        var units_current = parseFloat(casinoTicker.readClass(u));
        scoreArray[tid+'-unit'] = units_current + 1;
      }else{
        // Update Numbers
        scoreArray[tid+'-unit'] = parseFloat(scoreArray[tid+'-unit']) + 1;
      }
      // When it reaches the end of its cycle
      if (scoreArray[tid+'-unit'] > 9) {
        scoreArray[tid+'-unit'] = '0';
      }
      var str_new = scoreArray[tid+'-unit'];
      (function(){ firstHalfFlip(u, str_new) }).delay(90);
      (function(){ secondHalfFlip(u, str_new) }).delay(200);
    }
    // Tens
    var animate_tens = function () {
      // If its the tens first update
      if (!scoreArray[tid+'-ten']) {
        var tens_current    = parseFloat(casinoTicker.readClass(t));
        scoreArray[tid+'-ten']  = tens_current + 1;
      }else{
        scoreArray[tid+'-ten'] = parseFloat(scoreArray[tid+'-ten']) + 1;
      }
      // When it reaches the end of its cycle
      if (scoreArray[tid+'-ten'] > 9) {
        scoreArray[tid+'-ten'] = '0';
      }
      var ten_new = scoreArray[tid+'-ten'];
      (function(){ firstHalfFlip(t, ten_new) }).delay(90);
      (function(){ secondHalfFlip(t, ten_new) }).delay(200);
    };
    // Hundreds
    var animate_hundreds = function () {
      // If its the hundreds first update
      if (!scoreArray[tid+'-hundred']) {
        var hundreds_current    = parseFloat(casinoTicker.readClass(h));
        scoreArray[tid+'-hundred']  = hundreds_current + 1;
      }else{
        scoreArray[tid+'-hundred'] = parseFloat(scoreArray[tid+'-hundred']) + 1;
      }
      // When it reaches the end of its cycle
      if (scoreArray[tid+'-hundred'] > 9) {
        scoreArray[tid+'-hundred'] = '0';
      }
      var hundred_new = scoreArray[tid+'-hundred'];
      (function(){ firstHalfFlip(h, hundred_new) }).delay(90);
      (function(){ secondHalfFlip(h, hundred_new) }).delay(200);
    };
    // Animate
    var animate = function() {
      // Counter
      if (counter < casinoTicker.subtract) {
        animate_units();
        // When unit reaches end of cycle
        if (scoreArray[tid+'-unit'] == '0') {
          animate_tens();
          // When tens and units reaches end of their cycle
          if (scoreArray[tid+'-ten'] == '0') {animate_hundreds();}
        }
      }
      counter ++;
    };
    // Periodical
    period = animate.periodical(300);
  }
};
/* Casino Hover */
var CasinoHover = {
  Initiate : function() {
    // Help out IE6 when hovering over games
    if($chk($('games-list'))){
      $$('.hoverListen').addEvent('mouseover', function() {
        var play_now = $(this).getElement('.play-now');
        var playButton = $(this).getElement('.play');
        var desc = $(this).getElement('.desc');
        var descOver = $(this).getElement('.descOver');
        play_now.setStyle('display', 'block');
        playButton.setStyle('display', 'block');
        desc.setStyle('display', 'block');
        descOver.setStyle('display', 'block');
        if($chk($(this).getElement('.title'))){
          var title = $(this).getElement('.title');
          var titleOver = $(this).getElement('.titleOver');
          title.setStyle('display', 'none');
          titleOver.setStyle('display', 'none');
        }
        if($chk($(this).getElement('.jpOverlay'))){
          var title = $(this).getElement('.jpOverlay');
          title.setStyle('display', 'none');
        }
      });
      $$('.hoverListen').addEvent('mouseout', function() {
        var play_now = $(this).getElement('.play-now');
        var playButton = $(this).getElement('.play');
        var desc = $(this).getElement('.desc');
        var descOver = $(this).getElement('.descOver');
        play_now.setStyle('display', 'none');
        playButton.setStyle('display', 'none');
        desc.setStyle('display', 'none');
        descOver.setStyle('display', 'none');
        if($chk($(this).getElement('.title'))){
          var title = $(this).getElement('.title');
          var titleOver = $(this).getElement('.titleOver');
          title.setStyle('display', 'block');
          titleOver.setStyle('display', 'block');
        }
        if($chk($(this).getElement('.jpOverlay'))){
          var title = $(this).getElement('.jpOverlay');
          title.setStyle('display', 'block');
        }
      });
    }
  }
};
// Class for New Casino Game Box
var CasinoTabs = {
  // Globals
  DefaultId : 'blackjack',
  ExpandAfter : 12,
  FirstClick  : true,
  activeClass : 'active',
  GameClass : 'cat_',
  TabId   : 'casino_tab_',
  Selected  : 0,
  maxScroll : 0,
  marginTop : 12,
  newMargin : 0,
  passedAfter : 0,
  // * Initiate Method
  // Loads Everything Up
  Initiate : function() {
    // Default Tab
    var activeTab = $(CasinoTabs.TabId+CasinoTabs.DefaultId);
    if ($chk(activeTab)) {
      // Activate Default Tab
      activeTab.addClass('active');
      // Show the games...
      CasinoTabs.FadeInGames(CasinoTabs.DefaultId);
    }
    if ($chk($('bankTable'))) {CasinoTabs.SlideInBanking();}
    // Scroll Promo Box with Page
    if ($chk($('promo'))) {
      var promo     = $('promo');
      var scrollAfter     = 550;
      var promoBoxH     = promo.getStyle('height'); promoBoxH =  promoBoxH.replace(/px/i, '');
      var marginBottom    = 15;
      CasinoTabs.newMargin  = CasinoTabs.marginTop;
      CasinoTabs.passedAfter  = false;
      var periodical;
      var marginLoop      = 0;
      var loopCount     = 0;
      // Check for scroll event
      window.addEvent('scroll', function() {
        CasinoTabs.maxScroll  = (CasinoTabs.BoxHeight - promoBoxH) - marginBottom;
        var scrollPosition    = window.getScroll();
        // If scroll position is correct, we can move the promo box
        if (scrollPosition.y > scrollAfter)
          CasinoTabs.passedAfter  = true;
        // If scroll position is less, we are no longer passed the limit
        if (scrollPosition.y < scrollAfter)
          CasinoTabs.passedAfter  = false;
        // Reset Passed
        if (scrollPosition.y == 0)
          CasinoTabs.passedAfter  = false;
        if (CasinoTabs.passedAfter) {
          CasinoTabs.newMargin  = (scrollPosition.y) - scrollAfter;
        }else{
          CasinoTabs.newMargin  = CasinoTabs.marginTop;
        }
        if (CasinoTabs.newMargin < 0) {
          CasinoTabs.newMargin = CasinoTabs.marginTop;
        }else if (CasinoTabs.newMargin > CasinoTabs.maxScroll) {
          CasinoTabs.newMargin = CasinoTabs.maxScroll;
        }
      });
      // The Tween object:
      var tw = new Fx.Tween(promo, {
        duration: 200,
        // Fix margin oversize issue
        onComplete: function() {
          if (CasinoTabs.newMargin < CasinoTabs.maxScroll) {
            CasinoTabs.newMargin = CasinoTabs.maxScroll;
          }
        }
      });
      var scrollEffect = function() {
        var scrollPosition  = window.getScroll();
        if (marginLoop == scrollPosition.y) {
          loopCount ++;
        }else{
          loopCount = 0;
        }
        // If scroll position is the same for 5 loops:
        if (loopCount == 5) {
          $clear(periodical);
          if (CasinoTabs.passedAfter) {
            if (CasinoTabs.newMargin > CasinoTabs.marginTop)
              tw.start('margin-top', CasinoTabs.newMargin+'px');
          }else{
            tw.start('margin-top', '0px');
          }
          // Delay:
          //tw.start.pass(['margin-top', CasinoTabs.newMargin+'px'], tw).delay(500);
        }
        // Set Vars
        marginLoop = scrollPosition.y;
      }
      scrollEffect.periodical(100);
    }
  },
  //* Clear out all Games
  ClearAll : function() {
    $$('#games-list li').setStyle('display', 'none');
  },
  // * Load in Jackpots
  // Clears everything out, and loads in the Jackpots tab
  Jackpots : function() {
    // Clear out all visible games
    CasinoTabs.ClearAll();
    // Deactivate all tabs, and Activate Jackpots Tab
    CasinoTabs.Switch('jackpots');
  },
  // * Fade In Method
  // Displays selected games with a nice animation
  FadeInGames : function(id) {
    CasinoTabs.ClearAll();
    // Select Game Set
    var gameGroup = $$('.'+CasinoTabs.GameClass+id);
    // Expand games-list div if needed
    // Element
    var gamesBox  = $$('#casino-games');
    // Numbers
    var numGames  = gameGroup.length;
    var boxSize = 140;
    if (numGames > CasinoTabs.ExpandAfter) {
      // Some Maths
      var newHeight   = Math.ceil(numGames / 4);
      newHeight     = newHeight * boxSize;
      CasinoTabs.BoxHeight= newHeight;
      // Animate Box
      gamesBox.tween('height', newHeight);
      var expanded = true;
    }else{
      var oldHeight = boxSize * 3;
      CasinoTabs.BoxHeight = oldHeight;
      gamesBox.tween('height', oldHeight);
      expanded  = false;
    }
    gameGroup.each( function(game) {
      // Show the game
      game.setOpacity(0);
      game.setStyle('display', 'block');
      // New Effect
      game.tween('opacity', '1.0');
    });
  },
  // * Switch Method
  // Switches Tabs & Loads in Games
  Switch : function(id) {
    if (id != CasinoTabs.Selected) {
      // Scroll tabs into view when clicked
      //if (CasinoTabs.FirstClick) {
        var scroll = new Fx.Scroll(window);
        scroll.toElement('scrollAnchor');
        CasinoTabs.FirstClick = false;
      //}
      // Hide all games by default
      CasinoTabs.ClearAll();
      var activeTab = $(CasinoTabs.TabId+id);
      var currentTab  = $$('a.active');
      // Reset Active Tab
      currentTab.removeClass('active');
      // Add Active Class to New Tab
      activeTab.addClass('active');
      // Load in Games
      CasinoTabs.FadeInGames(id);
      // New Selected
      CasinoTabs.Selected = id;
    }
  },
  // * Load Method
  // Loads up a specific game in a new window
  LoadGame : function(LoadType, GameCode) {
  },
  // * Use Toggle
  // Slides Payment Options into view on click
  SlideInBanking : function(id) {
    $$('#bankTable a.bankLink').each(function(item, index){
      var bankingSlide = new Fx.Slide('drop'+index);
      bankingSlide.hide();
      bankingSlide.element.setStyle('display', 'block');
      item.addEvent('click', function(e){
        if(item.className == 'bankLink') {item.addClass('drop');}
        else {item.removeClass('drop');}
        e.stop();
        bankingSlide.toggle();
      });
    });
  }
}

// Show Seo Box
var ShowSeoBox = new Class({
  initialize: function() {
    var seoBox = $('InsideContent') || $$('.InsideContent');
    var expandedSpan = seoBox.getParent().getElement('span');
    var loggedCookie = Cookie.read('__utmv');
    if (seoBox) {
      if (loggedCookie) {
        if (loggedCookie.indexOf('AccNum') != -1) {
          seoBox.setStyle('display', 'none');
          if (expandedSpan.hasClass('expanded')) {
            expandedSpan.removeClass('expanded');
            expandedSpan.addClass('not_expanded');
          }
        }
      } else {
        seoBox.setStyle('display', 'block');
        if (expandedSpan.hasClass('not_expanded')) {
          expandedSpan.removeClass('not_expanded');
          expandedSpan.addClass('expanded');
        }
      }
    }
  }
});

// ** Casino General Class
var generalDropDown = {
  Initiate : function () {
    // Hover Menus
    var dropList  = $$('ul.sub li.drop');
    dropList.addEvent ('mouseover', function() {
      var dropArea  =  this.getElement('ul');
      var dropButton  =  this.getElement('a.subLink');
      dropButton.addClass('subTabHover');
      dropArea.setStyle('display', 'block');
    });
    dropList.addEvent ('mouseleave', function() {
      var dropArea  =  this.getElement('ul');
      var dropButton  =  this.getElement('a.subLink');
      dropButton.removeClass('subTabHover');
      dropArea.setStyle('display', 'none');
    });
    // Hover Menus
    var dropLeft  = $$('ul.sub li.dropLeft');
    dropLeft.addEvent ('mouseover', function() {
      var dropArea  =  this.getElement('ul');
      var dropButton  =  this.getElement('a.subLink');
      dropButton.addClass('subTabHover');
      dropArea.setStyle('display', 'block');
    });
    dropLeft.addEvent ('mouseleave', function() {
      var dropArea  =  this.getElement('ul');
      var dropButton  =  this.getElement('a.subLink');
      dropButton.removeClass('subTabHover');
      dropArea.setStyle('display', 'none');
    });
    // Browser detection - decides on what content to show in Casino Quick Start
    if($chk($('qsFirefox')) && $chk($('qsIE'))) {
      if(navigator.appCodeName == 'Mozilla') {
        $('qsFirefox').setStyle('display', 'block');
          }
          else {
            $('qsIE').setStyle('display', 'block');
          }
        }
  }
}
function load(lang) { var load = window.open ('http://faq.williamhill.com/'+lang,'','scrollbars=yes,height=500,width=1000'); }
var serverTime = {
  init : function() {
    var podical;
    var theClock = $$('#serverClock #st-dynamic');
    var currenttime = theClock.get('html');
    currenttime = currenttime[0];
    currenttime = currenttime.replace(/<!--/g, '');
    currenttime = currenttime.replace(/-->/g, '');
    var serverdate=new Date(currenttime);
    function padlength (what) {
      var output = (what.toString().length==1)? "0"+what : what;
      return output;
    }
    function displaytime () {
      serverdate.setSeconds(serverdate.getSeconds()+1);
      var timestring = padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds());
      theClock.set('text',timestring);
    }
    podical = displaytime.periodical(1000);
  }
};
// * Countdown - used in Martians Vegas
var countDown = {
  // * Init Method
  gyear: 0,
  gmonth: 0,
  gday: 0,
  ghour: 0,
  gminute: 0,
  theClock: '',
  init : function(year, month, day, hour, minute) {
    var podical;
    countDown.gyear = year;
    countDown.gmonth = month;
    countDown.gday = day;
    countDown.ghour = hour;
    countDown.gminute = minute;
    if($chk($('martiansTab'))){
      countDown.theClock = $('martiansTab');
      podical = countDown.displaytime.periodical(1000);
    }
  },
  displaytime: function() {
    Today = new Date();
          Todays_Year = Today.getFullYear() - 2000;
          Todays_Month = Today.getMonth();
          Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
          Target_Date = (new Date(countDown.gyear, countDown.gmonth - 1, countDown.gday, countDown.ghour, countDown.gminute, 00)).getTime();
          Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
          if(Time_Left < 0)
              Time_Left = 0;
    //More datailed.
    days = Math.floor(Time_Left / (60 * 60 * 24));
    Time_Left %= (60 * 60 * 24);
    hours = Math.floor(Time_Left / (60 * 60));
    Time_Left %= (60 * 60);
    minutes = Math.floor(Time_Left / 60);
    Time_Left %= 60;
    seconds = Time_Left;
    days = countDown.zeroPad(days);
    hours = countDown.zeroPad(hours);
    minutes = countDown.zeroPad(minutes);
    seconds = countDown.zeroPad(seconds);
    countDown.theClock.innerHTML = days + '  :  ';
    countDown.theClock.innerHTML += hours + '  :  ';
    countDown.theClock.innerHTML += minutes + '  :  ';
    countDown.theClock.innerHTML += seconds;
  },
  zeroPad: function(num) {
    var numZeropad = num + '';
    if(numZeropad.length < 2) {
      numZeropad = "0" + numZeropad;
    }
    return numZeropad;
  }
}
var imgFader = {
  Initiate: function(name){
    window.addEvent('domready',function() {
      /* settings */
      var showDuration = 5000;
      if ($chk($(name))){
        var container = $(name);
        var images = container.getElements('img');
        var spans = container.getElements('span');
        var currentIndex = 0;
        var interval;
        /* opacity and fade */
        images.each(function(img,i){
          if(i > 0) {img.set('opacity',0);}
        });
        /* worker */
        var show = function() {
          if (images.length > 0){
            images[currentIndex].fade('out');
            images[currentIndex = currentIndex < images.length - 1 ? currentIndex+1 : 0].fade('in');
            if ($chk($(spans[currentIndex]))){
              spans[currentIndex].style.display = 'none';
              spans[currentIndex = currentIndex < images.length - 1 ? currentIndex+1 : 0].style.display = 'block';
            }
          }
        };

        interval = show.periodical(showDuration);
      }
    });
  }
}
function TopGunSubmit(){
  jQuery('#buyIn').removeClass('TopGunError');
  if (jQuery('#buyIn').val() == '0'){
    jQuery('#buyIn').addClass('TopGunError');
    return false;
  }
  jQuery('#entrants').removeClass('TopGunError');
  if (jQuery('#entrants').val() == ''){
    jQuery('#entrants').addClass('TopGunError');
    return false;
  }
  jQuery('#place').removeClass('TopGunError')
  if (jQuery('#place').val() == ''){
    jQuery('#place').addClass('TopGunError');
    return false;
  }
  var returns = (5 * Math.sqrt(jQuery('#entrants').val()/jQuery('#place').val()) * jQuery('#buyIn').val()).toFixed(2);
  jQuery('#total').val(returns);
  return false;
}
function checkDigit(evt){
  var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))  return false;
    return true;
}
//Lock & Load!
window.addEvent('domready', function() {

    //Start Server Clock
    console.log('William Hill Core v 1.1');
    console.log(' - Server Compile Time: ' + strCompileTime);
    console.log(' - Server Query Count: ' + strQueries);
    console.time('Execute Time');
    // Initialise Common Functions
    if($chk($('serverClock'))) {if($chk($('st-dynamic'))){serverTime.init();}
  else{
        (function(){
      serverDate.setTime(serverDate.getTime() + 1000);
      $('serverClock').innerHTML = (serverDate.toTimeString().split(' ')[0] + " UK");
    }).periodical(1000);
  }
    }
  if($chk($('subNavContentId'))){
    $('subNavContentId').setStyle('display', 'none');
      $("langSelectLink").addEvent('click', function(event){
        if ($("subNavContentId").style.display!='') {
            var myFx = new Fx.Tween($("subNavContentId"));
                myFx.set('opacity', 0);
                $("subNavContentId").setStyle('display', '');
                        myFx.start('opacity', 1);
        }
      }
    );
  }

  if($chk($('subNavContentVisId'))){
        $("langSelectVisLink").addEvent('click', function(event){$(this).addClass('sfhover');});
  }
    //Initialise Site Specific Functions
    if(Browser.Engine.trident4){
  $$('.headerBG li').each(function(item, index){
      item.onmouseover=function() {
    this.className+=" sfhover";
      }
      item.onmouseout=function() {
    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
  });
    }
    if(Browser.Engine.trident4){
  $$('#products li').each(function(item, index){
      item.onmouseover=function() {
    this.className+=" sfhover";
      }
      item.onmouseout=function() {
    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
  });
    }
    //Detect Page
    switch(document.body.id){
        case 'root_site':
            if($chk($('user'))){whLogin.init();}
            whTrack.getSERef('Seowh');
            productCode="SB";
            break;
        case 'financials_site':
            whLogin.init();
             if ($chk($('financial_new')) != true) new gameNav.init();
            new imgFader.Initiate('featuredPanel');
            productCode = "FI";
            whTrack.getSERef('Seowhtrader');
            break;
        case 'bingo_site':
            whLaunch.frameKill();
            whLogin.init();
            new SliderNav({
                scrollArea: '.scrollContent',
                scrollControl: '.scrollControl'
            });
      new winners({
                table: '.scheduleTable'
            });
            whTrack.getSERef('Seobn');
      productCode = "BN";
            break;
        case 'developer_site':
            whLogin.init();
            break;
        case 'news_site':
            if (!$chk($('horse_rt'))) whLogin.init();
            //if(!Browser.Engine.trident4){whNews.init()};
            whNews.init();
            new transformVegasTables('newsTable');
            if ($chk($("cropperRadio"))) {setMainNewsImage();}
            productCode = "SB";
            break;
        case 'vegas_site':
           // whLaunch.frameKill();
            whLogin.init();
            productCode = "VA";
            new ShowSeoBox();
            new gameNav.init();
            new FadeNav({
                scrollArea: '.scrollContent',
                duration: 30
            });
            new whAnnouncementScroll.init();
            new transformVegasTables('vegasTable');
            new whNewsScroll.init();
            new CasinoTabs.Initiate();
            new CasinoHover.Initiate();
      new generalDropDown.Initiate();
            whTrack.getSERef('Seowhvegsn');
            countDown.init("09","11","12","12","0");
            if($chk($('productsLeftBlock'))){
    var sidebar = new ScrollSidebar('productsLeftBlock',{
      offsets: {
        x: 0,
        y: 0
      }
    });
      }

            break;
        case 'liveDealer_site':
            //whLaunch.frameKill();
            whLogin.init();
            productCode = "LC";
            new ShowSeoBox();
            new gameNav.init();
            new FadeNav({
                scrollArea: '.scrollContent',
                duration: 30
            });
            new whAnnouncementScroll.init();
            new transformVegasTables('vegasTable');
            new whNewsScroll.init();
            new generalDropDown.Initiate();
            whTrack.getSERef('Seowhvegsn');
            countDown.init("09","11","12","12","0");
            break;
        case 'vegas_minilobby':
      new gameNav.init();
      new miniFeed.init();
     new ShowSeoBox();
      new whNewsScroll.init();
      break;
  case 'games_minilobby':
    new gameNav.init();
    new miniFeed.init();
    new whNewsScroll.init();
    break;
  case 'games_demo':
  new gameNav.init();
  var gameName = window.location.hash.substring(1);
      gameNav.load(gameName,'freeplay',1);
      break;
  case 'vegas_demo':
      new gameNav.init();
      var gameName = window.location.hash.substring(1);
      gameNav.load(gameName,'FP');
      break;
  case 'bingo_minilobby':
      new gameNav.init();
      new miniFeed.init();
      new whNewsScroll.init();
      break;
        case 'games_site':
            productCode = "GM";
           // whLaunch.frameKill();
            whLogin.init();
            new gameNav.init();
    /*if($chk($('newLobbyLeftNav'))){
    var sidebar = new ScrollSidebar('newLobbyLeftNav',{
      offsets: {
        x: 0,
        y: 0
      }
    });
      }*/
            new CasinoTabs.Initiate();
            new CasinoHover.Initiate();
            new generalDropDown.Initiate();
            whTrack.getSERef('Seowhgamesn');
            loadUpdateBrowser();
            break;
        case 'casino_site':
          //  whLaunch.frameKill();
            whLogin.init();
           // new gameNav.init();
            if($chk($('newLobbyLeftNav'))){
    var sidebar = new ScrollSidebar('newLobbyLeftNav',{
      offsets: {
        x: 0,
        y: 0
      }
    });
      }
            productCode = "CA";
            whLaunch.openCasino();
            whTrack.getSERef('Seowhcn');
            new CasinoTabs.Initiate();
            new CasinoHover.Initiate();

            if (window.CSW && window.CSW.isEnabled) {

              var child = document.getElementById('casino-promotions');
              if (child) {
	          child.parentNode.classList.remove('drop');
                  child.parentNode.classList.remove('subNavSelected');
                  child.parentNode.removeChild(child);
              }
            }
            
            new generalDropDown.Initiate();

      $$('.jackpotTop').setOpacity(1);
      if(getQueryVariable('auto') == '1') {whLaunch.launchDownload();}
      if ($chk($('overFlash'))) {showTakeOver();}
      if ($chk($('casinoTitleUnder')) && $chk($('casinoTitleUnder').getElement('#downloadBtn a'))) {
                //var dwnldText = $('casinoTitleUnder').getElement('#downloadBtn a').get('text');
                //$('casinoTitleUnder').getElement('#downloadBtn a').set('html', dwnldText + '<div id="newRibbonTop"></div>');
                //$('newRibbonTop').setStyle('background-image', 'url(http://whdn.williamhill.com/cms/images/casino/site3/new/'+strLang+'/new_34x28.png?dummy=443403)');
            }
            if ($chk(document.getElement('a.downloadGS'))) {
                document.getElement('a.downloadGS').setStyle('background-image', 'url(http://whdn.williamhill.com/cms/images/casino/site2/qs_blue_downloadnew_'+strLang+'.gif?dummy=955701)');
            }
            jQuery(document).ready(function($){
        $('#subNav .expandable').click(function(ev){
      $(this).parent().toggleClass('menu-expanded');
      return false;
    });
      });
      break;
        case 'poker_site':
            whLogin.init({
              callback: function(){
                whLogin.pokerRS();
                whLogin.promoWarriors();
                whLogin.eoyPoker();
              }
            });
            productCode = "PK";
            new whAnnouncementScroll.init();
            new SliderPromo({
                scrollArea: '#scroll',
                scrollControl: '#promosMenu'
            });
            //new whNewsScroll.init();
      $$('.Tips1').each(function(element,index) {
      var content = element.get('title').split('::');
    element.store('tip:title', content[0]);
    element.store('tip:text', content[1]);
      });
      var tips = new Tips($$('.Tips1'), {
    showDelay: 200
      });
      tips.tip.setStyle('opacity', 0);
      tips.addEvent('show', function(tip) {tip.fade(1);});
      tips.addEvent('hide', function(tip){
    tip.setStyle('opacity', 0);
      });
      if($chk($('wsopLeaders'))){
              whLogin.promoLeaderboard('wsopLeadersJSON', 'wsopLeaders');
            }
            whLaunch.launchPrompt();
            scheduleToday.init();
            if(getQueryVariable('auto') == '1') {whLaunch.launchDownload();}
            whTrack.getSERef('Seowhpn');
            if ($chk($('overFlash')) && !isMobileBrowser()) {showTakeOver();}

          // Hiding btn from mac and mobile
        if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || Browser.Platform.name == "mac") {jQuery("#downloadBtn2").hide();}
            break;
        case 'affiliate_site':
           // whLaunch.frameKill();
            whLogin.showSimple();
            break;
        case 'skill_site':
            whLogin.init();
            new gameNav.init();
            new generalDropDown.Initiate();
            productCode = "SK";
            break;
        default:
            //Default;
            productCode = "AP";
            break;
    }
      if($chk($('adventmain'))){
    console.log('Advent Calendar initialised');
    $$('div.openbuttontext').addEvent('click', function(){
      $(this.getParent()).set('style', 'background-position: 0px -100px');
    });
    window.location = '#todaysadvent';
  }
  if($chk($('dynamicleaderboard'))) {
    if(typeof whDynamicLBInit == 'function') {whDynamicLBInit();}
  }
  if($chk($('pointscalculator'))){
    var myScript = Asset.javascript('http://poker.williamhill.com/widgetjs/', {
        id: 'myScript'
    });
  }
  if($chk($('csOurSite_bookmark'))){
        if (Browser.Engine.webkit){
          $('csOurSite_bookmark').set('style','display:none !important');
        }
      }
        // IE - CA - AU fix //
  var theParam = location.href.split('?');
  if (theParam[1] != undefined){
    if (theParam[1].indexOf('l=') != -1){
      var pageLinks = $$('a');
      pageLinks.each(function(item){
        if (item.href.indexOf('mailto') == -1 && item.href.indexOf('javascript') == -1 && item.id != 'choseLang' && item.className != 'Flag' && item.href.indexOf('sports.williamhill') == -1) {
          var segments = item.href.split('/');
          var localFakeLang = theParam[1].substring(2); // remove '?l=' part
          var appendVirtualLanguage = true;
          for (var i=0; i < segments.length; i++) {
            if (localFakeLang == segments[i]) {
              appendVirtualLanguage = false;
            }
          }
          if (appendVirtualLanguage) {
            if (item.href.indexOf('#') != -1){
              var theUrl = item.href.split('#');
              if (item.href.indexOf('?l=') == -1) {
                item.href = theUrl[0] + "?"+ theParam[1] +'#'+ theUrl[1];
              }
            }else if (item.href.indexOf('en-gb') != -1 ){
              if (theParam[1].indexOf('l=ie') != -1){item.href.replace('en-gb','en-ie');}
              if (theParam[1].indexOf('l=ca') != -1){item.href.replace('en-gb','en-ca');}
              if (theParam[1].indexOf('l=au') != -1){item.href.replace('en-gb','en-au');}
            }else if (item.href.indexOf('de-at') != -1 ){
              // do nothing
            }else if (item.href.indexOf('javascript') == -1 && item.href.indexOf('?') == -1){
              item.href += "?"+theParam[1];
            }
          }
        }
      });
    }
  }
    whMessaging.init();
    $$('.joinNow').each(function(a) {
      if(strLang == 'br')
    strLoginLang = 'pt';
  else
    strLoginLang = strLang;
  a.setProperty("href","javascript:loadOverlay('register','" + productCode + "','" + strLoginLang + "');void(0);")
  });
    $$('.joinNowbtnHeader').each(function(a) {
      if(strLang == 'br')
        strLoginLang = 'pt';
      else
        strLoginLang = strLang;
      a.setProperty("href","javascript:loadOverlay('register','" + productCode + "','" + strLoginLang + "');void(0);")
    });
    console.timeEnd('Execute Time');
});
/** Function to append a parameter to the url depending on the existing query string - used on the logout function**/
function insertParam(uri, key, value) {
    var   key = escape(key),
        value = escape(value),
        urlObj = parseURL(uri);

    var kvp = urlObj.search.substr(1).split('&');
    if (kvp == '') {
        urlObj.search = '?' + key + '=' + value;
    }
    else {
        var i = kvp.length; var x; while (i--) {
            x = kvp[i].split('=');

            if (x[0] == key) {
                x[1] = value;
                kvp[i] = x.join('=');
                break;
            }
        }

        if (i < 0) { kvp[kvp.length] = [key, value].join('='); }

        urlObj.search = '?' + kvp.join('&');
    }
    var newUrl = urlObj.host + '/' + urlObj.path +  urlObj.search;
    if(urlObj.hash != '')
      newUrl += '#' + urlObj.hash;
    var pattern = "//",
    reg = new RegExp(pattern, "g");
    newUrl = newUrl.replace(reg,'/');
    return urlObj.protocol + '://' + newUrl;
}


function parseURL(url) {
    var a =  document.createElement('a');
    a.href = url;
    return {
        source: url,
        protocol: a.protocol.replace(':',''),
        host: a.hostname,
        port: a.port,
        search: a.search,
        params: (function(){
            var ret = {},
                seg = a.search.replace(/^\?/,'').split('&'),
                len = seg.length, i = 0, s;
            for (;i<len;i++) {
                if (!seg[i]) {continue;}
                s = seg[i].split('=');
                ret[s[0]] = s[1];
            }
            return ret;
        })(),
        file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
        hash: a.hash.replace('#',''),
        path: a.pathname.replace(/^([^\/])/,'/$1'),
        relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [,''])[1],
        segments: a.pathname.replace(/^\//,'').split('/')
    };
}

function isMobileBrowser() {
  return (/(android|bb\d+|meego).+mobile|avantgo|bada|android|ipad|playbook|silk\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)));
}

if(document.body.id == 'poker_site'){
  var openInstantPlay = function(w, h) {
  var left = (screen.width/2)-(w/2);
  //window.open('http://banner.poker.williamhill.com/html5/poker/PokerDeskLauncher.html?lang='+strLang.toUpperCase(),'instant','width='+w+',height='+h+',toolbar=no,status=yes,resizable=yes,left=' + left);
  window.open('http://cachedownload-poker.williamhill.com/html5/poker/PokerDeskLauncher.html?lang='+strLang.toUpperCase(),'instant','width='+w+',height='+h+',toolbar=no,status=yes,resizable=yes,left=' + left);
}
  jQuery(document).ready(function($){
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || Browser.Platform.name == "mac" || navigator.platform.indexOf('Mac') >=0) {
        if("#whp-home-download-main") {jQuery("#whp-home-download-main").hide();}
        if ( $('#newLobbyDownload')) {$('#newLobbyDownload').hide();}
        if( $('#infoLinks')) {$('#infoLinks').hide();}

         if (document.cookie.indexOf('isMacDownload=true') < 0) {
           document.cookie = "isMacDownload=true; expires=Fri, 30 Dec 2020 23:59:59 GMT";
           alert("Poker Games at William Hill Poker are currently available for Windows PC and MAC");

         }
    }
    $('.whpoker-link').live('click', function(e){
      window.open(help_redirect_link);


      if(!$.browser.msie){
        e.preventDefault;
        e.stopPropagation();
        my_window = window.open(this.href);
        setTimeout(function(){my_window.close();},1000);
        return false;
      }
    });
  });
}
function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}

function loadUpdateBrowser() {
  var ie = (function(){

      var undef,
          v = 3,
          div = document.createElement('div'),
          all = div.getElementsByTagName('i');

      while (
          div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i>< ![endif]-->',
          all[0]
      );

      return v > 4 ? v : undef;

  }());

      if (typeof ie != 'undefined' && parseInt(ie) <= 9) {
    if (getCookie('game_update_browser') != "close" && document.getElementById('update_browser') != null) {document.getElementById('update_browser').style.display="block";}
  }

}

function closeUpd() {
  if (document.getElementById('update_browser') != null) {
    document.getElementById('update_browser').style.display="none";
    document.cookie = "game_update_browser=close; path=/";
  }
}