var CorentLang = "en";
var InstallSerial = "693939";
var ssr = 106144;
var PopupWindow,MoreInfo;
var sFlag = "no";
var byFlag = false;
var isIT = false;
var isUK = false;
var UKWindow;
var sLang = "en";
var windowY = ((screen.availHeight-260)/2);
var windowX = ((screen.width-340)/2);
var ofw


var FlagAr = sFlag.split("");
if (FlagAr[0]=="1"){byFlag = true;}

if(document.all)
{
    if(document.all['scrollPict'])
    {
		window.document.all['scrollPict'].style.width='100%';
        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=117-diff;
                
             }
                
        }
        else
            window.document.all['scrollPict'].style.left=1;
        if(ofw<820)
            window.document.all['scrollPict'].style.left=1;
    }
}

var ShowPopup = true;

if (getCookie("flag"))
	if(getCookie("flag").substring(3,4) == "1")	// "1001" or "0001"
		ShowPopup = false;
	
	
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 != null))
	{
	/*
		if(mEvent.srcElement)
			ref = srcEl.getAttribute("href")
			
		else
			{
				//firefox
				var lastSlash = document.location.href.lastIndexOf("/");
				var directory = document.location.href.substring(0,lastSlash);
				ref = directory + '/' + srcEl.getAttribute("href");
				
			}
*/

		ref = 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("INSTALLER") != -1)||
				(ref.indexOf("CASINO-ON-NET") != -1)||
				(ref.indexOf("10.10.10") != -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 (getCookie("isDownload") == null)
			{
				if (window.confirm("Find out now why everyone is playing Poker at Pacific Poker."))
				{
					window.open("http://www.pacificpoker.com/?sr=" + getCookie("serial"));
				}
			}
		}
	}
}

