

/**This file is used by affiliates in order display free games on their site*/

var timeOutInfinite = 0;
var timeOutBJ = 3;
var timeOutRoulette = 3;
var timeOutVSlots = 3.5;
var timeOutSlots = 4;
var timeOutBingo = 10;
var timeOutPoker = 6;
var timeOut = timeOutInfinite;
var unbranded = false;

// To display rules popup from supplier's site.
function rules(url)
{
	var features="directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=440,height=420";
	var remote = open(url, "rules", features);
}

function getGameName(gameId)
{
		unbranded = false;

		switch (gameId)
		{
			case 1: 
			case 2:
			case 5:
			case 11:
			case 18:
			case 20:
			case 21:
			case 26:
			case 30:
			case 34:
			case 36:
			case 38:
			case 41:
			case 48:
			case 50:
			case 53:
			case 66:
			case 126:
			case 134:
			case 151:
			case 181:
			case 184:
			case 188:
			case 211:
			case 214:
			{						
				timeOut = timeOutBJ; //In Minutes
				return "blackjackmini";
			}

			case 217:
			{
				unbranded = true;
				timeOut = timeOutInfinite;
				return "blackjackmini";
			}
			
			case 3:
			case 4:
			case 7:
			case 12:
			case 22:
			case 27:
			case 40:
			case 46:
			case 51:
			case 54:
			case 67:
			case 123:
			case 128:
			case 154:
			case 207:
			case 213:
			{			
				timeOut = timeOutRoulette;
				return "lrroulette2french";
			}

			case 218:
			{							
				unbranded = true;
				timeOut = timeOutInfinite;
				return "lrroulette2french";
			}

			case 6:
			case 10:
			case 13:
			case 19:
			case 24:
			case 29:
			case 32:
			case 35:
			case 37:
			case 39:
			case 45:
			case 47:
			case 56:
			case 61:
			case 79:
			case 129:
			case 135:
			case 152:
			case 182:
			case 185:
			case 192:
			{			
				timeOut = timeOutVSlots;
				return "jackpot6k";
			}

			case 210:
			{
				unbranded = true;
				timeOut = timeOutInfinite;
				return "jackpot6k";
			}
				
			case 8:
			case 58:
			case 63:
			case 81:
			case 141:
			case 178:
			{							
				timeOut = timeOutSlots;
				return "arabian";
			}

			case 9:
			case 100:
			case 155:
			{
				timeOut = timeOutVSlots;
				return "luckyeight";
			}
				
			case 14:
			case 31:
			case 52:
			case 55:
			case 57:
			case 62:
			case 80:
			case 124:
			case 136:
			case 142:
			case 153:
			case 183:
			case 186:
			case 187:
			case 190:
			case 191:
			{
				timeOut = timeOutSlots;
				return "relicraiders";
			}
	
			case 15:
			case 87:
			case 130:
			case 197:
			{
				timeOut = timeOutSlots;
				return "frog";
			}
	
			case 16:
			case 91:	
			case 144:
			{
				timeOut = timeOutSlots;
				return "viking";
			}
				
			case 17:
			case 73:
			case 127:
			case 180:
			case 189:
			case 204:
			{
				timeOut = timeOutPoker;
				return "cstudflash";
			}
				
			case 23:
			case 28:
			case 44:
			case 120:
			case 125:
			case 131:
			case 175:
			{
				timeOut = timeOutSlots;
				return "wizards";
			}
	
			case 33:
			case 60:
			case 65:
			case 83:
			case 215:
			{
				timeOut = timeOutVSlots;
				return "megajoker";
			}

			case 42:			
			case 112:
			case 169:
			{
				timeOut = timeOutPoker;
				return "jacksorbetter1";
			}

			case 43:
			case 116:
			case 171:
			{
				timeOut = timeOutPoker;
				return "jokerwild1";
			}

			case 49:
			case 68:
			case 205:
			case 212:
			{
				timeOut = timeOutPoker;
				return "oasispoker";
			}

			case 59:
			case 64:
			case 82:
			{
				timeOut = timeOutVSlots;
				return "beetle";
			}

			case 69:
			{
				timeOut = timeOutPoker;
				return "txsholdem";
			}

			case 70:
			{
				timeOut = timeOutPoker;
				return "treypoker-1h";
			}

			case 71:
			case 207:
			{
				timeOut = timeOutPoker;
				return "lrletitride2";
			}

			case 72:
			{
				timeOut = timeOutPoker;
				return "casinoholdem";
			}

			case 74:
			{
				timeOut = timeOutPoker;
				return "reddog";
			}

			case 75:
			{
				timeOut = timeOutPoker;
				return "hilo";
			}

			case 84:
			case 132:
			case 137:
			case 194:
			{
				timeOut = timeOutSlots;
				return "excalibur";
			}

			case 85:
			case 148:
			{
				timeOut = timeOutSlots;
				return "geisha";
			}
			
			case 86:
			case 196:
			{
				timeOut = timeOutSlots;
				return "ice";
			}

			case 88:
			case 179:
			case 195:
			{
				timeOut = timeOutSlots;
				return "pacific";
			}

			case 89:
			case 139:
			{
				timeOut = timeOutSlots;
				return "krakow";
			}

			case 90:
			case 145:
			{
				timeOut = timeOutSlots;
				return "voodoo";
			}

			case 96:
			case 206:
			{
				timeOut = timeOutBingo;
				return "kenobnjp";
			}

			case 97:
			{
				timeOut = timeOutBingo;
				return "lrscratchticket";
			}

			case 98:
			{
				timeOut = timeOutBingo;
				return "hrscratchticketjp";
			}

			case 99:
			{
				timeOut = timeOutBingo;
				return "bingo";
			}

			case 101:
			case 156:
			{
				timeOut = timeOutVSlots;
				return "luckyeightlove";
			}

			case 102:
			case 157:
			{
				timeOut = timeOutVSlots;
				return "luckyeightsafari";
			}	

			case 103:
			case 158:
			{
				timeOut = timeOutVSlots;
				return "goldrushflash";
			}

			case 104:
			case 146:
			case 159:
			{
				timeOut = timeOutVSlots;
				return "piratesgold2";
			}

			case 105:
			case 160:
			{
				timeOut = timeOutVSlots;
				return "vault";
			}

			case 110:
			{
				timeOut = timeOutPoker;
				return "shvideopokerdw";
			}

			case 117:
			case 172:
			{
				timeOut = timeOutPoker;
				return "allamerican1";
			}
			
			case 109:
			case 209:
			{
				timeOut = timeOutPoker;
				return "fhvideopokerjob";
			}

			case 115:
			case 170:
			{
				timeOut = timeOutPoker;
				return "deuceswild1";
			}

			case 118:
			case 173:
			{
				timeOut = timeOutSlots;
				return "tiki";
			}

			case 119:
			case 143:
			case 174:
			{
				timeOut = timeOutSlots;
				return "crusaders";
			}

			case 121:
			case 140:
			case 176:
			{
				timeOut = timeOutSlots;
				return "mansion";
			}

			case 122:
			case 147:
			case 177:
			{	
				timeOut = timeOutSlots;				
				return "fishyfortune";
			}

			case 138:
			case 149:
			case 203:
			{
				timeOut = timeOutInfinite;
				return "horserace";
			}

			case 150:
			case 198:
			case 199:
			case 202:
			{
				timeOut = timeOutVSlots;				
				return "reelsteal";
			}

			case 193:
			case 200:
			case 201:
			case 216:
			{
				timeOut = timeOutVSlots;				
				return "devil";
			}
	}
}

