var lobbyWindow = null;

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var redirect = readCookie('PBstart');
createCookie('PBstart','set',30)

var wmv = parseInt(readCookie('FIBWMID'));
if (!isNaN(wmv)) value=wmv; else value=3214963;
if(value==null || value=='undefined' || value=='' || value==1000000) value = 3214963;


function launchBingo(){
	if(lobbyWindow != null && !lobbyWindow.closed) {
		lobbyWindow.focus();
		return;
	}
	
	//outerheight=570, outerwidth=788. deltaHeight:33, deltaWidth:7
	if(navigator.appName && navigator.appName.indexOf("Netscape") == -1 && navigator.appVersion.indexOf("Netscape") != -1){
		lobbyWindow = window.open("https://account.fiveplay.tv/launchBingo.do?productID=BINGO&LANG_ID=en_US&wm="+ value +"","Bingo","fullscreen=yes,toolbar=no,status=no,height=715,width=1005,resizable=yes");
	} else {
		lobbyWindow = window.open("https://account.fiveplay.tv/launchBingo.do?productID=BINGO&LANG_ID=en_US&wm="+ value +"","Bingo","toolbar=no,status=no,height=715,width=1005,resizable=yes");
	}
	
}

function joinNow(){
        location.href="https://account.fiveplay.tv/earlyexp/Step3BingoAccount.do?channelID=WC&LANG_ID=en_US&productID=BINGO&brandID=FIVE&regType=threestep&wm="+value;
}