// JS functions for FSCommands

function createRequestObject() {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(f) {
      xmlhttp = null;
    }
  }
  if(!xmlhttp && typeof XMLHttpRequest != "undefined") {
    xmlhttp = new XMLHttpRequest();
    xmlhttp.overrideMimeType('text/xml');
  }
  return  xmlhttp;
}
var httpObj = createRequestObject();

function sndReq() {
  httpObj.open('GET', 'anleitung.html');
  httpObj.onreadystatechange = handleResponse;
  httpObj.send(null);
}

function handleResponse() {
  try {
    if((httpObj.readyState == 4) && (httpObj.status == 200)) {
      var response = httpObj.responseText;
      strresp = response.substring(response.search('<div class="main">'),response.search('</body>'));
      document.getElementById('bodyelem').innerHTML = strresp;
      document.getElementById('innersuo').innerHTML = '<object width="220" height="140" id="FlashMovie" name="FlashMovie" type="application/x-shockwave-flash" data="http://www.allslotscasino.com/sites/default/themes/as/flash/as_inr_suo01.swf"><param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="movie" value="http://www.allslotscasino.com/sites/default/themes/as/flash/as_inr_suo01.swf" /></object>';
    } else {
      try{}
      catch(e){
        alert("display div  undefined");
      }
    }
  }catch(e) {}
  finally{}
}

function FlashMovie_DoFSCommand(command, args) {
  if(command=="click") {
    if(args=="offer" || args=="suo") {
      location.href="willkommensbonus.html";
    }
    if(args=="download") {
      startDownloadWithTutor();
    }
    if(args=="instant") {
    	guid = Get_Cookie('PCMGUID');
    	var new_url = "https://allslots.gameassists.co.uk/german/?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=="playmobile") {
      location.href="mobile.html";
    }
  }
}

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

function SplashRight_DoFSCommand(command, args) {
//	alert(command);
//	alert(args);
  if (command == 'click') {
    if (args == 'aff') {
      location.href="/de/casinode.html";
    }
  }
}

function FlashMovieNewGames_DoFSCommand(command, args) {
//  alert(command + "  " + args);
  if(command=="click") {
    if(args=="promo") {
      location.href="freetournamentnew.html";
    }
    if(args=="offer" || args=="suo") {
      location.href="willkommensbonus.html";
    }
    if(args=="instant" || args=="promo") {
    	guid = Get_Cookie('PCMGUID');
    	var new_url = "https://allslots.gameassists.co.uk/german/?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=="download") {
      startDownloadWithTutor();
    }
  }
}

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();
  if(window.location.href.indexOf('anleitung.html') == -1)
    tutorial_win=window.open('anleitung.html');tutorial_win.focus();
}
function startDownloadWithTutorInNewWin(){
	dwnl();
  	window.open("anleitung.html");
}

function SplashCenter_DoFSCommand(command, args) {
 // alert(command + " " + args);
  if (command == 'click') {
    switch (args) {
      case "suo" :
      if(document.getElementById('SplashCenter').movie.indexOf('hp_de_5600') != -1)
       	  location.href = '5600_welcome.html';
       else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CTL_de') != -1)
          location.href = 'casinotoplists.html';
       else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466CT10_de') != -1)
          location.href = 'casinotop10.html'; 
       else if(Get_Cookie('bTag').indexOf('asaff2664_5600') != -1)
          location.href = 'askgamblers_welcome.html';        
       else if(Get_Cookie('bTag') == 'ks')
          location.href = 'casinode.html';
       else if(Get_Cookie('bTag').indexOf('asCa495225_aff_466GB_de') != -1)
          location.href="gamblingplanet_welcome.html";
        else
        location.href="willkommensbonus.html";
        break;
      case "download" :
        dwnl();
        break;
      case "instant" :
        guid = Get_Cookie('PCMGUID');
        var new_url = "https://allslots.gameassists.co.uk/german/?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="http://www.allslotscasino.com/mobile.html";
        break;
    }
  }
}

function HowToPlay_DoFSCommand(command, args) {
  if (command=='click') {
    switch (args) {
      case "action1" :
        location.href = 'anleitung.html','game_window','width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=1,top=0,left=0';
        break;
      case "action2" :
        location.href = 'casinokontoerstellung.html','game_window','width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=1,top=0,left=0';
        break;
      case "action3" :
        location.href = 'anleitung_einzahlung.html','game_window','width='+screen.availWidth+',height='+screen.availHeight+',resizable=yes,scrollbars=1,top=0,left=0';
        break;
    }
  }

}

function onlineMalta_DoFSCommand(command, args) {
  location.href = 'zahlungsmittel.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";
}

