//function tha replace the include
function include(script_filename) {
    document.write('<' + 'script');
    document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="' + script_filename + '">');
    document.write('</' + 'script' + '>');
}


include ('/sharedobj/js/utility.js.php');
//include ('/shared/js/AC_RunActiveContent.js');


/*pop ups the download window */
function popupdl (lng) {
    var add2url = (arguments.length > 1) ? ';DLB:'+arguments[1] : '';
    var ua = navigator.userAgent;

/*  var new_exe = false;
    if (lng == 'en')
    {
        if(ua.match(/MSIE 7\.0/) || ua.match(/MSIE 6\.0/) || ua.match(/Firefox\/2/) || ua.match(/Firefox\/3/))
        {
		if(ua.match(/Windows NT 5\.1/) || ua.match(/Windows NT 6\.0/) || ua.match(/Windows NT 5\.2/))// XP SP2/SP3, Vista, XP 2003
            {
			new_exe = true;
		}
        }
    }
    */
    var down_url;
    var mem = getMember('banner_domainclick');
    if(mem == 'lightman'){
	var ext = getSource('banner_domainclick');
	var source_id = '';
	aExt = ext.split(';');
	for(var i=0; i<aExt.length;i++){
	    tmp = aExt[i].split(':');
	    if(tmp[0]=='source'){
		source_id = tmp[1];
	    }
	}
	fire_pixel('http://track.right-ads.com/conv/?n=7&t=img&clickid='+source_id+'&status=download&nconv_id=');
    }
    
    var src=getSource('banner_domainclick');
    var source;
    
    try{
	if(src.length<2 || src == null){
	    source = '&creferer=source:'+getEVId();
	    setSourse(source);

	}
	else{
	    source='&creferer='+src;
	}
    }
    catch(e){
	//source = '&creferer=source:'+getEVId();
	//setSourse(source);
    }


    if (typeof(lng) == 'undefined')
	down_url = 'http://banner.eurogrand.com/cgi-bin/SetupCasino.exe?opt_lang=en';
    else if(lng=='it')
	down_url = 'http://download.eurogrand.com/cgi-bin/SetupCasino.exe?opt_lang=it';
    else{
	if(lng=='sa') lng='en-za';
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	if(!sPage) sPage = "index";
	var cookie_data = getCookieData('clickinfo');
	down_url = "http://banner.eurogrand.com/cgi-bin/SetupCasino.exe?opt_lang="+lng;
     }
    if ( source == undefined || add2url == undefined )
    {
    	var a21 = window.open(down_url);
    }
    else
    {
    	var a21 = window.open(down_url+source+add2url);
    }
    
    a21.blur();
}


function download (bt, lng) {
    var refpage;

    var arrayrefpage = {
			'es':'descargar-casino.php'
			,'fr':'telecharger-casino.php'
			,'da':'gratis-casino.php'
			,'qc':'getting-started.html'
			,'fi':''
			,'ja':'getting-started.php'
			,'it':'scarica.php'
			,'ru':'casino-software.php'
			,'de':'starten.php'
			,'pl':'pobierz-kasyno.php'
			,'en':'free-casino.php'
			,'nl':'downloaden.php'
			,'uk':'download-casino.php'
			,'en-gb':'download-casino.php'
	};


    refpage = arrayrefpage[lng] || '/free-casino.php';

    popupdl (lng);

    location.href = refpage;

}


function fire_pixel(URL){
	var pix = new Image(1,1);
	pix.src = URL;
}

function jumpto (page)
{
	location.href = page;
}
function goflash (lang) {

	var dlbvar = String(document.location);
	    dlbvar = dlbvar.replace(/.*\//, "" );
	    window.open('http://banner.eurogrand.com/flashcasino.php?creferer=DLB:'+dlbvar);
	}

//get the member from the cookies
function getMember(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));
   var result = res.split(",");
   return (result[0]);
}
function getProfile(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));
   var result = res.split(",");
   return (result[2]);
}
function getChannel(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));
   var result = res.split(",");
   return (result[4]);
}

//get the source from the cookies
function getSource(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));
   var result = res.split(",");
   return (result[4]);
}
function getCookieData(name){	 
	 var start = document.cookie.indexOf(name+"=");	 
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));      
   return res;
}

