// JS functions for FSCommands
function chLang(obj) {
  location.href=obj.value;
}

function FlashMovie_DoFSCommand(command, args) {
  //alert(command + "  " + args);
  if(command=="click") {
    if(args=="offer" || args=="suo") {
      location.href="bienvenue.html";
    }
    if(args=="download") {
      startDownloadWithTutor();
    }
    if(args=="instant") {
   	  location.href = 'https://instant.allslotscasino.com/fr/';
   	  return;

    	guid = Get_Cookie('PCMGUID');
    	var new_url = "https://allslots.gameassists.co.uk/french/?bTag=" + Get_Cookie('bTag');
    	if(guid!=null)
    	 new_url +="&trackingguid="+guid;
      window.open(new_url,'game_window','width=810,height=670,resizable=yes,scrollbars=1,top=0,left=0');
    }
    if(args=="promo") {
      startDownloadWithTutor();
    }
    if(args=="read") {
    	location.href="/fr/welcome.html";
    }
  }
}
function FlashMovieMobile_DoFSCommand(command, args) {
  //alert(command + "  " + args);
  if(command=="click") {
    if(args=="offer" || args=="suo") {
      location.href="/fr/mobile";
    }
    if(args=="download") {
    	location.href="/fr/mobile";
      //startDownloadWithTutor();
    }
    if(args=="instant") {
    	location.href = 'https://instant.allslotscasino.com/fr/';
     	  return;
    	guid = Get_Cookie('PCMGUID');
    	var new_url = "https://allslots.gameassists.co.uk/french/?bTag=" + Get_Cookie('bTag');
    	if(guid!=null)
    	 new_url +="&trackingguid="+guid;
      window.open(new_url,'game_window','width=810,height=670,resizable=yes,scrollbars=1,top=0,left=0');
    }
    if(args=="promo") {
      location.href="/fr/mobile";
    }
  }
}
function SplashCenter_DoFSCommand(command, args) {
  //alert(command + " " + args);
  if (command == 'click') {
    switch (args) {
      case "suo" :
        if(document.getElementById('SplashCenter').innerHTML.indexOf('hp_fr_5600') != -1)
      		location.href = '5600_welcome.html';
        else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CT10_fr') != -1)
          location.href="casinotop10.html";
        else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CTL_fr') != -1)
          location.href="casinotoplists.html";
        else if(Get_Cookie('bTag').indexOf('ajadko') != -1)
          location.href="lucky.html";
        else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466GB_fr') != -1 || Get_Cookie('bTag').indexOf('asaff04188_fr') != -1)
          location.href="gamblingplanet_welcome.html";
        else
          location.href="bienvenue.html";
        break;
      case "download" :
        dwnl();
        break;
      case "instant" :
    	  location.href = 'https://instant.allslotscasino.com/fr/';
       	  return;
        guid = Get_Cookie('PCMGUID');
        var new_url = "https://allslots.gameassists.co.uk/french/?bTag=" + Get_Cookie('bTag');
        if(guid!=null) {
          new_url +="&trackingguid="+guid;
        }
        window.open(new_url,'game_window','width=810,height=670,resizable=yes,scrollbars=1,top=0,left=0');
        break;
      case "playmobile" :
        location.href="mobile";
        break;
    }
  }
}


function HowToPlay_DoFSCommand(command, args) {
  if (command=='click') {
    switch (args) {
      case "action1" :
        window.open('tutorial.html','game_window','width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=1,top=0,left=0');
        break;
      case "action2" :
        window.open('tutorial_creation_compte.html','game_window','width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=1,top=0,left=0');
        break;
      case "action3" :
        window.open('tutorial_depot.html','game_window','width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=1,top=0,left=0');
        break;
    }
  }

}

function FlashMobile_DoFSCommand(command, args) {
  if (command == 'click') {
    if (args == 'mobile') {
      location.href="mobile";
    }
  }
}

