// initialize exit traffic flag (leaving) to true
var leaving = true;

// Exit Traffic prompt; called from onunload event 
// leaving flag is set to false by all links on homepage; if user leaves homepage any other way, flag will still be true
// If flag is true, user is prompted to download
function exitPrompt(){
	if (leaving){
		if(confirm('DOWNLOAD Party Poker\'s FREE poker software before leaving?\n\n*************************************************\nWRITE DOWN THESE BONUS CODES:\n*************************************************\n\n$25 Free on First Deposit: ' + code25 + '\n\n20% Deposit Bonus: ' + code20 + '\n\n(You\'ll need these codes when you register AND when you make your first deposit)')){
			//location.replace('http://www.partypoker.com/Downloads/' + wm + '/PartyPokerSetup.exe');
			location.replace('http://www.partypoker.com/download/index.htm?wm=' + wm);
			//window.open('http://www.partypoker.com/download/index.htm?wm=' + wm,'','');
	    }
	}
}

// Create expiry date one day from today
var exp = new Date();
var OneDayFromNow = exp.getTime() + (1 * 24 * 60 * 60 * 1000);
exp.setTime(OneDayFromNow);

// Function to parse all cookie data
function getCookieDate(labelName){
	var labelLen = labelName.length;
	var cookieData = document.cookie;
	var cLen = cookieData.length;
	var i = 0;
	var cEnd;
	while (i < cLen) {
		var j = i + labelLen;
		if (cookieData.substring(i,j) == labelName) {
			cEnd = cookieData.indexOf(";",j);
			if (cEnd == -1) {
				cEnd = cookieData.length;
			}
			return unescape(cookieData.substring(j+1,cEnd));
		}
		i++;
	}
	return "";
}

// Get value of Visited cookie
var data = getCookieDate('Visited');

// Called from onload event
// Prompts user to download software if Visited cookie has not been found
function download(){
	//if(!(data=="true")){
		// Create cookie and set to expire in one month
		document.cookie = "Visited=true; expires=" + exp.toGMTString();
		if(confirm('DOWNLOAD Party Poker while surfing our site?\n\n**************************************\nWRITE DOWN THESE BONUS CODES:\n**************************************\n\n$25 Free on First Deposit: ' + code25 + '\n\n20% Deposit Bonus: ' + code20)){
			//location.replace('http://www.partypoker.com/Downloads/' + wm + '/PartyPokerSetup.exe');
			location.replace('http://www.partypoker.com/download/index.htm?wm=' + wm)
	    }
	//}
}