function getAffiliateCode(gameId)
{
	switch (gameId)
	{
		case 2:
		case 3:
			return "kph599";

		case 5:	
		case 6:
		case 7:
		case 8:
		case 9:
		case 10:
		case 14:
		case 15:
		case 16:
		case 17:
			return "pelikassa";

		case 11:
		case 12:
		case 13:
			return "askgamblers";

		case 18:
		case 19:
			return "Elgoog";

		case 20: 
			return "spelapoker";

		case 21:
		case 22:
		case 23:
		case 24:
		case 25:
		case 26:
		case 27:
		case 28:
		case 29:
		case 30:
		case 31:
		case 32:
		case 33:
			return "Weblight";

		case 34:
		case 35:
			return "kasino";

		case 36:
		case 37:
			return "casino-spel";

		case 38:
		case 39:
		case 40:
		case 41:
			return "casinosnl";

		case 42:
		case 43:
		case 44:
		case 45:
			return "caver1";

		case 46:
		case 47:
			return "alainla";

		case 48:
			return "ccity";
			
	}
}

function getUniqueName(prefix, gameName)
{
	var found = 1;
	var count = 0;
	
	while (true)
	{
		var x = document.getElementById (prefix + gameName + count);
		if (x == null)
		{
			return prefix + gameName + count;
		}
		count++;
	}
}

