 
/*
flag=1000 will not display entry popup
flag=0001 will not display exit popup
flag=1001 will not display neither
flag=0002 will be open exit popup with this page(http://www.888.com/new888/lang/en/texts/exitpage.htm)
*/

var InstallSerial = "698193";
var ssr = 106144;
var PopupWindow,MoreInfo;
var byFlag = false;
var windowY = ((screen.availHeight-260)/2);
var windowX = ((screen.width-340)/2);


//register events
//window.onload = position_page
//window.onresize = PositionSite

var MM_contentVersion = 6;
var ShowPopup = true;



if (getCookie("flag"))
	if(getCookie("flag").substring(3,4) == "1")	// "1001" or "0001"
		ShowPopup = false;
		
/***** set cookie *******/

if (queryString("sr") != 'false')
{
	//get serial from querystring
	//alert('in set client cookie');
	setCookie("serial", queryString("sr"),null,"/");

}
else
{

	if (getCookie("serial") == null)
	{
		setCookie("serial", GetSerialByReferrer() ,null,"/")	
	}
}



if (queryString("flag") != 'false')
{
	//get serial from querystring
	setCookie("flag", queryString("flag"),null,"/")	
}
else
{
	if (getCookie("flag") == null)
	{
		setCookie("flag", "0002" ,null,"/")	
	}
}

/***************************/	
//isLocal()
 
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
 
function Down(game,e) 
{ 
	if (e!=null && e.keyCode==27)
	{	Close();
		return;
	}	
	switch (game) 
	{ 
	    case "casino": 						
			
				setCookie("isDownload", "true" ,null,"/")
				Download() 
				break; 
	} 
		
	Close(); 
} 
 
function SetPopUpFocus()
{	 
	/*
	var p=document.getElementById("popdiv");
	if (p)
	{
		if (popdiv.style.display=="inline")
		{	
			setTimeout("popdiv.focus()",200);	 
			 
		}
	}
	*/
}