function Flash2009_DoFSCommand(command, args) {

 // alert("Flash2009_DoFSCommand "+command+", "+args);


  var gameId = "empty";
  var section = "empty";
  if(command=="click") {
    switch (args) {
     case "download":
//      location.href = "/download.html?download=1";
	  dwnl();
     // window.open('/it/scarica.html');
      break;
     case "download1":
     case "download2":
     case "download3":
      dwnl();
      break;
     case "suo":
        if(document.getElementById('Flash2009').innerHTML.indexOf('hp_fr_5600') != -1)
      		location.href = '5600_welcome.html';
        
      		else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CT10_fr') != -1 || Get_Cookie('bTag').indexOf('asaff04455')!= -1)
          location.href = '/fr/casinotop10.html';
        else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CTL_fr') != -1 || Get_Cookie('bTag').indexOf('asaff04456')!= -1)
          location.href="/fr/casinotoplists.html";
          
        else if(Get_Cookie('bTag').indexOf('ajadko') != -1)
          location.href="lucky.html";
        else if(Get_Cookie('bTag').indexOf('asaff2664_5600') != -1)
          location.href="askgamblers_welcome.html";
        else if(Get_Cookie('bTag').indexOf('asez_5600') != -1)
          location.href="onlinekeno_welcome.html";
        else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466GB_fr') != -1 || Get_Cookie('bTag').indexOf('asaff04188_fr') != -1 || Get_Cookie('bTag').indexOf('asaff04454') != -1) 
          location.href="/fr/gamblingplanet_welcome.html";
        else if(Get_Cookie('bTag').indexOf('ca410835_aff_') != -1)
          location.href="/fr/casinoweb_welcome.html";
        else if(bTag.indexOf('asaff04184') != -1)
	       	location.href = '/fr/pokerlistings_welcome.html';
        else
          location.href = "/fr/welcome.html";//"/fr/bienvenue.html";
     break;
     case "suo1":
     case "side":
        location.href = "/fr/telecharger.html";
      break;
     case "suo_main":
      if(document.getElementById('Flash2009').innerHTML.indexOf('hp_fr_5600') != -1)
      		location.href = '5600_welcome.html';
      else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CT10_fr') != -1)
          location.href = '/fr/casinotop10.html';
      else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CTL_fr') != -1)
          location.href="/fr/casinotoplists.html";
      else if(Get_Cookie('bTag').indexOf('ajadko') != -1)
          location.href="lucky.html";
      else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466GB_fr') != -1 || Get_Cookie('bTag').indexOf('asaff04188_de') != -1)
          location.href="gamblingplanet_welcome.html";
      else
          location.href = "/fr/bienvenue.html";
      break;
     case "win":

        location.href = "/fr/tournaments.html";

      break;
     case "lucky_spin":

        location.href = "/fr/slots-bonus.html";

      break;
     case "instant":
      gameId = "";
      break;
     case "game1":
      gameId = "RubyTombRaiderII";
      break;
     case "game2":
      gameId = "5ReelDrive";
      break;
     case "game3":
      gameId = "bj";
      break;
     case "game4":
        location.href = "/fr/topgames.html";
      break;
     case "game5":
      location.href = "/fr/topgames.html";
      break;
     case "game6":
      //gameId = "Thunderstruck";
      location.href = "/fr/topgames.html";
      break;
     case "promo":
    	 //gameId = "Thunderstruck";
    	 location.href = '/fr/thunderstruck2slot.html';
    	 break;
    }
    if(gameId!="empty") {
      gotoGame(gameId);
    }
  }
}

function PlayNow2009_DoFSCommand(command, args) {
  var ext_btag = readCookie('sp_medium');
  if(!ext_btag) ext_btag = '';
  else ext_btag = "_spv_" + ext_btag;
  if(command=="click") {
    switch (args) {
     case "instant":
      gameId = "empty";
      InstantPlay();
      return;
     case "mobile":
        gameId="empty";
        location.href = "http://www.allslotscasino.com/fr/mobile";
      break;
    }
    if(gameId!="empty") {
      gotoGame(gameId);
    }
  }
}

function gotoGame(gameId) {

/*  if(gameId.length>0) {
    window.location.href = "/free_games.html?gameid="+gameId;
  }
  else {*/
    guid = Get_Cookie('PCMGUID');
    var ext_btag = readCookie('sp_medium');
    if(!ext_btag) ext_btag = '';
    else ext_btag = "_spv_" + ext_btag;
   	var new_url = "https://allslots.gameassists.co.uk/french/?bTag=" + Get_Cookie('bTag') + ext_btag;
    if(gameId.length>0)
      new_url += "&gameId="+gameId+"&sEXT1=demo&sEXT2=demo";
    if(guid!=null)
      new_url +="&trackingguid="+guid;
    window.open(new_url,'game_window','width=810,height=670,resizable=yes,scrollbars=1,top=0,left=0');
  //}
}

function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function startDownloadWithTutor() {
//  sndReq();
  dwnl();
  //window.setTimeout("tutorial_win=window.open('tutorial.html');tutorial_win.focus()", 10000);
  tutorial_win=window.open('/fr/tutorial.html');tutorial_win.focus();
}
function startDownloadWithTutorInNewWin(){
	dwnl();
  	window.open("/fr/tutorial.html");
}


var google_conversion_id = 1034636391;
var google_conversion_language = "en_GB";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "sGtxCLPQogEQ55it7QM";

function gdcp() {
 var headID = document.getElementsByTagName("body")[0];
 //
 var newScript = document.createElement('script');
 newScript.type = 'text/javascript';
 newScript.src = 'http://www.googleadservices.com/pagead/conversion.js';
 headID.appendChild(newScript);
 var img = new Image(1,1);
 img.src = "http://www.googleadservices.com/pagead/conversion/1034636391/?label=sGtxCLPQogEQ55it7QM&amp;guid=ON&amp;script=0";
}

