
var InstallSerial = "400194";
var ofw

var ShowPopup = true;

if (getCookie("flag"))
	if(getCookie("flag").substring(3,4) == "1")	// "1001" or "0001"
		ShowPopup = false;

if(document.all)
{
    if(document.all['scrollPict'])
    {
        if(document.getElementById){document.all['scrollPict'].style.position="absolute";}
        ofw=document.body.offsetWidth;
        
		var pictTop
        if (document.getElementById("scrollFromTop"))
        {
			pictTop = parseInt(document.getElementById("scrollFromTop").innerText);
        }
        else
        {
			pictTop=250;
        }
        
        
        if(ofw<1300 && ofw>819)
        {
            var diff;
            diff=(1024-ofw)/2;
            if(diff<120)
                window.document.all['scrollPict'].style.left=132-diff;
        }
        else
            window.document.all['scrollPict'].style.left=1;
        if(ofw<820)
            window.document.all['scrollPict'].style.left=1;
    }
}

/*if(document.all)
{
	if(document.all['dvMain'])
    {
		 window.document.getElementById('dvMain').style.display="inline";
		 window.document.all['dvOnlineGambling'].style.display="none";
		 window.document.all['dvBlackJack'].style.display="none";
		 window.document.all['dvBaccarat'].style.display="none";
		 window.document.all['dvCraps'].style.display="none";
		 window.document.all['dvRoulette'].style.display="none";
		 window.document.all['dvSlots'].style.display="none";
		 window.document.all['dvVPoker'].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"))
		if (mEvent.srcElement)
				srcEl = srcEl.parentElement
		else if (mEvent.target)
				srcEl = srcEl.parentNode
	
	if ((srcEl.tagName == "A")&&(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("CONET") != -1)||
				(ref.indexOf("10.10.10") != -1) || 
				(ref.indexOf("CASINO-ON-NET") != -1)|| 
				(ref.indexOf("DOWNLOAD()") != -1) || 
				(ref.indexOf("NODOWN()") != -1) ||
				(ref.indexOf("CASINOONNET") != -1) ||
				(ref.indexOf("LOCALHOST") != -1)) 
				
			{
			
				ShowPopup = false
			}
		}
	}
}

function beforeUnload()
{
 
	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 (window.confirm("Find out now why everyone is playing Poker – at Pacific Poker Online."))
			{
				window.open("http://www.pacificpoker-online.com?sr=" + getCookie("serial"));
			}
		}
	}
}

function PopUpEntry()
{
	if (window.confirm("Click OK to download our free software while browsing the site!"))
		{
			//window.open("http://www.888.com/CasinoInstaller?lang=en&sr=" + getCookie("serial"));
			ShowPopup = false;
			window.location.href="http://www.888.com/CasinoInstaller?lang=en&sr=" + getCookie("serial");
		}
}


function questionOpener()
{
//	if(confirm('Click OK to download our free software while browsing the site')){Download('10');}
}


function AddSerial(_linkObj,_serial)
{	
	var href = _linkObj.href;
	//clean the href
	if (href.indexOf('?')!=-1 || href.indexOf('&')!=-1)
	{
		if (href.indexOf('?')!=-1)
			href = href.substr(0,href.indexOf('?'));
		else                                 
			href = href.substr(0,href.indexOf('&')); 	
	}
 
	var delimiter;
	var _text = _linkObj.innerText;
	
	/*if (href.indexOf('?')==-1)
		delimiter = "?";
	else
		delimiter = "&";	*/
	 
	_linkObj.href = href + "?" + "sr=" + _serial;	
	_linkObj.innerText = _text;
}


function Affiliates()
{
	window.open("http://affiliates.888.com","","width=800,height=600,left=50,top=50,resizable=yes,status=yes,scrollbars=auto,toolbar=yes,menubar=yes");
}

function InviteFriend()
{
	window.open("http://www.888.com/new888/home.htm?page=iafform&lang=en&sr=400194","","width=800,height=600,left=50,top=50,resizable=yes,status=yes,scrollbars=yes,toolbar=yes,menubar=yes");
}



function writeCookie(sKey,sValue)
{
	var the_date = new Date("December 31, 2020");
	var domain = "www.888.com";
	if (domain.indexOf("888")!=-1){domain = ".888.com";}
	
	var cookie_text = sKey + "=" + sValue + "; expires=" + the_date.toGMTString() + "; path=/; domain=" + domain;
	document.cookie = cookie_text;
}

