function writeFlash(movie, fallback, width, height, id, paramlist, wmode, swLiveConnect, color) {
	
	// major, minor, revision
	var hasReqestedVersion = DetectFlashVer(8, 0, 0);

	var isNC = location.href.indexOf("nightclub") > 0;
	var isPlayboy = location.href.indexOf("playboy") > 0;
	var color = "333333";
	var sitename = "maxdome";
	
	if(isPlayboy) {
		color = "000000";
		sitename = "nightclub.de";
	} else if(isNC) {
		color = "880000";
		sitename = "nightclub.de";
	}

	fallback = '<div id="' + id + '_flashcontainer" style="width:' + width + 'px; height:' + height + 'px; background-color:#' + color + ';"><div style="padding:20px;">Um ' + sitename + ' nutzen zu können, benötigen Sie den Adobe Flash Player.<br /><br /><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">&gt; Hier geht es zum kostenlosen Download!</a></div></div>';

	if(hasReqestedVersion) {
		document.write(getFlash(movie, fallback, width, height, id, paramlist, wmode, swLiveConnect, color));
	} else {
		document.write(fallback);
	}
	
	return;
	
	
	if(hasReqestedVersion) {
		document.write(getFlash(movie, '', width, height, id, paramlist, wmode, swLiveConnect, color));
	} else {
		document.write('<div id="' + id + '_flashcontainer" style="width:' + width + 'px; height:' + height + 'px; background-color:#' + color + ';"><div style="padding:20px;">Um ' + sitename + ' nutzen zu können, benötigen Sie den Adobe Flash Player.<br /><br /><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">&gt; Hier geht es zum kostenlosen Download!</a></div></div>');
	}
}

/* detect Flash Version */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('9 H=(c.W.i("12")!=-1)?m:s;9 J=(c.W.D().i("13")!=-1)?m:s;9 K=(c.C.i("14")!=-1)?m:s;G P(){9 b;9 f;9 e;n{f=y o("g.g.7");b=f.O("$b")}v(e){}8(!b){n{f=y o("g.g.6");b="F 6,0,15,0";f.16="17";b=f.O("$b")}v(e){}}8(!b){n{f=y o("g.g.3");b=f.O("$b")}v(e){}}8(!b){n{f=y o("g.g.3");b="F 3,0,18,0"}v(e){}}8(!b){n{f=y o("g.g");b="F 2,0,0,11"}v(e){b=-1}}j b}G Q(){9 k=-1;8(c.l!=Y&&c.l.Z>0){8(c.l["B z 2.0"]||c.l["B z"]){9 R=c.l["B z 2.0"]?" 2.0":"";9 S=c.l["B z"+R].10;9 A=S.u(" ");9 L=A[2].u(".");9 p=L[0];9 w=L[1];9 a=A[3];8(a==""){a=A[4]}8(a[0]=="d"){a=a.M(1)}h 8(a[0]=="r"){a=a.M(1);8(a.i("d")>0){a=a.M(0,a.i("d"))}}9 k=p+"."+w+"."+a}}h 8(c.C.D().i("E/2.6")!=-1)k=4;h 8(c.C.D().i("E/2.5")!=-1)k=3;h 8(c.C.D().i("E")!=-1)k=2;h 8(H&&J&&!K){k=P()}j k}G X(I,N,V){t=Q();8(t==-1){j s}h 8(t!=0){8(H&&J&&!K){T=t.u(" ");U=T[1];x=U.u(",")}h{x=t.u(".")}9 p=x[0];9 w=x[1];9 a=x[2];8(p>q(I)){j m}h 8(p==q(I)){8(w>q(N))j m;h 8(w==q(N)){8(a>=q(V))j m}}j s}}',62,71,'||||||||if|var|versionRevision|version|navigator|||axo|ShockwaveFlash|else|indexOf|return|flashVer|plugins|true|try|ActiveXObject|versionMajor|parseFloat||false|versionStr|split|catch|versionMinor|versionArray|new|Flash|descArray|Shockwave|userAgent|toLowerCase|webtv|WIN|function|isIE|reqMajorVer|isWin|isOpera|tempArrayMajor|substring|reqMinorVer|GetVariable|ControlVersion|GetSwfVer|swVer2|flashDescription|tempArray|tempString|reqRevision|appVersion|DetectFlashVer|null|length|description||MSIE|win|Opera|21|AllowScriptAccess|always|'.split('|'),0,{}))
	


