
//	Flash-Detection und Gabelfunktion
//	aw - pepperzak - Version: 2003-07-31

var gIsWin;
var gIsMac;
var gIsIE;

var gBrowserVersion;
	
var gFlashVersion;
var gFlashDetectable;
var gFlashInstalled;
var gFlashActive;
var gFlashImplementation;
var vbFlashInstalled = false;
var vbFlashVersion = false;
var gFlashChecked = false;

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)
	{
		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>');
	}
}

//	----------

function Check_Flash (Version, Loose)
{
	gFlashChecked = true;
	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;

	if (Loose)
		CheckRes = ((gFlashVersion >= 1*Version) || !gFlashDetectable);
	else
		CheckRes = (gFlashVersion >= 1*Version);
	
	if (!gFlashActive) CheckRes = false;
	
	return (CheckRes);
}

//	----------

function Show_Flash (File, XSize, YSize, VersionOpt, BGColorOpt, NoFlashURLOpt, NoFlashImgOpt, LooseOpt, CallOpt, TrgtOpt)
{
	if (typeof(File) != "string" || typeof(XSize) == "undefined" || typeof(YSize) == "undefined") return false;
	
	if (typeof(VersionOpt) == "undefined") VersionOpt = 5;
	if (typeof(BGColorOpt) == "undefined") BGColorOpt = "#ffffff";
	
	FlashOK = Check_Flash (VersionOpt, LooseOpt);

	if (FlashOK)
		Build_SWF (File, XSize, YSize, VersionOpt, BGColorOpt);
	else
	{
		if (typeof(NoFlashURLOpt) == "string" && NoFlashURLOpt != "")
			location.replace (NoFlashURLOpt);
		else if (typeof(NoFlashImgOpt) == "string" && NoFlashImgOpt != "")
			Build_Img (NoFlashImgOpt, XSize, YSize, CallOpt, TrgtOpt);
		else
			Build_Alt (XSize, YSize, VersionOpt, BGColorOpt);
	}
}

//	----------

function Build_SWF (FileAndParams, XSize, YSize, VersionOpt, BGColorOpt)
{
	if (typeof(FileAndParams) == "undefined")
	{	document.write("<b>Build_SWF</b>: keine swf-Datei angegeben");
		return false;	}

	if (typeof(XSize) == "undefined" || typeof(YSize)=="undefined")
	{	document.write("<b>Build_SWF</b>: keine Gr&ouml;&szlig;enangabe");
		return false;	}

	if (typeof(VersionOpt) == "undefined") VersionOpt = 5;
	if (typeof(BGColorOpt) == "undefined") BGColorOpt = "#ffffff";

	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) ? "?" : "&";
	FileAndParams += ("ht=1&js=1&xsize=" + FXSize + "&ysize=" + FYSize + "&fver=" + gFlashVersion);
	
	FileAndParams += Parse_URLParams("&","#");
	
	FlLoop		= "false";
	FlMenu		= "false";
	FlQuality	= "high";
	FlAlign		= "lt";
	FlScale		= "noscale";
	FlMode		= "opaque";		// VORSICHT: wenn das gesetzt wird, funktioniert in Flash das TAB abfangen nicht !?!
	
	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='" + FlMode + "'> ";
	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='" + FlMode + "' ";
	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, CallOpt, TrgtOpt)
{
	HRef1 = "";
	HRef2 = "";
	Trgt  = "";
	
	if (typeof(TrgtOpt) == "string" && TrgtOpt != "") Trgt = "target='" + TrgtOpt + "'";
	
	if (typeof(CallOpt) == "string" && CallOpt != "")
	{
		HRef1 = "<a href='" + CallOpt + "' " + Trgt + ">";
		HRef2 = "</a>";
	}
	
	var ImgString = HRef1 + "<img src='" + File + "' alt='' width=" + XSize + " height=" + YSize + " border=0 align='top'>" + HRef2;
	document.write (ImgString);
}

//	----------

function Build_Alt (XSize, YSize, Version, BGColor)
{
	AltString  = "<table border='0' bgcolor='" + BGColor + "' width=" + XSize + " height=" + YSize + " cellspacing='0' cellpadding='0'>";
	AltString += "<tr><td align='center' valign='middle'>";
	AltString += "Flash-Version ist zu klein!";
	AltString += "</td></tr></table>";
	
	document.write (AltString);
}

//	----------

function Parse_URLParams (SearchStr, ReplaceStr)
{
	PStr = location.search;
	if (PStr == "") return "";
	
	if (typeof(SearchStr) == "undefined") SearchStr = "&";
	if (typeof(ReplaceStr) == "undefined") ReplaceStr = "#";
	
	PStr = PStr.substr (1, PStr.length-1);
	PStrReal = PStr;
	
	while (PStr.indexOf(SearchStr) != -1) PStr = PStr.substr (0, PStr.indexOf(SearchStr)) + ReplaceStr + PStr.substr(PStr.indexOf(SearchStr)+1,255);
	
	return ("&" + PStrReal + "&cchr=" + ReplaceStr + "&prms=" + PStr);
}

//	----------

function Show_FlashStatus (StatTxt)
{
	if (typeof(StatTxt) != "string") StatTxt = " ";
	if (StatTxt == "") StatTxt = " ";
	window.status = unescape(StatTxt);
}

