/************************************************************
*@purpose:
*@param:
*@return:
*/
function focusW(){
    window.focus();
}

//setTimeout("focusW()", 420000);//



/************************************************************
*@purpose: verisign func
*@param:
*@return:
*/

function popSign(url)
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,re sizable=1,width=720,height=450');
	self.name = "mainWin";
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function getCookieContent(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;
}



/************************************************************
*@purpose:
*@param:
*@return:
*/
function getCookie(name) {
	var result = getCookieContent(name);
	return (result == null) ? null :  (result[0]);
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function buildUrl(url, lang) {
	var base = 'http://www.joylandcasinocasino.com/';
	return(base+lang+'/'+url);
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function jumpto(url, lang) {
    location.href = buildUrl(url, lang);
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function getMember(name) {
	var result = getCookieContent(name);
	return (result == null) ? null :  (result[0]);
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function getProfile(name) {
	var result = getCookieContent(name);
	return (result == null) ? null : (result[2]);
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function getBanner(name) {
	var result = getCookieContent(name);
	return (result == null) ? null : (result[1]);
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
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();
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function replaceWith(str,char2find,char2replace) {
  var newStr = "";
  for(var i=0 ; i<str.length ; i++)
    if(str.charAt(i) == char2find)
	  newStr += char2replace;
	else
	  newStr += str.charAt(i);
  return newStr;
}

/************************************************************
*@purpose:
*@param:
*@return:
*/
function download(buttonId, lang) {
    if(buttonId==null) buttonId="0000";
  	var urlStr = window.location.href;
  	var pageLang = lang;
 	var urlStrArray = urlStr.split("/");						//seperate url into array, "/" is the seperator
  	var pageStr = urlStrArray[urlStrArray.length-1];			//page name is the last in the array
  	var len = pageStr.indexOf("."); 							//find seperator between file name and extension
  	var pageName = pageStr.substr(0,len);						//seperate file name from extension (save file name)
	if(pageName=="") pageName = "index";						//if ".com" address with no actual file
  	var finalStr = pageLang + "+" + pageName + "+" + buttonId;	//"+" is the seperator of the final string
	finalStr = replaceWith(finalStr,"_","-");					//replace all the "_" with "-" because the cgi won't accept "_".


	mbr = getMember('banner_domainclick');
	prf = getProfile('banner_domainclick');

	if(lang != 'undefined') lang = 'es';
    // checking from what tracking link coming
    var wwwd = "banner";
    // Pixel code
	var pixelSrc='';
	switch(mbr){
		case 'struq':
		pixelSrc = "http://this.content.served.by.adshuffle.com/p/kl/46/799/r/12/4/8/t/580/rmktg/track.gif";
		break;
	}
	if(pixelSrc)
		createPixel(pixelSrc);


	if(getMember("banner_click") != null) {
		//alert("wwww cookie was found");
		//wwwd = "www"; // TODO!!!!!!!!!!!!!!!!!!!!!check
	}

    var down_url = "http://"+wwwd+".joylandcasino.com/cgi-bin/SetupCasino.exe?opt_lang="+lang+"&member="+mbr+"&profile="+prf;

      var sURLpop = "http://www.joylandcasino.com/"+lang+"/getting_started.php";
	var sURLreg = down_url;

	var a21 = window.open(sURLreg,"d12863","width=1,height=1,top=150,left=1,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no");
	a21.blur();
	document.location.href = sURLpop;

	return true;
}

function createPixel(pixelSrc){
		var pixel= new Image(1,1); 
		pixel.src = pixelSrc;
		document.body.appendChild(pixel);
}


/************************************************************
*@purpose:
*@param:
*@return:
*/
function downloadpage() {
	if (document.readyState=='loading')	{
        setTimeout("downloadpage()",200);
    }
	else {
        location.href = 'http://www.joylandcasino.com/'+webLang+'/getting_started.php';
    }
}

/************************************************************
*@purpose:	Will change source of image (imageName.gif) to new one (imageName_o.gif) on mouse over (usually)
*@param:		img Image that will have rollover
*					name Image source
*@return:
*/
function rollover(img, name) {
	var index = name.indexOf("_o.gif");
    var imgName="";

    if (index!=-1) {
 	   imgName= name.substr(0,index);
       imgName = imgName + ".gif"
    }
    else {
    	index = name.indexOf(".gif");
        imgName= name.substr(0,index);
        imgName = imgName + "_o.gif";
    }

    img.src = imgName;
}

 // 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>');
			var seoActive = true;
		}
}
// End of SE referrers