/* Flash movies */

var xxplugin = __sim_get_flash_version();

if (!xxplugin && navigator.userAgent 
		&& navigator.userAgent.indexOf("MSIE") >= 0 
		&& (navigator.userAgent.indexOf("Windows 95") >=0 
		|| navigator.userAgent.indexOf("Windows 98") >= 0 
		|| navigator.userAgent.indexOf("Windows NT") >= 0)) {
	document.write('<script language="VBScript"\>\n'); 
	document.write('    on error resume next\n'); 
	document.write('    xxplugin = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n'); 
	document.write('<\/script\>\n'); 
}

function __sim_get_flash_version()
{
	var x = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ?
		navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if (!x) return 0;
	
	var descr = x.description;
	if (!descr) return 0;
	
	var found = descr.match(/([0-9]+)\.[0-9]/);
	if (!found) return 0;
	
	return Number(found[1]) >= 3;
}

/*
	Important note:
	To work around the EOLAS patent issue regarding activex controls:
	always use 'writeFlash' and 'writeVideoPlayer' rather than
	document.write(getFlash(...)) or document.write(getVideoPlayer(..)).
	Also, use 'writePopupVideo' and 'writeVPQ' instead of directly
	embedding the object tag.
	You might additionally add the object tag explicitly in a 'noscript' block. 
*/

/*
	The optional argument 'paramlist' allows to pass parameters to the flash.
	If specified, the value must be a list of the following format:
	[['name1', 'value1', DO_ENCODE1], ['name2', 'value2', DO_ENCODE2], ...]
	where DO_ENCODE* is a boolean value, indicating whether the value
	needs to be converted via htmlEscape() before being appended.
*/


/* Keep arguments synchronized with writeFlash */
function getFlash(movie, fallback, width, height, id, paramlist, wmode, swLiveConnect, color)
{
	var swLiveConnectString = '';
	
	if (!swLiveConnect) {
		swLiveConnect = 'false';
	}
	else if (swLiveConnect != 'false') {
		swLiveConnect = 'true';
	}
	
	var object_swLiveConnect = '';
	var embed_swLiveConnect = '';

	if (swLiveConnect) {
		object_swLiveConnect = '<param name="swLiveConnect" value="' + swLiveConnect + '" \/>\n';
		embed_swLiveConnect  = ' swLiveConnect="' + swLiveConnect + '"';
	}

	var object_color = '';
	var embed_color  = '';

	if (color) {
		object_color = '<param name="bgcolor" value="#' + color + '" />';
		embed_color  = ' bgcolor="#' + color + '"';
	}
	

	var object_wmode = '';
	var embed_wmode  = '';

	if (!wmode) wmode = 'opaque';
	
	if (wmode) {
		object_wmode = '<param name="wmode" value="' + wmode + '" />';
		embed_wmode  = ' wmode="' + wmode + '"';
	}

	var flash = '';
	var params = '';
	var needs_fallback = 0;
	var fallbackurl = '';
	var fallbacktarget = '';
	
	if (paramlist) {
		for (var k = 0; k < paramlist.length; ++k) {
			var name      = paramlist[k][0];
			var value     = paramlist[k][1];
			var do_encode = paramlist[k][2];

			if (value == null || name == null || value == '' || name == '') continue;

			if (do_encode) value = htmlEscape(value);

			if (name == 'link1url') {
				fallbackurl = value;
			}
			else if (name == 'link1target') {
				fallbacktarget = ' target="' + value + '"';
			}

			if (params) params += '&';
			params += name + '=' + value;
		}
	}

	if (movie) {
		if (params) movie += '?' + params;
		
		if (xxplugin) { 
			flash =
				  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
				+ ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0"'
				+ ' id="' + id + '" width="' + width + '" height="' + height + '"  style="display:block;">\n'
				+ '<param name="movie" value="' + movie + '" \/>\n'
				+ '<param name="wmode" value="' + wmode + '" \/>\n' 
				+ '<param name="quality" value="high" \/>\n'
				+ object_color + object_swLiveConnect
				+ '<embed src="' + movie + '" quality="high"'
				+ embed_color + embed_swLiveConnect
				+ ' width="' + width + '" height="' + height + '"'
				+ ' type="application/x-shockwave-flash" wmode="' + wmode + '" name="' + id + '"' 
				+ ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
				+ '<\/embed>\n'
				+ '<\/object>';
		}
		else {
			needs_fallback = 1;
		}
	}
	else {
		needs_fallback = 1;
	}

	if (needs_fallback && fallback
		&& !(navigator.appName
		&& navigator.appName.indexOf("Netscape") >= 0
		&& navigator.appVersion.indexOf("2.") >= 0)) { 

		// The usemap handling is a pro7 special which should never have happened here.
		var usemap = id == "navi" ? ' usemap="#naviimage"' : '';
		flash = fallback;

		if (fallbackurl) {
			if (!fallbacktarget) fallbacktarget = ' target="_top"';
			flash = '<a href="' + fallbackurl + '"' + fallbacktarget + '>' + flash + '<\/a>';
		}
	}
	
	return flash;
}