//make the string of the poker link
function makestr (lng,urll){	
	var URL;
  var clickinfo = getCookieData('clickinfo');
  if(clickinfo != null){	//if we got a cookie, do the following (meytal)
	  var getaff = clickinfo.split("=");
	  var getaff2 = getaff[1].split("&");  
	  if(!clickinfo) {clickinfo = '&member='+member;}
	} else {clickinfo = '&member=DEFAULT';}	//if no cookie, send default
  switch(lng){
		case 'es':
		URL = 'http://serve.williamhill.com/promoRedirect?'+clickinfo+'&zone=536979842&lp=536979919';
		break;
		case 'fr':
		URL = 'http://serve.williamhill.com/promoRedirect?'+clickinfo+'&zone=536979840&lp=536979835';
		break;
		case 'de':
		URL = 'http://serve.williamhill.com/promoRedirect?'+clickinfo+'&zone=1314843640&lp=1084340411';
		break;
		case 'en':
		default:
		URL = 'http://serve.williamhill.com/promoRedirect?'+clickinfo+'&zone=66906304&lp=953711681';
	}
  window.open (URL+'&creferer=source:eg2wh'+lng);
}

//make the sport of the sport link
function makestrsport (lng,urll){
	var clickinfo = getCookieData('clickinfo');
  if(clickinfo != null){	//if we got a cookie, do the following (meytal)
	  var getaff = clickinfo.split("=");
	  var getaff2 = getaff[1].split("&");  
	  if(!clickinfo) {clickinfo = '&member='+member;}
	} else {clickinfo = '&member=DEFAULT';}	//if no cookie, send default
  var zone = '&zone=66906318&lp=13510190';
	switch(lng){
			case 'es':
			zone = '&zone=463602378&lp=14192805';
			break;
			case 'fr':
			zone = '&zone=463602375&lp=14192809';
			break;
			case 'de':
			zone = '&zone=1291797472&lp=1291797478';
			break;
    }
    urll = (typeof(urll) != 'undefined') ? urll : 'http://serve.williamhill.com/promoRedirect?'+clickinfo+zone+'&creferer=source:eg2sport'+lng
    window.open (urll);
}

//make the string of the bingo link
function makestrbingo (lng,urll){
  var clickinfo = getCookieData('clickinfo'); 
  if(clickinfo != null){	//if we got a cookie, do the following (meytal)
	  var getaff = clickinfo.split("=");
	  var getaff2 = getaff[1].split("&");  
	  if(!clickinfo) {clickinfo = '&member='+member;}
	} else {clickinfo = '&member=DEFAULT';}	//if no cookie, send default
    var zone = '&zone=734601858&lp=13510390';
    switch(lng){
			case 'it':
			zone = '&zone=915261577&lp=915261595';
			break;
			case 'es':
			zone = '&zone=915261597&lp=915209426';
			break;
			case 'fr':
			zone = '&zone=915261598&lp=915261594';
			break;
			case 'de':
			zone = '&zone=1370611908&lp=1370611904';
			break;
    }
    urll = (typeof(urll) != 'undefined') ? urll : 'http://serve.rubybingo.com/promoRedirect?'+clickinfo+zone+'&creferer=source:eg2rbb'+lng
    window.open (urll);
}


function makemobilestr ()
{
	var member = getMember ('banner_domainclick');
	var str = 'http://banner.eurograndmobile.com/cgi-bin/redir.cgi?member='+member+'&profile=egr2mob';
	window.open (str);
}



//opens the movie
function upopup(url,w,h,s,n,m){
	var x;
	if(m != "yes") m = "no";
	//alert("test "+m);
	var l = (window.screen.width-w)/2;
	var t = (window.screen.height-h)/2;
	x = window.open(url,n,"height="+h+",width="+w+",status=no,toolbar="+m+",menubar=no,location=no,scrollbars="+s+",left="+l+",top="+t);
    x.window.focus();
}


//Bonus scroll
var s100='s100';

function setDivPos() {

		try{
		var initX = document.documentElement.scrollWidth/2-320;
	}catch(E){
		var initX = document.body.scrollWidth/2-320;
	}
	var initY = 150;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	var layerPos;
		function ml(id) {
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			if (d.layers) el.style=el;
			try{
				el.sP=function(x,y) {
					try{
						this.style.left=x + 'px';
						this.style.top=y + 'px';
					}
					catch(e){
						this.style.left=x;
						this.style.top=y;
					}
				};
			}catch(e){}
		try{
			el.x = initX;
			el.y = initY;
		}catch(e){}
			return el;
		}
		window.remainInPosition=function() {
			try{
				layerPos.x = document.body.scrollWidth/2-370;
			}catch(e){
				try{
					layerPos.x = document.documentElement.scrollWidth/2-370;
				}catch(e){}
			}
			try{
				var pY = ns ? pageYOffset : document.documentElement.scrollTop; //document.body.scrollTop
			}catch(e){
				var pY=document.body.scrollTop;
			}
			try{
				layerPos.y += (pY + initY - layerPos.y)/5;
				layerPos.sP(layerPos.x, layerPos.y);
			}catch(e){}
			setTimeout("remainInPosition()", 60);
		}
	layerPos = ml("bonusGr");
	remainInPosition();
}