function showGameAff (gameId, lang, height, width, affcode)
{
	var gameName      = getGameName(gameId);					
	var objectId      = getUniqueName ("game", gameName);
	var divName       = getUniqueName ("div", gameName);
	var tableName     = getUniqueName ("table", gameName);
	var ruleServer    = "http://casinoeuro-proxy.casinomodule.com";		
	var gameServer    = "http://casinoeuro-proxy.casinomodule.com/";
	var unbrandedPath = unbranded ? "unbranded/" : ""; 
	var gameURL       = gameServer + "flash/" + unbrandedPath + gameName + "/" + lang + "/loader.swf"; 
		
	
	var flashVars  = "gameId=" + gameName +"&" +
					 "lang=" + lang + "&" +
					 "currencyChar=EUR&" +
					 "symbol1=EUR&" +
					 "symbol2=c&" +
					 "gameurl=" + 	gameName + ".swf&" +
					 "server=" + gameServer + "&fullscreen=false";
					 					 		
/*	document.write ('<div style=\"margin: 0px\" id=\"' + divName + '\">') +
						'<table border=\"0\" style=\"border-style: none; margin: 0px; cellpadding: 0%; cellspacing: 0%; width: ' + width +'; height: ' + height + '\" id=\"' + tableName + '\">' +
							'<tr border=\"0\" style=\"border-style: none \">' +
								'<td border=\"0\" style=\"border-style: none \">');	*/			

	document.write ('<div style=\"margin: 0px; valign: center\" id=\"' + divName + '\">');
	
	var strFlash = "<object " +
	 "classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'" + 
		" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'" + 
		" WIDTH='" + width + "' " +
		" HEIGHT='" + height + "' " +
		" id='" + objectId + "'" + 
		" ALIGN=''>" +
		"<param name=\"allowScriptAccess\" value=\"always\">" +
		"<param name=\"movie\" value=\"" + gameURL +"\">" +
		"<param name=\"base\" value=\".\">" +
		"<param name=\"scale\" value=\"exactfit\">" +
		"<param name=\"quality\" value=\"high\">" +
		"<param name=\"bgcolor\" value=\"#002678\">" +
		"<param name=\"FlashVars\" value=\"" + flashVars + "\">" +

		" <embed" +
		" src='" + gameURL +"'" +
		" quality='high'" +
		" bgcolor='#002678'" +
		" ALLOWSCRIPTACCESS='ALWAYS'" +
		" base='.'" +
		" width='" + width + "'" +
		" height='" + height + "'" +
		" name='" + objectId + "'" +
		" align=''" +
		" scale='exactfit'" +
		" type='application/x-shockwave-flash'" +
		" pluginspage='http://www.macromedia.com/go/getflashplayer'" +
		" FlashVars='" + flashVars + "'></EMBED>" +
		"</OBJECT>";
	
	document.write (strFlash);	
	document.write ('</div>');
	
	if (timeOut != timeOutInfinite)
	{ 	
		setTimeout ("replaceFlash('" + divName + "','" + height + "','" + width + "','" +  lang + "','" + tableName + "','" + affcode + "')", timeOut * 60000);
	}	
}

function showGame (gameId, lang, height, width)
{
	showGameAff (gameId, lang, height, width, getAffiliateCode(gameId));
}

function getNewFlashLang(currentLang)
{
	if (currentLang.toLowerCase() == "de" || currentLang.toLowerCase() == "en" || currentLang.toLowerCase() == "fi" || currentLang.toLowerCase() == "fr" || 
		currentLang.toLowerCase() == "nl" || currentLang.toLowerCase() == "no" || currentLang.toLowerCase() == "sv")
	{
		return currentLang;
	}

	return "en";
}


function replaceFlash(divId, height, width, lang, tableName, affiliate)
{
	var flashDiv = document.getElementById (divId);	
	var tableHTMLStart = '<table border=\"0\" id=\"' + tableName + 
						 '\"><tr><td align=\"center\" valign=\"center\" height=\"' + height + '\" width=\"' + width + '\">';									
	var tableHTMLEnd = '</td></tr></table>';									
	var proportion   = 489 / 641;
	var newFlashId = getUniqueName ("flash", "CE");	
	var newFlashURL = "http://www.casinoeuro.com/" + getNewFlashLang(lang) + "/flash/ce-freeplay-site-prompt.swf";
    var clickTag    = "http%3A//www.casinoeuro.com/" + lang + "/casino-games/%3Ffrom%3D" + affiliate;
		
	var newFlash = "<object " +
	 "classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'" + 
		" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'" + 
		" WIDTH='" + width + "' " +
		" HEIGHT='" + width * proportion + "' " +
		" id='" +newFlashId + "'" + 
		" ALIGN=''>" +
		"<param name=\"allowScriptAccess\" value=\"always\">" +
		"<param name=\"movie\" value=\"" + newFlashURL + "?clickTAG=" + clickTag + "\">" +
		"<param name=\"base\" value=\".\">" +
		"<param name=\"scale\" value=\"exactfit\">" +
		"<param name=\"quality\" value=\"high\">" +
		"<param name=\"bgcolor\" value=\"#002678\">" +
	    
		
		" <embed" +
		" src='" + newFlashURL + "?clickTAG=" + clickTag + "' " +
		" quality='high'" +
		" bgcolor='#002678'" +
		" ALLOWSCRIPTACCESS='ALWAYS'" +
		" base='.'" +
		" width='" + width + "'" +
		" height='" + width * proportion + "'" +
		" name='" + newFlashId + "'" + 
		" align=''" +
		" scale='exactfit'" +
		" type='application/x-shockwave-flash'" +
		" pluginspage='http://www.macromedia.com/go/getflashplayer' </EMBED>" +
		"</OBJECT>";

	flashDiv.innerHTML =newFlash;	
}