/* Keep arguments synchronized with getVideoPlayer */
function writeVideoPlayer(movie, fallback, width, height, id) {
	document.write(getVideoPlayer(movie, fallback, width, height, id));
}

/* Keep arguments synchronized with writeVideoPlayer */
function getVideoPlayer(movie, fallback, width, height, id)
{
	if (!movie) return '';

	var player = '';
	var needs_fallback = 0;
	
	if (xxplugin) {
		player =
			  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'
			+ ' id="' + id + '" width="' + width + '" height="' + height + '" align="left">\n'
			+ '<param name="movie" value="' + movie + '" \/>'
			+ '<param name="menu" value="false" \/>'
			+ '<param name="quality" value="high" \/>'
			+ '<param name="bgcolor" value="#ffffff" \/>'
			+ '<embed src="' + movie + '" menu="false" quality="high" bgcolor="#ffffff"'
			+ ' width="'+ width + '" height="' + height + '" name="' + id + '" align="left"'
			+ ' type="application/x-shockwave-flash"'
			+ ' pluginspage="http://www.macromedia.com/go/getflashplayer">'
			+ '<\/embed>'
			+ '<\/object>';
		
	}
	else {
		needs_fallback = 1;
	}

	if (needs_fallback && fallback
		&& !(navigator.appName
		&& navigator.appName.indexOf("Netscape") >= 0
		&& navigator.appVersion.indexOf("2.") >= 0)) { 
		player = '<img src="' + fallback + '" width="' + width + '" height="' + height + '" border="0" \/>';
	}
	
	return player;
}

function writeWMPlayer(movie, width, height, config) {
	document.write(getWMPlayer(movie, width, height, config));
}

function getWMPlayer(movie, width, height, config) {
	// Should never happen.
	if (!movie) return '';

	var defaults = {
			id: 'wmp',
			AutoStart: 'true',
			ShowControls: 'true',
			ShowStatusBar: 'true',
			ShowAudioControls: 'true',
			ShowPositionControls: width && width > 270 ? 'true' : 'false',
			AnimationAtStart: 'false',
			ShowTracker: 'false',
			ShowGotoBar: 'false',
			ShowCaptioning: 'false',
			ShowDisplay: 'false'
		};

	var control_height = 49;
	
	var params = new Object;
	
	for (var i in config) {
		var value = config[i];
		if (value == true) {
			value = 'true';
		}
		else if (value == false) {
			value = 'false';
		}
		
		params[i] = value;
	}
	
	for (var i in defaults) {
		if (params[i] == null) params[i] = defaults[i]; 
	}
	
	if (params.ShowControls == 'true') height += control_height;
	
	var dimensions = '';
	
	if (width)  dimensions += ' width="' + width + '"';
	if (height) dimensions += ' height="' + height + '"';
	
	var id = params.id;
	delete params.id;
	
	var classname = params.classname ? ' class="' + params.classname + '"' : '';
	delete params.classname;
	
	var style = params.style ? ' style="' + params.style + '"' : '';
	delete params.style;
	
	var object_params = '<param name="FileName" value="'+ movie +'">\n';
	var embed_params  = ' src="' + movie + '"\n';
	
	for (var i in params) {
		if (i == 'class') continue;
		object_params += '<param name="' + i + '" value="' + params[i] + '">\n';
		embed_params  += ' ' + i + '="' + params[i] + '"\n';
	}
	
	embed_params = embed_params.replace(/\n$/, '');

	var player =
		'<object id="' + id + '"' + classname + style + dimensions
			+ ' classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'
			+ ' type="application/x-oleobject"'
			+ ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">\n'
			+ object_params
			+ '<embed id="' + id + '"' + classname + style + dimensions
			+ ' type="application/x-mplayer2"'
			+ embed_params + '></embed>\n'
		+ '</object>';

	return player;
}