function openGame(Status,location)
{
	var w = 637;
	var h = 458;
	var LS;
	var LastSR;
    
    //java
		
		if ('null' == 'y')
		{LastSR = '293897';}//for direct open
		else
		{
			LastSR = window.parent.SelectSR;
			if ('null' == 'Y'){LastSR = window.opener.parent.SelectSR;}
		}
		
		var sCut = "lang=en&s=069548665060948518&sr="+ LastSR +"&st=79&geo=0";
		
		sCut = sCut+ '&dl=' + location;
		
		
		
			
				w = 820;
				h = 590;
				LS = "http://flash.888.com/start.asp?Mode=1&" + sCut;
			
		
        LS = LS + "&Real=" + Status;
    
    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2;
   window.open(LS,"NoDownWin","resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h);
}

function window_onscroll()
{
    if(document.all && document.getElementById) //added for IE4
    {
        if(window.document.getElementById("scrollPict"))
            window.document.getElementById("scrollPict").style.top=document.body.scrollTop+pictTop;
    }
    else if(document.all && !document.getElementById) //added for IE4
    {
        if(document.all['scrollPict'])
            document.all['scrollPict'].style.top=document.body.scrollTop+pictTop;
    }
}



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 - Casino-on-Net</title></head><body bgcolor="#4b9e3b"><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 ChangePic(PicName,imgFile)
{
	document.getElementById(PicName).src=imgFile;
}

function ShowReport(type,Val)
{
	if(Val == "0"){return;}
    if(type == "pwc"){window.document.Frm.RNG.selectedIndex = 0;}
    else{window.document.Frm.PWC.selectedIndex = 0;}
	window.document.ReportImg.src = "http://images.888.com/casino/new888/lang/en/images/pwc/" + type + "_" + Val + ".gif";
    location.href = "#img";
    document.body.focus();
}

function ShowDiv(DivName)
{
	document.getElementById(DivName).style.display="inline";
	document.getElementById('dvMain').style.display="none";
}

function HideDiv(DivName)
{
	document.getElementById(DivName).style.display="none";
	document.getElementById('dvMain').style.display="inline";
}

function GoToPCPO()
{
	var SRparam = getCookie("serial"); 
	if(SRparam == null)
	{
		SRparam = "928336"; //Default serial
	}
	
	var sURL = 'http://www.pacificpoker-online.com?sr='+ SRparam;
	
	document.getElementById("pcpoLink").setAttribute("href",sURL);
}

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;
			
	//	if(q.length == 0) 
	//		this.q = null;
	//	else
	//		this.q = q;
		
	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 queryString(key)
{
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

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)
{
	if (name=="sr") name="serial"	 
    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";
    }
}

function Delay(){Download(true);}
function Download(x)
{ 
	if (!x)
	 setTimeout("Delay()",200)
	else
	{
		var sURL;
		var sr = getCookie("serial");
		var srParam;
		if (sr == null)
		{
			srParam = InstallSerial;
		}
		else
		{
			srParam = sr;
		}
			
		sURL = 'http://www.888.com/CasinoInstaller?lang=en&sr=' + srParam;	 
		 
		document.location.href = sURL;
		//return false 
	}	
}
 
function NoDownload(event)
{	
	var obj
	if (!document.all)//if firefox
	{
		obj = event.target.parentNode
		obj.href = "javascript:void 0;";
		
	}	
	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&lang=en&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");
	
	
	if (!document.all)
	{		
		setTimeout("fixLink('" + obj.id + "')",200);				
	}
}
function fixLink(o)
{	
	var link = document.getElementById(o)
	link.href = "http://www.casinoonnet-online.com"; 
}
	
function OpenBJSchool(dl,event)
{
	var obj
	if (!document.all)
	{
		obj = event.target.parentNode
		obj.href = "javascript:void 0;";
		
	}	
	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;
	}
	
	Location = "http://standalone.888.com/bjschool/bjschool.htm?lang=en&s=780327321358714709&sr=" + srParam + "&st=94&bc=0&anid=0&dl="+dl;
	//alert(Location);
	window.open(Location,"","resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no,left=0,top=0,width=" + w + ",height=" + h);
	if (!document.all)
	{		
		setTimeout("fixLink('" + obj.id + "')",200);				
	}	
}

function PlayersClub()
{
	if (sr== null)
	{
		srParam = InstallSerial;		/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	window.open("http://playersclub.888.com/Default.asp?sr=" + srParam,"","width=800,height=600,left=50,top=50,resizable=yes,status=yes,scrollbars=auto,toolbar=yes,menubar=yes");
}

function GetSerialByReferrer()
{
	//return a serial number
			
	var serial;
	var referrer = document.referrer.toLowerCase();
	//var referrer = "http://search.msn.com/results.aspx?FORM=MSNH&srch_type=0&q=site%3Awww.casinoonnet-online.com";	 
	if(referrer.length > 0)
	{
		serial = "698014";
		if (referrer.indexOf("msn.") != -1)
		{
			serial = "698012";
		}
		else
			if (referrer.indexOf("google.") != -1)
			{
				serial = "698010";
			}
			else
				if (referrer.indexOf("yahoo.") != -1)
				{
					serial = "698011";
				}
				else
					if (referrer.indexOf("aol.") != -1)
					{
						serial = "698013";
					}
	}
	else
	{
		//no referrer
		serial = InstallSerial;	//default serial
	}	
			
	return serial;
}


/***** set cookie *******/

if (queryString("sr") != 'false')
{
	//get serial from querystring
	setCookie("serial", queryString("sr"),null,"/")	
}
else
{
	if (getCookie("serial") == null)
	{
		//get serial from referrer if any, else use default serial.
		setCookie("serial", GetSerialByReferrer(),null,"/")	
	}
}

if (queryString("flag") != 'false')
{
	//get serial from querystring
	setCookie("flag", queryString("flag"),null,"/")	
}
else
{
	if (getCookie("flag") == null)
	{
		setCookie("flag", "0000" ,null,"/")	
	}
}
/***************************/