//--fs command ---------------------------------------------------
<!--
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function movie_master_DoFSCommand(command, args) {
	var movie_masterObj = isInternetExplorer ? document.all.movie_master : document.movie_master;
	Download()
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub movie_master_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call movie_master_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
//-->
//---fs command ---------------------------------------------------

 
function relocateDiv()
{
	var center = document.body.clientWidth /2		
	var p=document.getElementById("popdiv"); 
	if (p)
	{
		var top = 70;
		
		switch(screen.availWidth)
		{
			case 800:				
				left = 65;		
				break;
			case 1280:		
				left = 321;
				break;				
			case 1024:		
				left = 193;	
				break;
			case 1152:		
				left = 321;	
				break;
																			
		}
		if (document.all)
			p.style.left = 138 +150
		else
			p.style.left = left + 319 - 178 +150
		p.style.top = top;
	}

}

function showPopDiv()
{ 
	Drag.init(document.getElementById("popdiv"));
	if (getCookie("isPopUpEntry") == null || getCookie("isPopUpEntry") == "false")
	{		
		if (document.all || 1==1)
		{
			//set PopUpEntry flag to pop only once in the session
			setCookie("isPopUpEntry", "true" ,null,"/")
			var p=document.getElementById("popdiv");
			if (p)	 	
			{
				relocateDiv();
				p.style.display = "inline";	
				p.style.visibility = "visible";
			}						 
			//SetPopUpFocus()
		}
		else //firefox - not show popup
		{
			setCookie("isPopUpEntry", "true" ,null,"/")
		}
	 } 
}

function Close() 
{ 
    var p=document.getElementById("popdiv"); 
    if (p)
    {
		p.style.display="none"; 
    }
}
function CloseSpecial(id) 
{ 
    var p=document.getElementById(id); 
    if (p)
    {
		p.style.display="none"; 
    }
}
function mouseDown(mEvent)
{
	var ref = ""
	var srcEl = ""
	
	if (mEvent.srcElement)
		srcEl = mEvent.srcElement
		
	else if (mEvent.target)
		srcEl = mEvent.target
	
		
	//check if the element that was pressed was an anchor
	while ((srcEl != null) && (srcEl.tagName != "A") && (srcEl.tagName != "BODY") && (srcEl.tagName != "AREA"))
		if (mEvent.srcElement)
				srcEl = srcEl.parentElement
		else if (mEvent.target)
				srcEl = srcEl.parentNode
	
	if ( ((srcEl.tagName == "A") || (srcEl.tagName == "AREA")) && (srcEl != null) )
	{
		if(mEvent.srcElement)
			ref = srcEl.getAttribute("href")
		else
			{
				var lastSlash = document.location.href.lastIndexOf("/");
				var directory = document.location.href.substring(0,lastSlash);
				ref = directory + '/' + srcEl.getAttribute("href");
			}
	
		if (ref)
		{
			
			
			ref = ref.toUpperCase();					 	 
			//check if the the link of the anchor points back to this site
			if ((ref.indexOf("ONLINE-CASINO") != -1)||
			(ref.indexOf("10.10.10") != -1) || 
			(ref.indexOf("DOWNLOAD(") != -1) || 
			(ref.indexOf("LOCALHOST") != -1) || 
			(ref.indexOf("10.10.12") != -1) || 
			(ref.indexOf("SUBMIT()") != -1) || 
			(ref.indexOf("NODOWN(") != -1))
			{
				
				ShowPopup = false								
			 
			}
		}
	}
}
function isLocal()
{
	var addres =  window.location.toString()
	var FirstSlash = 0
		 
	addres = addres.substr(7,addres.length-7)
	FirstSlash = addres.indexOf("/");
	addres = addres.substr(0,FirstSlash)
	if (addres == "localhost" ||
		addres == "10.10.12.63" ||
		addres == "10.10.10.6")
		return true;
	else
		return false;	
}
function beforeUnload()
{	 
	//return; //untill next upload
	 
	 
	if (ShowPopup)
	{
		if (getCookie("flag").substring(3,4) == "2")
		{
			window.open("http://www.888.com/new888/lang/en/texts/exitpage.htm?sr=" + getCookie("serial"),"OPP","width=770,height=485,left=50,top=50,resizable=yes,status=no,scrollbars=auto,toolbar=no,menubar=no");
		}
		else
		{
			if (getCookie("isDownload") == null && getCookie("NoDownClick")==null)
			{
				if (window.confirm("Find out now why everyone is playing Poker - at Online Poker Plus"))
				{
					openGame('1');
				}
			}
		}
	}
}
function openGame(tmp)
{
	switch(tmp)
	{
		case "1":			  					
			window.open("http://www.onlinepokerplus.com?sr=" + getCookie("serial"),"OPP","");
			break;
		
	}
}
function position_page()
{ 	

	var body = document.getElementsByTagName("body")
	var attr = document.body.attributes		
	var HomePage = document.getElementById("HomePageDiv")
	
	for (i=0;i<attr.length;i++)
	{		
		 
		if (attr[i].nodeName == "id")
		{
			if (attr[i].nodeValue == "HideDivPage")
			{
			//	HideDiv('divArticles')
			}
				
		}
 
	}
	//if (HomePage)
		showPopDiv();
		
	PositionSite()
	
	SetPopUpFocus();
	RenderLogo();

}  

function PositionSite()
{	
	 
	var top = 0;
	//var center = document.body.clientWidth /2;		
	var CenterScreen = document.body.clientWidth/2;
	var LeftStart = CenterScreen - 317; //317 is the half of main table width
	var DivideResult = LeftStart/64; 
	var CloseLinePosition =  Math.round(DivideResult) * 64 + 1 

	 
	//Site_Box.style.left =  CloseLinePosition;
	//Site_Box.style.top = top;
		 			
	//Site_Box_Upper.style.left = CloseLinePosition;
	//Site_Box_Upper.style.top = top - 25;
		 
}
function ChangeCursor(obj)
{
	if (document.all) //ie
		obj.style.cursor='hand'
	else
		obj.style.cursor='pointer'
}
function RenderLogo()
{		 
		/* 
		now check if flash can play 
		if flash is enabled then output flash movie
		else set a picture for the header
		*/
		
		var xheaderContent = ""; 
			
		if (MM_FlashCanPlay)
		{
			return;					
		}	
		else
		{
			xheaderContent = "<img src='" + virtualDir + "/images/main_pic.jpg'>"
		}
		var FlashContainer = document.getElementById("FlashBox")
		
		if (FlashContainer)
			FlashContainer.innerHTML = xheaderContent;

}


    
function PopPhone(Content)
{
    var PhoneWindow
    if(window.document.FrmPhone.SupportPhones.selectedIndex!=0)
    {
        PhoneWindow = window.open('','',"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=260,height=140,left=300,top=240");
        PhoneWindow.document.write('<html><head><title>Contact Support by Telephone - Online-Casino</title></head><body bgcolor="#1A2C2C"><table width="%100" align="center"><tr><td valign="middle"><br><b><font face="Verdana" color="#ffffff" size="2">' + Content + '</font></b></td></tr></table></body></html>');
    }
}
function PopPhoneItaly(Content)
{
    var PhoneWindow
    if(window.document.FrmPhone.SupportPhones.selectedIndex!=0)
    {
        PhoneWindow = window.open('','',"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=260,height=140,left=300,top=240");
        PhoneWindow.document.write('<html><head><title>Contatta telefonicamente l\'Assistenza - Online-Casino</title></head><body bgcolor="#1A2C2C"><table width="%100" align="center"><tr><td valign="middle"><br><b><font face="Verdana" color="#ffffff" size="2">' + Content + '</font></b></td></tr></table></body></html>');
    }
}
function ShowDiv(DivName)
{
	if (byFlag == false)
	{		 
		document.getElementById(DivName).style.display="inline";
		byFlag = true;	//permit one click
	}
}

function HideDiv(DivName)
{	 
	document.getElementById(DivName).style.display="none";
}

function displayItem(key)
{
	/*
	if(queryString(key)=='false') 
	{
		result.innerHTML="you didn't enter a ?name=value querystring item.";
	}
	else
	{
		result.innerHTML+=queryString(key)+"<BR>";
	}
	*/
	return queryString(key);
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

//-----------------------------------------------------------
//-----------------------------------------------------------
// download functions
// Etti - Added DL parameter
//-----------------------------------------------------------
//-----------------------------------------------------------

function DownloadLink(obj,strBrand,dl)
{
	//dl='12345'
	var strDL = "";
	var strDL2 = "";
	var anidFromCookie = getCookie("anid");
	var strAnid = "";
	
	if(anidFromCookie != null){
		if(anidFromCookie.length > 0)
		{
			strAnid = "&anid=" + anidFromCookie
			if(dl != null)
			{
				if(dl.length > 0)
				{
					strAnid = strAnid + dl
				}
			}
		}
	}
		
	var tmpHref = document.getElementById(obj);		
	tmpHref.target ="_self"
	
	
	if(strBrand == 'casino')
	{	
		tmpHref.href = "javascript:Download(dl)";
	}	
	else
	{
		//--------------------------------
		//start of the change for the log
		//--------------------------------

		//--------------------------------
		// -----old code:
		//--------------------------------
			
		//document.location.href = "http://www.pacificpoker.com/PokerInstaller?sr=" + getCookie("serial") + "" + strDL;

		//--------------------------------
		// ----new code:
		//--------------------------------
		
		//Etti - when pressed on download move the user first to 
		// the log writing - then move the user to the installation page
		//dev - 
		//sURLLog = '/onlineCasino/DownloadLog.htm'; // *** check that the path works always!!!!
		//live - 
		//sURLLog = '/DownloadLog.htm'; // *** check that the path works always!!!!
		
		// commented by shahar tal 16/09/07
		//window.open(sURLLog,"","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,height=1,width=1,left=1,top=1");	
	
		document.location.href = "http://www.pacificpoker.com/PokerInstaller?sr=" + getCookie("serial") + "" + strAnid;	 
		
		//--------------------------------
		//end of the change for the log
		//--------------------------------	
	}
}  
 

function Download(anid, cancelRedirection, i_ClientLang)
{
	ShowPopup = false;
	var sURL;
	var sr = getCookie("serial");
	var anidFromCookie = getCookie("anid");	
	var srParam;
	var strAnid = "";
	var lang = "en";
	
	if(anidFromCookie != null){
		if(anidFromCookie.length > 0)
		{
			strAnid = "&anid=" + anidFromCookie + anid;
		}
	}
	
	// See if someone asked a different language of the client
	if(i_ClientLang != null){
		if(i_ClientLang.length == 2)
		{
			lang = i_ClientLang;
			strAnid = strAnid + "I" + i_ClientLang;
		}
	}
		
	if (sr == null)
	{
		srParam = InstallSerial;
	}
	else
	{
		srParam = sr;
	}

	
	// alonw version 27/4/09
	sURL = 'http://www.888.com/CasinoInstaller?sr=' + srParam + "" + strAnid + "&lang=" + lang;
	window.open(sURL,"popDown","width=1,height=1,top=0,left=0");
	
	if (cancelRedirection != 1){
		var sURLpop = "http://www.online-casino.com/download.asp";
		document.location.href = sURLpop;
	}
	// end of alon's version	
}

//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------


function NoDownload()
{
	//set no download cookie to true
	setCookie("NoDownClick", "true",null,"/")	
	var sURL;
	var sr = getCookie("serial");
	var srParam;
	
	if (sr==null)
	{
		srParam = InstallSerial;	/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	sURL = "http://flash.888.com/start.asp?Mode=1&sr=" + srParam + "&Real=1";
	//alert(sURL);
	window.open(sURL,"","width=800,height=600,left=50,top=50,resizable=no,status=no,scrollbars=no,toolbar=no,menubar=no");
}

	


function queryString(key)
{
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}
/*
function ReferrerQueryString(key)
{
	var page = new PageQuery(document.referrer); 
	return unescape(page.getValue(key)); 
}*/


function ReferrerQueryString(ref,key)
	{
		//var page = new PageQuery(document.referrer); 
		var page = new PageQuery(ref); 
		return unescape(page.getValue(key)); 
	}
	
function PageQuery(q) 
	{
		if(q.length > 1) 
		{
			if(q.substring(0,1)== "?")
				this.q = q.substring(1, q.length);
			else
				this.q = q;
		}
		else 
			this.q = null;			 
			
		this.keyValuePairs = new Array();
		
		if(q) 
		{
			for(var i=0; i < this.q.split("&").length; i++) 
			{
				this.keyValuePairs[i] = this.q.split("&")[i];
				
			}
		}

		this.getKeyValuePairs = function() 
			{ 
				return this.keyValuePairs; 
			}
		this.getValue = function(s) 
			{
				for(var j=0; j < this.keyValuePairs.length; j++) 
				{
					if(this.keyValuePairs[j].split("=")[0].toLowerCase() == s.toLowerCase())
					{
						return this.keyValuePairs[j].split("=")[1];
					}
				}
				return false;
			}
		this.getParameters = function() 
			{
				var a = new Array(this.getLength());
				for(var j=0; j < this.keyValuePairs.length; j++) 
				{
					a[j] = this.keyValuePairs[j].split("=")[0];
				}
				return a;
			}
		this.getLength = function() 
			{ 
				return this.keyValuePairs.length; 
			}	
	}
 
function GetSerialByReferrer()
{
	//return a serial number
			
	var serial;
	var referrer = document.referrer.toLowerCase();
	//var referrer = "http://www.google.fr/search?hl=fr&q=pacificpoker&btnG=Recherche+Google&meta=";
	
	
	if(referrer.length > 0)
	{
		serial = "668641";
		if (referrer.indexOf("msn.") != -1)
		{
			serial = "698190";
		}
		else
			if (referrer.indexOf("google.") != -1)
			{
				serial = "698188";
			}
			else
				if (referrer.indexOf("yahoo.") != -1)
				{
					serial = "698189";
				}
				else
					if (referrer.indexOf("aol.") != -1)
					{
						serial = "698191";
					}
					else
						serial = "698192";
						
	}
	else
	{
		//no referrer
		serial = InstallSerial;	//default serial

	}	
			
	return serial;
}
function get_serial()
{
	return getCookie("serial");
}


/**
 * Added from http://www.888.com/new888/clientscripts/utils.js
 */
var sCut = '';

function ContactUs()
{
    var w = 793;
    var h = 517;
    var LocationString = "http://www.888.com/new888/lang/en/texts/contactusform/contactus.htm?"+sCut;
    var l = 1; //(window.screen.width-w)/2;
    var t = 1; //(window.screen.height-h)/2;
    window.open(LocationString,"contactUsWnd","status=no,toolbar=no,menubar=no,location=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h)
}
function ContactUsVIP()
{
    var w = 793;
    var h = 517;
    var LocationString = "http://www.888.com/new888/lang/" + sLang + "/texts/contactusform/contactus.htm?" + sCut + "&status=1";
    var l = 1; //(window.screen.width-w)/2;
    var t = 1; //(window.screen.height-h)/2;
    window.open(LocationString,"contactUsWnd","status=no,toolbar=no,menubar=no,location=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h)
}

function ContactUsPoker()
{
    var w = 793;
    var h = 517;
    var LocationString = "http://www.pacificpoker.com/contactusform/contactus.htm?"+sCut;
    var l = 1; //(window.screen.width-w)/2;
    var t = 1; //(window.screen.height-h)/2;
    window.open(LocationString,"contactUsWnd","status=no,toolbar=no,menubar=no,location=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h)
}

function openEmailMsg()
    {
        var w = 804;
        var h = 430; 
        var l = (window.screen.width-w)/2;
        var t = (window.screen.height-h)/2; 
        
        PhoneWindow = window.open('','',"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" +w +",height="+ h + ",left="+l + ",top=" + t);
        PhoneWindow.document.write('<html><head><title>spoofed email </title></head><body style="margin:0px"><table align="center"><tr><td valign="top"><img src="http://images.888.com/casino/new888/lang/en/images/account_alert.gif" border="0"></td></tr></table></body></html>');
    }
 
function NoDownUK(ver,location)
{
	var NewSite;
	if (ver == "../") //new
		NewSite = true;
	else //old
		NewSite = false;
        
//        sCut = "lang=en&s=333875208759151964&sr="+serial+"&st=265&bc=123&anid=0&ic=0"; 
//        sCut = sCut+ '&dl=' + location;
    sCut = '';    	
	if(0!="0")
        {
		if(UKWindow){UKWindow.close();}
		UKWindow = window.open(ver + "ukpopup.htm?" + sCut + "&NewSite="+NewSite+"","Offline","width=795,height=545,left="+windowX+",top="+windowY+",resizable=no,status=no,scrollbars=no,toolbar=no,menubar=no");
        }
        else
        {
               openGame('1',location);
        }
}

function OpenBJSchool(ElementName,dl)
{
	var w = 794;
	var h = 517;
	//var l = (window.screen.width-w)/2;
	//var t = (window.screen.height-h)/2;
	var Location;
	//204.92.99.140
	
	var sr = getCookie("serial");
	var srParam;
	
	if (sr == null)
	{
		srParam = InstallSerial;		/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	// added for generalinstructions/giindex.html
	if (ElementName != null)
	{
  	sURL = "javascript:void(0);"
  	document.getElementById(ElementName).setAttribute("href",sURL);
	}
		
	Location = "http://standalone.888.com/bjschool/bjschool.htm?lang=en&s=780327321358714709&sr=" + srParam + "&st=94&bc=0&anid=0&dl="+dl;
	window.open(Location,"","resizable=yes,status=no,scrollbars=auto,toolbar=no,menubar=no,left=0,top=0,width=" + w + ",height=" + h);
}

