
//	Flash-Detection und Gabelfunktion
//	XHTML-Ausgabe, V-1.1
//	pepperzak, aw 2005-08-01

if (typeof (gFlashNeeded) == "undefined") gFlashNeeded = 6;

var gIsWin;
var gIsMac;
var gIsIE;

var gBrowserVersion;

var gFlashVersion;
var gFlashDetectable;
var gFlashInstalled;
var gFlashActive;
var gFlashImplementation;
var vbChecked;
var vbFlashInstalled;
var vbFlashVersion;
var gFlashOK;

Get_Environment();

//	----------

function Get_Environment () {

	gAppVersion = navigator.appVersion;
	gUserAgent = navigator.userAgent;
	
	gIsWin  = (gAppVersion.indexOf("Win") != -1) ? true : false;
	gIsMac  = (gAppVersion.indexOf("Mac") != -1) ? true : false;
	gIsIE	= (document.all)?true:false;
	
	CheckMSIE = gUserAgent.indexOf("MSIE");
	
	if (CheckMSIE > -1) {
		Short = gUserAgent.substr(CheckMSIE+5,100);
		gBrowserVersion = Short.substr(0,Short.indexOf(";"));
	}

	if (gIsWin && gIsIE && typeof (vbChecked) == "undefined") {
	
		vbChecked = true;
		vbFlashInstalled = false;
		vbFlashVersion = false;
		
		document.writeln ('<script language="VBScript">');
		document.writeln ('Private i, ObjAct');
		document.writeln ('On Error Resume Next');
		document.writeln ('vbFlashInstalled = False');
		document.writeln ('vbFlashVersion = False');
		document.writeln ('For i = 10 To 1 Step -1');
		document.writeln ('Set ObjAct = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)');	// Anfuehrungszeichen nicht tauschen!
		document.writeln ('vbFlashInstalled = IsObject(ObjAct)');
		document.writeln ('If vbFlashInstalled Then');
		document.writeln ('vbFlashVersion = CStr(i)');
		document.writeln ('Exit For');
		document.writeln ('End If');
		document.writeln ('Next');
		document.writeln ('</script>');
	}

	gFlashDetectable = true;
	gFlashInstalled = false;
	gFlashActive = false;
	gFlashVersion = -1;
	gFlashImplementation = -1;

	if (vbFlashInstalled) {
	
		gFlashInstalled = true;
		gFlashActive = gFlashInstalled;
		gFlashVersion = 1*vbFlashVersion;
		gFlashImplementation = "ActiveX";
		
	} else if (navigator.plugins && navigator.plugins.length > 0) {
	
		gFlashImplementation = "Plugin";
		if (navigator.plugins["Shockwave Flash"]) {
		
			gFlashInstalled = true;
			var StringTmp = navigator.plugins["Shockwave Flash"].description.split(" ");

			for (var i=0; i<StringTmp.length; ++i) {
			
				if (isNaN(parseInt(StringTmp[i]))) continue;
				gFlashVersion = 1*StringTmp[i];
			}
		}

		if (navigator.mimeTypes["application/x-shockwave-flash"])
 			gFlashActive = (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin != null);
	}
	
	if (gIsIE && gIsMac && (1*gBrowserVersion) < 5) gFlashDetectable = false;
	if (gFlashVersion == -1) gFlashImplementation = -1;

	gFlashOK = (gFlashVersion >= 1*gFlashNeeded);
	if (!gFlashActive || !gFlashDetectable) gFlashOK = false;

}

//	----------

