/////////////////////////////////////////////////////////////


/* This function takes in a game id and gametype param (flash /java)
and determines if the user is logged in. If they are, it writes a game link, otherwise
it writes a link to the register page */

function play_or_reg_img (gametype, gameid) {
	if (document.cookie.indexOf("logged_in") != -1) {
		// LOGGED IN
		var username = getCookie('username');
		var email = getCookie('email');
		
		//Write game url to page, with gameid, gametype, email and username
		document.write("<a href=\"http://www.datablade.com/cgi-bin/software.html/730055/InterCasino%20Installer.exe\">");
		//alert("<a href=\"#\" onclick=\"MM_openBrWindow('http://practice.ifunds.com/C2/00/instant_" + gametype + ".ehtml?Alias=" + username + "&Email=" + email + "&GameID=" + gameid + "&BrandID=C2','','width=600,height=500')\">CLICK TO PLAY</a>");
	}
	else {
		//NOT LOGGED IN
		document.write("<a href=\"login.html\">");
	}
}

//Close A tag for image. Messy but neccessary. Or meccessary...
function img_close() {
	document.write("</a>");
}

function getuser_embed() {
	if (document.cookie.indexOf("logged_in") != -1) {
		var username = getCookie('username');
		var email = getCookie('email');
		//Write game url to page, with gameid, gametype, email and username
		document.write("<embed src=\"/images/games_v2.swf?loggedin=1&alias=" + username +"&playeremail=" + email + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"440\" wmode=\"transparent\"></embed>");
		//alert("<embed src=\"/images/games_v2.swf?loggedin=1&alias=" + username +"&playeremail=" + email + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"440\" wmode=\"transparent\"></embed>");
	}
	else {
		//NOT LOGGED IN
		document.write("<embed src=\"/images/games_v2.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"440\" wmode=\"transparent\"></embed>");
	}
	
}

function getuser_name_param() {
	if (document.cookie.indexOf("logged_in") != -1) {
		var username = getCookie('username');
		var email = getCookie('email');
		//Write game url to page, with gameid, gametype, email and username
		document.write("<param name=\"movie\" value=\"/images/games_v2.swf?loggedin=1&alias=" + username +"&playeremail=" + email + "\">");
		//alert("<embed src=\"/images/games_v2.swf?loggedin=1&alias=" + username +"&playeremail=" + email + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"440\" wmode=\"transparent\"></embed>");
	}
	else {
		//NOT LOGGED IN
		document.write("<param name=\"movie\" value=\"/images/games_v2.swf\">");
	}
	
}
function getCookie(Name) {   	

	var search = Name + "="   

	if (document.cookie.length > 0) { 
	
	// if there are any cookies      
	offset = document.cookie.indexOf(search)       

	if (offset != -1) { 
		// if cookie exists          
		offset += search.length          
		// set index of beginning of value         
		end = document.cookie.indexOf(";", offset)          
		// set index of end of cookie value         
		if (end == -1)             
			end = document.cookie.length         
			return unescape(document.cookie.substring(offset, end))      
		}    
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}