
/* Flash movies */

var xxplugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

if (xxplugin) { 
	xxplugin = parseInt(xxplugin.description.substring(xxplugin.description.indexOf(".")-1)) >= 3; 
} 
else if (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'); 
} 

/*
	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.
*/
function getFlash(movie, fallback, width, height, id, paramlist, wmode, swLiveConnect)
{
	var swLiveConnectString = '';
	
	if (!wmode) wmode = 'opaque';
	
	if (!swLiveConnect) {
		swLiveConnect = 'FALSE';
	}
	else {
		swLiveConnect = 'true';
		swLiveConnectString = '<param name="swLiveConnect" value="' + swLiveConnect + '" \/>\n';
	}

	var flash = '';
	var params = '';
	var needs_fallback = 0;
	
	if (movie) {
		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 (params) params += '&';
				params += name + '=' + value;
			}

			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 + '">\n'
				+ '<param name="movie" value="' + movie + '" \/>\n'
				+ '<param name="wmode" value="' + wmode + '" \/>\n' 
				+ '<param name="quality" value="high" \/>\n'
				+ '<param name="LOOP" value="false" \/>\n'
				+ '<param name="SAlign" value="L">\n'
				+ '<param name="Scale" value="ShowAll">\n'
				+ swLiveConnectString
				+ '<embed src="' + movie + '" loop="false" quality="high" swLiveConnect="' + 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)) { 
		// hier nochmal durch die Parameterliste gehen wenn vorhanden, damit das Fallbackbild verlinkt ist im Flash-Teaser.
		var fallbackurl = '';
		var fallbacktarget = ' target="_top"';
		if (paramlist) {
			fallbackurl = '\/';
			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 (name == 'link1url') fallbackurl = value;
				if (name == 'link1target' && value.length > 0) fallbacktarget = ' target="' + value + '"';
				if (value == null || name == null || value == '' || name == '') continue;
			}
		}
		if (fallbackurl == '') {
			flash = '<img src="' + fallback + '" width="' + width + '" border="0" \/>';
		} else {
			flash = '<a href="' + fallbackurl + '"' + fallbacktarget + '><img src="' + fallback + '" width="' + width + '" border="0" \/><\/a>';
		}
	}
	
	return flash;
}

function getVideoPlayer(movie, fallback, width, 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" \/>'
			+ '<param name="SAlign" value="L">\n'
			+ '<param name="Scale" value="ShowAll">\n'
			+ '<embed src="' + movie + '" menu="false" quality="high" bgcolor="#ffffff"'
			+ ' width="'+ width + '" 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 + '" border="0" \/>';
	}
	
	return 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;
} 

