// JavaScript Document

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('PBWMID'));
if (!isNaN(wmv)) value=wmv; else value=2938711;
if(value==null || value=='undefined' || value=='' || value==1000000) value = 2938711;

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://secure.partyaccount.com/launchBingo.do?productID=BINGO&LANG_ID=es_ES&wm="+ value +"","Bingo","fullscreen=yes,toolbar=no,status=no,height=715,width=1005,resizable=yes");
	} else {
		lobbyWindow = window.open("https://secure.partyaccount.com/launchBingo.do?productID=BINGO&LANG_ID=es_ES&wm="+ value +"","FlashClient","toolbar=no,status=no,height=715,width=1005,resizable=yes");
	}

}

function joinNow(){
		var link = "https://secure.partyaccount.com/earlyexp/Step3BingoAccount.do?channelID=WC&LANG_ID=es_ES&productID=BINGO&brandID=PARTY&regType=threestep&wm=" + value;
	  	if (window.TDPEH) link += '&tdpeh=' + window.TDPEH;
        location.href=link;
        
}