function Show_Flash (FileAndParams, XSize, YSize, VersionOpt, BGColorOpt, ImageOpt, URLOpt, TrgtOpt) {

	
	if (typeof(VersionOpt) == 'undefined') VersionOpt = 6;
	
	if (VersionOpt > gFlashVersion) {
		if (typeof(ImageOpt) == 'string' && ImageOpt!='') Build_Img (ImageOpt, XSize, YSize, URLOpt, TrgtOpt);
		return false;
	}

	if (typeof(FileAndParams) == 'undefined') {	
		document.write('<b>Show_Flash</b>: keine swf-Datei angegeben');
		return false;	}

	if (typeof(XSize) == 'undefined' || typeof(YSize)=='undefined') {
		document.write('<b>Show_Flash</b>: keine Gr&ouml;&szlig;enangabe');
		return false;	}
	
	if (typeof(BGColorOpt) == 'undefined') {
		BGColorOpt = '#ffffff';
		BGMode = 'opaque';
	} else if (BGColorOpt == 'transparent') {
		BGColorOpt = '#ffffff';
		BGMode = 'transparent';
	} else {
		BGMode = 'opaque';
	}
	
	FXSize = XSize;
	FYSize = YSize;
	
	if (FXSize == '100%') FXSize = window.innerWidth;
	if (FYSize == '100%') FYSize = window.innerHeight;
	if (isNaN(FXSize) || typeof(FXSize)=='undefined' || FXSize==0) FXSize = document.body.offsetWidth;
	if (isNaN(FYSize) || typeof(FYSize)=='undefined' || FYSize==0) FYSize = document.body.offsetHeight;
	
	FileAndParams += (FileAndParams.indexOf('?') == -1) ? '?' : '&amp;';
	FileAndParams += 'js=1';
	
	FlLoop		= 'true';
	FlMenu		= 'false';
	FlQuality	= 'high';
	FlAlign		= 'lt';
	FlScale		= 'noscale';
		
	FlashString	 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	FlashString	+= 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + VersionOpt + ',0,0,0" ';
	FlashString	+= 'width="' + XSize + '" ';
	FlashString	+= 'height="' + YSize + '"> ';
	FlashString	+= '<param name="movie" value="' + FileAndParams + '" /> ';
	FlashString	+= '<param name="loop" value="' + FlLoop + '" /> ';
	FlashString	+= '<param name="menu" value="' + FlMenu + '" /> ';
	FlashString	+= '<param name="quality" value="' + FlQuality + '" /> ';
	FlashString	+= '<param name="scale" value="' + FlScale + '" /> ';
	FlashString	+= '<param name="salign" value="' + FlAlign + '" /> ';
	FlashString	+= '<param name="wmode" value="' + BGMode + '" /> ';
	FlashString	+= '<param name="bgcolor" value="' + BGColorOpt + '" /> ';
	FlashString	+= '<embed src="' + FileAndParams + '" ';
	FlashString	+= 'loop="' + FlLoop + '" ';
	FlashString	+= 'menu="' + FlMenu + '" ';
	FlashString	+= 'quality="' + FlQuality + '" ';
	FlashString	+= 'scale="' + FlScale + '" ';
	FlashString	+= 'salign="' + FlAlign + '" ';
	FlashString	+= 'wmode="' + BGMode + '" ';
	FlashString	+= 'bgcolor="' + BGColorOpt + '" ';
	FlashString	+= 'width="' + XSize + '" ';
	FlashString	+= 'height="' + YSize + '" ';
	FlashString	+= 'type="application/x-shockwave-flash" ';
	FlashString	+= 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
	FlashString	+= '</embed></object>';

	document.write (FlashString);
}

//	----------

function Build_Img (File, XSize, YSize, URLOpt, TrgtOpt) {

	if (typeof(File) != 'string' || File == '') return false;
	
	var HRef1 = '';
	var HRef2 = '';
	var Trgt  = '';
	
	if (typeof(TrgtOpt) == 'string' && TrgtOpt != '') Trgt = 'target="' + TrgtOpt + '"';
	
	if (typeof(URLOpt) == 'string' && URLOpt != '') {
	
		HRef1 = '<a href="' + URLOpt + '" ' + Trgt + '>';
		HRef2 = '</a>';
	}
	
	var ImgString = HRef1 + '<img src="' + File + '" alt="" width=' + XSize + ' height=' + YSize + ' border=0 align="top" usemap="#noflash">' + HRef2;
	document.write (ImgString);
}

//	----------

function SpecialCharsToFlash6 (SrcTxt) {

	//	Ersetzt die HTML-Entities durch Flash 6-konforme 2-Byte-Maskierungen
	
	SrcTxt = Replace (SrcTxt, '&auml;','%C3%A4');
	SrcTxt = Replace (SrcTxt, '&ouml;','%C3%B6');
	SrcTxt = Replace (SrcTxt, '&uuml;','%C3%BC');
	SrcTxt = Replace (SrcTxt, '&Auml;','%C3%84');
	SrcTxt = Replace (SrcTxt, '&Ouml;','%C3%96');
	SrcTxt = Replace (SrcTxt, '&Uuml;','%C3%9C');
	SrcTxt = Replace (SrcTxt, '&szlig;','%C3%9F');
	
	return (SrcTxt);
}

//	----------

function Replace (SrcTxt, OldStr, NewStr) {

	//	Ersetzt einen Teil-String
	
	while (SrcTxt.indexOf(OldStr) != -1) {
	
		SrcTxt = SrcTxt.substring (0,SrcTxt.indexOf(OldStr)) + NewStr + SrcTxt.substring (SrcTxt.indexOf(OldStr) + OldStr.length ,SrcTxt.length); 
	}

	return (SrcTxt);
}

//	----------