function writePopupVideo(movie, width, height, position_controls) {
	document.write(getPopupVideo(movie, width, height, position_controls));
}

function getPopupVideo(movie, width, height, position_controls) {
	// Backwards compatibility.
	if (height) height -= 49;
	return getWMPlayer(movie, width, height, {ShowPositionControls: position_controls});
}

/*
	By default, 'wmode' is left empty which results
	in the flash default value 'window'.
	This is different from the default wmode in getFlash!
	Please note that with 'transparent' or 'opaque',
	user interaction does not work for games.
*/
function writeVPQ(movie, width, height, color, wmode) {
	var player = '';
	
	if (!movie) {
		// Should never happen.
	}
	else if (xxplugin) {
		var object_color = '';
		var embed_color  = '';
		
		if (color) {
			object_color = '<param name="bgcolor" value="#' + color + '" />';
			embed_color  = ' bgcolor="#' + color + '"';
		}

		var object_wmode = '';
		var embed_wmode  = '';
		
		if (wmode) {
			object_wmode = '<param name="wmode" value="' + wmode + '" />';
			embed_wmode  = ' wmode="' + wmode + '"';
		}

		player =
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
			+ ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'
			+ ' width="' + width + '" height="' + height + '" id="vpq_57" align="middle">'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="movie" value="' + movie + '" />'
			+ '<param name="menu" value="false" />'
			+ '<param name="quality" value="high" />'
			+ object_color + object_wmode
			+ '<embed src="' + movie + '"'
			+ 	' menu="false"'
			+ 	' quality="high"'
			+ 	' width="' + width + '" height="' + height + '"'
			+ 	' name="vpq_57"'
			+ 	' align="middle"'
			+ embed_color + embed_wmode
			+ 	' allowScriptAccess="sameDomain"'
			+   ' type="application/x-shockwave-flash"'
			+ 	' pluginspage="http://www.macromedia.com/go/getflashplayer" />'
		+ '</object>';
	}
	else {
		window.defaultStatus = 'xxplugin not defined';
		player = '';
	}
	
	document.write(player);
}

function utf8Encode(string) {
	if (!string) return string;
	
	string = string.replace(/\r\n/g,"\n");

	var utfString = "";

	for (var i=0; i < string.length; i++) {
		var c = string.charCodeAt(i);
		if (c < 128) {
			utfString += String.fromCharCode(c);
		}
		else if((c > 127) && (c < 2048)) {
			utfString += String.fromCharCode((c>>6)|192);
			utfString += String.fromCharCode((c&63)|128);
		}
		else {
			utfString += String.fromCharCode((c>>12)|224);
			utfString += String.fromCharCode(((c>>6)&63)|128);
			utfString += String.fromCharCode((c&63)|128);}
		}

	return utfString;
}

function htmlEscape(string)
{
	if (string) {
		string = encodeURI(string);
		string = string.replace(/\//g,"%2F");
		string = string.replace(/\?/g,"%3F");
		string = string.replace(/=/g,"%3D");
		string = string.replace(/&/g,"%26");
		string = string.replace(/@/g,"%40");
	}

	return string;
}