// SE referrers
if (typeof seoActive == "undefined")
{
		var REF = document.referrer;
		if (REF)
		{
			document.write('<scr'+'ipt type="text/javascript" src="/ref.php?r='+REF+'&way=qs"></scr'+'ipt>');
			seoActive = true;
		}
}
// End of SE referrers



/*
 +-------------------------------------------------------------------+
 |                   J S - T O O L T I P   (v1.5)                    |
 |                                                                   |
 | Copyright Gerd Tentler               www.gerd-tentler.de/tools    |
 | Created: Feb. 15, 2005               Last modified: Mar. 28, 2006 |
 +-------------------------------------------------------------------+
 | This program may be used and hosted free of charge by anyone for  |
 | personal purpose as long as this copyright notice remains intact. |
 |                                                                   |
 | Obtain permission before selling the code for this program or     |
 | hosting this software on a commercial website or redistributing   |
 | this software over the Internet or in any other medium. In all    |
 | cases copyright must remain intact.                               |
 +-------------------------------------------------------------------+

======================================================================================================

 This script was tested with the following systems and browsers:

 - Windows XP: IE 6, NN 4, NN 7, Opera 7, Firefox 1
 - Mac OS X:   IE 5, Safari 1

 If you use another browser or system, this script may not work for you - sorry.

------------------------------------------------------------------------------------------------------

 USAGE:

 Use the toolTip-function with mouse-over and mouse-out events (see example below).

 - To show a tooltip, use this syntax: toolTip(text, width in pixels, opacity in percent)
   Note: width and opacity are optional

 - To hide a tooltip, use this syntax: toolTip()

------------------------------------------------------------------------------------------------------

 EXAMPLE:

 <a href="#" onMouseOver="toolTip('Just a test', 150)" onMouseOut="toolTip()">some text here</a>

======================================================================================================
*/

  var OP = (navigator.userAgent.indexOf('Opera') != -1) ? true : false;
  var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP) ? true : false;
  var GK = (navigator.userAgent.indexOf('Gecko') != -1) ? true : false;
  var NN4 = document.layers;
  var DOM = document.getElementById;

  function TOOLTIP() {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------
    this.width = 250;                     // width (pixels)
    this.bgColor = '#FFFFff';             // background color
    this.textColor = '#000000';           // text color
    this.borderColor = '#D00000';         // border color
    this.opacity = 100;                    // opacity (percent) - doesn't work with all browsers
    this.cursorDistanceX = -100;              // distance from cursor (pixels)
    this.cursorDistanceY = 30;              // distance from cursor (pixels)

    // don't change
    this.text = '';
    this.height = 0;
    this.obj = 0;
    this.sobj = 0;
    this.active = false;

// -------------------------------------------------------------------------------------------------------
// Functions
// -------------------------------------------------------------------------------------------------------
    this.create = function() {
      if(!this.sobj) this.init();

      var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + ' bgcolor=' + this.bgColor + '><tr>' +
              '<td align=center><font color=' + this.textColor + '>' + this.text + '</font></td></tr></table>';

      if(NN4) {
        t = '<table border=0 cellspacing=0 cellpadding=1><tr><td bgcolor=' + this.borderColor + '>' + t + '</td></tr></table>';
        this.sobj.document.write(t);
        this.sobj.document.close();
      }
      else {
        this.sobj.border = '1px solid ' + this.borderColor;
        this.setOpacity();
        if(document.getElementById) document.getElementById('ToolTip').innerHTML = t;
        else document.all.ToolTip.innerHTML = t;
      }
      if(DOM) this.height = this.obj.offsetHeight;
      else if(IE) this.height = this.sobj.pixelHeight;
      else if(NN4) this.height = this.obj.clip.bottom;

      this.show();
    }

    this.init = function() {
      if(DOM) {
        this.obj = document.getElementById('ToolTip');
        this.sobj = this.obj.style;
      }
      else if(IE) {
        this.obj = document.all.ToolTip;
        this.sobj = this.obj.style;
      }
      else if(NN4) {
        this.obj = document.ToolTip;
        this.sobj = this.obj;
      }
    }

    this.show = function() {
      var ext = (document.layers ? '' : 'px');
      var left = mouseX;
      var top = mouseY;

      if(left + this.width + this.cursorDistanceX > winX) left -= this.width + this.cursorDistanceX;
      else left += this.cursorDistanceX;

      if(top + this.height + this.cursorDistanceY - scrTop > winY) top -= this.height;
      else top += this.cursorDistanceY;

      this.sobj.left = left + ext;
      this.sobj.top = top + ext;

      if(!this.active) {
        this.sobj.visibility = 'visible';
        this.active = true;
      }
    }

    this.hide = function() {
      if(this.sobj) this.sobj.visibility = 'hidden';
      this.active = false;
    }

    this.setOpacity = function() {
      this.sobj.filter = 'alpha(opacity=' + this.opacity + ')';
      this.sobj.mozOpacity = '.1';
      if(this.obj.filters) this.obj.filters.alpha.opacity = this.opacity;
      if(!document.all && this.sobj.setProperty) this.sobj.setProperty('-moz-opacity', this.opacity / 100, '');
    }
  }