function PopUpEntry()
{
	
	if (getCookie("isPopUpEntry") == null)
	{
		//set PopUpEntry flag to pop only once in the session
		setCookie("isPopUpEntry", "true" ,null,"/")
		
		if (window.confirm("Click OK to download our free software while browsing the site!"))
		{
			ShowPopup = false;
			window.location.href = "http://www.888.com/CasinoInstaller?lang=en&sr=" + getCookie("serial")
			//window.open("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 Affiliates(ElementName)
{
	var sr = getCookie("serial");
	var srParam;
	
	if (sr==null)
	{
		srParam = InstallSerial;		/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	sURL = "javascript:void(0);"
	document.getElementById(ElementName).setAttribute("href",sURL);
	
	window.open("http://affiliates.888.com?sr=" + srParam ,"","width=800,height=600,left=50,top=50,resizable=yes,status=no,scrollbars=auto,toolbar=no,menubar=no");
}

function InviteFriend(ElementName)
{
	//alert('InviteFriend')
	var sr = getCookie("serial");
	var srParam;
	
	if (sr==null)
	{
		srParam = InstallSerial;		/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	sURL = "javascript:void(0);"
	document.getElementById(ElementName).setAttribute("href",sURL);
	
	window.open("http://www.888.com/new888/home.htm?page=iafform&lang=en&sr=" + srParam,"","width=800,height=600,left=50,top=50,resizable=yes,status=no,scrollbars=auto,toolbar=no,menubar=no");
}

function ExperiencePlayers(obj)
{
	var sr = getCookie("serial");
	var srParam;
	
	if (sr==null)
	{
		srParam = InstallSerial;		/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	var tmpHref = document.getElementById("ExperiencePlayers");	
	tmpHref.href = "http://www.casinoonnet-online.com/?sr=" + srParam;
	
	//window.open("http://www.casinoonnet-online.com/?sr=" + srParam,"","width=800,height=600,left=50,top=50,resizable=yes,status=no,scrollbars=auto,toolbar=no,menubar=no");
}

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);
}

function PlayersClub(ElementName)
{
	var sURL;
	var sr = getCookie("serial");
	var srParam;
	
	if (sr == null)
	{
		srParam = InstallSerial;		/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	sURL = "javascript:void(0);"
	document.getElementById(ElementName).setAttribute("href",sURL);
		
	window.open("http://playersclub.888.com?sr=" + srParam,"","width=800,height=600,left=50,top=50,resizable=yes,status=no,scrollbars=auto,toolbar=no,menubar=no");	
}

function Download(ElementName)
{
	var sURL;
	var sr = getCookie("serial");
	var srParam;
	
	//set download flag to true
	if (getCookie("isDownload") == null)
	{
		setCookie("isDownload", "true" ,null,"/")	
	}
		
	if (sr == null)
	{
		srParam = InstallSerial;
	}
	else
	{
		srParam = sr;
	}
	
	sURL = "http://www.888.com/CasinoInstaller?lang=en&sr=" + srParam;
	document.getElementById(ElementName).setAttribute("href",sURL);
		
	//sURL = 'http://www.888.com/CasinoInstaller?lang=en&sr=' + srParam;
	//document.location.href = sURL;
		
}

function NoDownload(ElementName)
{
	var sURL;
	var Location;
	var sr = getCookie("serial");
	var srParam;
	
	if (sr==null)
	{
		srParam = InstallSerial;	/*use a the default serial*/
	}
	else
	{
		srParam = sr;
	}
	
	sURL = "javascript:void(0);"
	document.getElementById(ElementName).setAttribute("href",sURL);
	
	//Location = "http://flash.888.com/start.asp?Mode=1&lang=en&sr=" + srParam + "&Real=1";
   //LangID=" + sLang + "&sr=" + sSerial + "&anid=" + sANID + "I" + trackingID
	Location = "http://ndl.888.com/casino/application/ViewActual.html?LangID=en&sr=" + srParam + "&mode=2";
	window.open(Location,"","width=800,height=600,left=50,top=50,resizable=no,status=no,scrollbars=auto,toolbar=no,menubar=no");
}

function getOperatingSystem()
{
    var s = new String(navigator.appVersion);
    if (navigator.appName == "Netscape")
    {
        var o = s.substring((s.indexOf("(") + 1),(s.indexOf(";",(s.indexOf("(") + 1))));
    }
    else
    {
        var o = "[undetermined]";
        if(s.indexOf("Windows 95") != -1){o = "Win95"};
        if(s.indexOf("Windows 98") != -1){o = "Win98"};
        if(s.indexOf("Windows NT") != -1){o = "WinNT"};
        if(s.indexOf("Macintosh") != -1){o = "Macintosh"};
    }
    return o;
}

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 HandCursor(obj)
{
    obj.style.cursor='hand';
}

function OpenPopUp(Look,location)
{
    var w = 314;
    var h = 459;
    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2; 
    var filename = "popupgames.htm";
    
    if ((Look == "33") || (Look == "34")){filename = location + "msenter.htm"; h = 360;} // Mini Site
    window.open(filename + "?lang=en&S=069548665060948518&OS=069548665060948518&SR=293897&OSR=293897&flag=no&un=true&ver=java&l=&geo=0&st=79&dl=0",null,
    "height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,location=no,resize=no,left="+l+",top="+t);
}

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 OpenPop(address)
{
    var w = 480; 
    var h = 350;
    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2;
    var windowprops = "location=no,scrollbars=auto,menubars=no,toolbars=no,resizable=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
    window.open(address,"Flash",windowprops);
}

function openPromWindow(num)
{
	
		var url= "http://playersclub.888.com/Default.asp?lang=en&S=069548665060948518&OS=069548665060948518&SR=293897&OSR=293897&flag=no&un=true&ver=java&l=&geo=0&st=79&dl=0";
    
    if(num != 0)
        url = url+"&TN="+ num

    nwin=window.open(url, "nwin",config="scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,menubar=yes,height=450,width=650");
    nwin.focus();
}

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 == InstallSerial || SRparam == null)
	{
		SRparam = "928336"; //Default serial
	}
	
	var sURL = 'http://www.pacificpoker-online.com?sr='+ SRparam;
	
	document.getElementById("pcpoLink").setAttribute("href",sURL);
}

function GoToPCP()
{
	var SRparam = getCookie("serial");
	if (SRparam == InstallSerial || SRparam == null)
	{
		SRparam = "928336"; //Default serial
	}
	
	var sURL = 'http://www.pacificpoker.com/?sr='+ SRparam;
	
	document.getElementById("pcpLink").setAttribute("href",sURL);
}

function GoToNoExitPopUp(url)
{
	ShowPopup = false;
	document.location.href=url;
}


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";
    }
}


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;
			
	//	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 GetSTSerialValue(ref,ParamName)
	{
		//return the value depending with the keyword value
		var st;
		var stValue;
		
		stValue = 520
		
		//find search term
		st= ReferrerQueryString(ref,ParamName)
		
		if (st=="false" || st=="")
		{
			stValue = 524;
		}
		else
			if (st.indexOf("888") != -1)
			{
				//search term has "888"
				stValue = 0;
			}
			else
				if(st.indexOf("casinoonnet") != -1 || st.indexOf("casino-on-net") != -1 || st.indexOf("casino+on+net") != -1)
				{
					//search term has "casinoonnet"
					stValue = 1;
				}
				else
					if(st.indexOf("pacific") != -1)
					{
						//search term has "pacific"
						stValue = 2;
					}
				
		return stValue;
	}
	
function GetCountryValue(ref)
	//return the value of the country of the referrer
	{
		var str;
		var CountryValue;
		str = ref.split("?")[0];
		
		
		
			if (str.indexOf(".co.uk") != -1 || str.indexOf("uk.") != -1)
			{
				CountryValue = 5;
			}
			else
				if (str.indexOf(".ca") != -1 || str.indexOf("ca.") != -1)
				{
					CountryValue = 10;
				}
				else
					if (str.indexOf(".fr") != -1 || str.indexOf("fr.") != -1)
					{
						CountryValue = 15;
					}
					else
						if (str.indexOf(".es") != -1 || str.indexOf("es.") != -1)
						{
							CountryValue = 20;
						}
						else
							if (str.indexOf(".it") != -1 || str.indexOf("it.") != -1)
							{
								CountryValue = 25;
							}
							else
								if (str.indexOf(".de") != -1 || str.indexOf("de.") != -1)
								{
									CountryValue = 30;
								}
								else
									if (str.indexOf(".au") != -1 || str.indexOf("au.") != -1)
									{
										CountryValue = 35;
									}
									else
										if (str.indexOf(".mx") != -1 || str.indexOf("mx.") != -1 ||str.indexOf(".pr") != -1 || str.indexOf("pr.") != -1 || str.indexOf(".br") != -1 || str.indexOf("br.") != -1 || str.indexOf(".ar") != -1 || str.indexOf("ar.") != -1 || str.indexOf(".no") != -1 || str.indexOf("no.") != -1 || str.indexOf(".se") != -1 || str.indexOf("se.") != -1 || str.indexOf(".dk") != -1 || str.indexOf("dk.") != -1 || str.indexOf(".gr") != -1 || str.indexOf("gr.") != -1 || str.indexOf(".asia") != -1 || str.indexOf("asia.") != -1 || str.indexOf(".cn") != -1 || str.indexOf("cn.") != -1 || str.indexOf(".sg") != -1 || str.indexOf("sg.") != -1 || str.indexOf(".kr") != -1 || str.indexOf("kr.") != -1 || str.indexOf(".co.jp") != -1 || str.indexOf("jp.") != -1 || str.indexOf(".tw") != -1 || str.indexOf("tw.") != -1 || str.indexOf(".hk") != -1 || str.indexOf("hk.") != -1)
										{
											CountryValue = 40;
										}
										else
											if (str.indexOf(".com") != -1)
											{
												CountryValue = 0;
											}
											else
												CountryValue = 40;
		return CountryValue;
		
	}

function BuildSerialByReferrer()
	{
		//return a serial number
		//uses functions:
		//	GetCountryValue to get country code
		//	GetSTSerialValue to get st code
			
		var serial;
		var seValue;	//search Engine 
		var os;	
		
		var countryValue;
		var stValue;	//search term
		var referrer = document.referrer.toLowerCase();
		//var referrer = "http://search.aol.com/aolcom/search?invocationType=comnonmem&query=dddd&Search=";
		var PageURL;
		var ReferrerQueryString;
		
		os = 108326;	//base serial
		stValue = 0;
		seValue = os;
		countryValue = 0;
		
		if(referrer.length > 0)
		{
			PageURL = referrer.split("?")[0];
			if (referrer.split("?").length > 0)
				ReferrerQueryString = referrer.split("?")[1];
			else
				ReferrerQueryString = "";
				
				
			// find search engine
			if (PageURL.indexOf("google.") != -1)
			{
				//referrer is "google"
				countryValue = GetCountryValue(referrer)
				seValue = ssr;
				stValue = GetSTSerialValue(ReferrerQueryString,"q");
			}
			else
				if(PageURL.indexOf("yahoo.") != -1)
				{
					//referrer is "yahoo"
					countryValue = GetCountryValue(referrer)
					seValue = ssr+65;
					stValue = GetSTSerialValue(ReferrerQueryString,"p");
				}
				else
					if(PageURL.indexOf("msn.") != -1)
					{
						//referrer is "msn"
						countryValue = GetCountryValue(referrer)
						seValue = ssr+130;
						stValue = GetSTSerialValue(ReferrerQueryString,"q");
					}
					else
						if(PageURL.indexOf("aol.") != -1)
						{
							//referrer is "aol"
							countryValue = GetCountryValue(referrer)
							seValue = ssr+195;
							
							stValue = GetSTSerialValue(ReferrerQueryString,"q");
							if (stValue==520 || stValue==524)
								stValue = GetSTSerialValue(ReferrerQueryString,"query");
						}
						else
							if(PageURL.indexOf("prweb.") != -1)
							{
								//referrer is "prweb"
								seValue = os+1;
							}
							else
								if(PageURL.indexOf("hotbot.") != -1)
								{
									//referrer is "hotbot"
									seValue = os+2;
								}
								else
									if(PageURL.indexOf("altavista.") != -1)
									{
										//referrer is "altavista"
										seValue = os+3;
									}
									else
										if(PageURL.indexOf("teoma.") != -1)
										{
											//referrer is "teoma"
											seValue = os+4;
										}
										else
											if(PageURL.indexOf("excite.") != -1)
											{
												//referrer is "excite"
												seValue = os+5;
											}
											else
												if(PageURL.indexOf("lycos.") != -1)
												{
													//referrer is "lycos"
													seValue = os+6;
												}
												else
													if(PageURL.indexOf("askjeevs.") != -1)
													{
														//referrer is "askjeevs"
														seValue = os+7;
													}
													else
														if(PageURL.indexOf("netscape.") != -1)
														{
															//referrer is "netscape"
															seValue = os+8;
														}
														else
															if(PageURL.indexOf("dogpile.") != -1)
															{
																//referrer is "dogpile"
																seValue = os+9;
															}
															else
																if(PageURL.indexOf("webcrawler.") != -1)
																{
																	//referrer is "webcrawler"
																	seValue = os+10;
																}
																else
																	if(PageURL.indexOf("metacrawler.") != -1)
																	{
																		//referrer is "metacrawler"
																		seValue = os+11;
																	}
																	else
																		if(PageURL.indexOf("iwon.") != -1)
																		{
																			//referrer is "iwon"
																			seValue = os+12;
																		}
																		else
																			if(PageURL.indexOf("about.") != -1)
																			{
																				//referrer is "about"
																				seValue = os+13;
																			}
																			else
																				if(PageURL.indexOf("joeant.") != -1)
																				{
																					//referrer is "joeant"
																					seValue = os+14;
																				}
																				else
																					if(PageURL.indexOf("myway.") != -1)
																					{
																						//referrer is "myway"
																						seValue = os+15;
																					}
						
					
			//alert("seValue=" + seValue + " stValue=" + stValue + " countryValue=" + countryValue);
			serial = seValue + stValue + countryValue;
		}
		else
		{
			//no referrer
			serial = InstallSerial;
		}	
				
		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", BuildSerialByReferrer(),null,"/")	
	}
}

if (queryString("flag") != 'false')
{
	//get serial from querystring
	setCookie("flag", queryString("flag"),null,"/")	
}
else
{
	if (getCookie("flag") == null)
	{
		setCookie("flag", "0000" ,null,"/")	
	}
}
/***************************/


/**
 * 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);
        }
}