//----------------------------------------------------------------------------------------------------
// Build layer, get mouse coordinates and window width, create tooltip-object
//----------------------------------------------------------------------------------------------------
  var tooltip = mouseX = mouseY = winX = winY = scrTop = 0;

  if(document.layers) {
    document.write('<layer id="ToolTip"></layer>');
    document.captureEvents(Event.MOUSEMOVE);
  }
  else document.write('<div id="ToolTip" style="position:absolute; z-index:69"></div>');
  document.onmousemove = getMouseXY_tip;

  function getMouseXY_tip(e) {
  	try{
  		getMouseXY(e);
  	}
  	catch(Err){}

    if(document.body && document.body.scrollTop >= 0) scrTop = document.body.scrollTop;
    else if(window.pageYOffset >= 0) scrTop = window.pageYOffset;

    if(IE) {
	try{
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	}
	catch(e){}
    }
    else {
      mouseX = e.pageX;
      mouseY = e.pageY;
    }

    if(mouseX < 0) mouseX = 0;
    if(mouseY < 0) mouseY = 0;

    if(GK || NN4) {
      winX = window.innerWidth - 25;
      winY = window.innerHeight;
    }
    else if(DOM) {
      try{
      winX = document.body.offsetWidth - 25;
      winY = document.body.offsetHeight;
      }
      catch(e){}


    }
    else {
      winX = screen.width - 25;
      winY = screen.height;
    }
    if(tooltip && tooltip.active) tooltip.show();
  }

  function toolTip(text, width, opacity) {
    if(text) {
      tooltip = new TOOLTIP();
      tooltip.text = text;
      if(width) tooltip.width = width;
      if(opacity) tooltip.opacity = opacity;
      tooltip.create();
    }
    else if(tooltip) tooltip.hide();
  }

  // Eyeview interface
function getEVId(){
  var id = "";
  try { id = EvUtils.UserID + "_" + EvUtils.SessionID;} catch(c){id='getEVIdeception';}
  return id;
}


function setSourse(value){
	/*var img = new Image(1,1);
	img.src = "http://banner.eurogrand.com/cgi-bin/redir.cgi?member="+getMember('banner_domainclick')+'&profile='+getProfile('banner_domainclick')+value;
	img.onload=function(){return}
	*/
	var today = new Date();
	var val = Get_Cookie('banner_domainclick');
	if(val){
		aVal = val.split(',');
		try{
		   aVal[4] = value; 
		}
		catch(e){}
		var cookie_val = aVal.join();
		Set_Cookie('banner_domainclick', cookie_val, today.getTime()+3600*24*3);
		Set_Cookie('banner_click', cookie_val, today.getTime()+3600*24*3);
	}
}

function Set_Cookie(name,value,expires,path,domain,secure) {
  var cookieString = name + "=" +escape(value) +
     ( (expires) ? ";expires=" + expires.toGMTString() : "") +
     ( (path) ? ";path=" + path : "") +
     ( (domain) ? ";domain=" + domain : "") +
     ( (secure) ? ";secure" : "");
  document.cookie = cookieString;
}

function Get_Cookie(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(len,end));
}//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
