// JavaScript Document
function MFD2004()
{
	//VB-Script for InternetExplorer
	function iExplore()
	{
		if(this.flashSrc && this.flashWidth && this.flashHeight && (this.Menu == false || this.Menu == true) && (this.Quality.toLowerCase() == "low" || this.Quality.toLowerCase() == "autolow" || this.Quality.toLowerCase() == "autohigh" || this.Quality.toLowerCase() == "meduim" || this.Quality.toLowerCase() == "high" || this.Quality.toLowerCase() == "best" ))
		{
			document.writeln('<SCR' + 'IPT LANGUAGE="VBScript">\n');
			document.writeln('MM_contentVersion ='+this.Version);
			document.writeln('on error resume next');
			document.writeln('MM_FlashCanPlay = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))');
			document.writeln('if MM_FlashCanPlay Then');
			document.writeln('q = Chr(34)');
			document.writeln('FlashFile = "<object classid=" & q & "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" & q &" codebase=" & q &"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.Version+',0,0,0" & q &" width=" & q &"'+this.flashWidth+'" & q &" height=" & q &"'+this.flashHeight+'" & q &" align=" & q &"middle" & q &"><param name=" & q &"allowScriptAccess" & q &" value=" & q &"sameDomain" & q &" /><param name=" & q &"movie" & q &" value=" & q &"'+this.flashSrc+'" & q &" /><param name=" & q &"menu" & q &" value=" & q &"'+this.Menu+'" & q &" /><param name=" & q &"quality" & q &" value=" & q &"'+this.Quality+'" & q &" /><param name=" & q &"bgcolor" & q &" value=" & q &"'+this.flashBGColor+'" & q &" /><embed src=" & q &"'+this.flashSrc+'" & q &" menu=" & q &"'+this.Menu+'" & q &" quality=" & q &"'+this.Quality+'" & q &" bgcolor=" & q &"'+this.flashBGColor+'" & q &" width=" & q &"'+this.flashWidth+'" & q &" height=" & q &"'+this.flashHeight+'" & q &" name=" & q &"centerimage" & q &" align=" & q &"middle" & q &" allowScriptAccess=" & q &"sameDomain" & q &" type=" & q &"application/x-shockwave-flash" & q &" pluginspage=" & q &"http://www.macromedia.com/go/getflashplayer" & q &" /></object>"');
			document.writeln('document.write(FlashFile)');
			document.writeln('else');
			document.writeln('q = Chr(34)');
			
			if(this.alternSrc)
			{
				if(this.alternLink)
					document.writeln('document.write("<a href=" & q & "'+this.alternLink+'" & q &">")');
				if(this.alternWidth || this.alternHeight)
					document.writeln('AlterFile = "<IMG border=" & q & "0" & q & " width=" & q & "'+this.alternWidth+'" & q & "  height=" & q & "'+this.alternHeight+'" & q & " SRC=" & q & "'+this.alternSrc+'" & q & "ALT=" & q &"'+this.alternAlt+'"& q & ">"');
				else
					document.writeln('AlterFile = "<IMG border=" & q & "0" & q & " SRC=" & q & "'+this.alternSrc+'" & q & "ALT=" & q &"'+this.alternAlt+'"& q & ">"');
				document.writeln('document.write(AlterFile)');
				if(this.alternLink)
					document.writeln('document.write("</a>")');
				document.writeln('end If');
				document.writeln('</SCR' + 'IPT\>\n');
			}
			else
			{
				document.writeln('end If');
				document.writeln('</SCR' + 'IPT\>\n');
				this.errorCheck("alt");
			}
			
		}
		else
		{
			this.errorCheck("flash");
		}
	}
	
	//This Function spits the Flash with all user defined settings
	function spitFlash()
	{
		if(this.flashSrc && this.flashWidth && this.flashHeight && (this.Menu == false || this.Menu == true) && (this.Quality.toLowerCase() == "low" || this.Quality.toLowerCase() == "autolow" || this.Quality.toLowerCase() == "autohigh" || this.Quality.toLowerCase() == "meduim" || this.Quality.toLowerCase() == "high" || this.Quality.toLowerCase() == "best" ))
		{
			var objectOpen = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+this.Version+",0,0,0\" width=\""+this.flashWidth+"\" height=\""+this.flashHeight+"\">\n";
			var scriptAcc = "<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
			var src = "<param name=\"movie\" value=\""+this.flashSrc+"\" />\n";
			var menu = "<param name=\"menu\" value=\""+this.Menu+"\" /\n>";
			var quali = "<param name=\"quality\" value=\""+this.Quality+"\" /\n>";
			var bgcolor = "<param name=\"bgcolor\" value=\""+this.flashBGColor+"\" />\n";
			var allin1 = "<embed src=\""+this.flashSrc+"\" menu=\""+this.Menu+"\" quality=\""+this.Quality+"\" bgcolor=\""+this.flashBGColor+"\" width=\""+this.flashWidth+"\" height=\""+this.flashHeight+"\" name=\""+this.Name+"\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n";
			var objectClose = "</object>\n";
			
			document.write(objectOpen);
			document.write(scriptAcc);
			document.write(src);
			document.write(menu);
			document.write(quali);
			document.write(bgcolor);
			document.write(allin1);
			document.write(objectClose);
		}
		else
		{
			this.errorCheck("flash");
		}
	}
	
	//this function spits the alternative image out
	function spitAlter()
	{
		if(this.alternSrc)
		{
			if(this.alternLink)
				document.write("<a href=\"" + this.alternLink + "\">");
			if(this.alternWidth || this.alternHeight)
				document.write("<img border=\"0\" src=\""+this.alternSrc+"\" width=\""+this.alternWidth+"\" height=\""+this.alternHeight+"\" alt=\""+this.alternAlt+"\">");
			else
				document.write("<img border=\"0\" src=\""+this.alternSrc+"\" alt=\""+this.alternAlt+"\">");
			if(this.alternLink)
				document.write("</a>");	
		}
		else
			this.errorCheck("alt");
	}
	
	//this is the heart of the script
	//with this function you start the detection
	function startDetect()
	{
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;
		if(!(plugin) && (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)))
		{
			this.iExploreCheck();
		}
		if(plugin)
		{
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
				for (var i = 0; i < words.length; ++i)
				{
					if (isNaN(parseInt(words[i])))
						continue;
					var MM_PluginVersion = words[i]; 
				}
			var MM_FlashCanPlay = MM_PluginVersion >= this.Version;
			if(MM_FlashCanPlay)
			{
				this.spitFl();
			}
			else
			{
				this.spitAl();
			}
		}
	}
	
	//this function will be called if one or more of required properties was not given
	function checkError(which)
	{
		document.write("<font style=\" font-family: verdana; font-size: 80%; font-weight: bold\">");
		document.write("<h2 style=\"color: #ff0000;\"><u>Error:</u></h2>");
		if(which.toLowerCase() == "flash")
		{
			if(!(this.flashSrc))
				document.writeln("<li>Flash-Source is not given</li>");
			if(!(this.flashHeight))
				document.writeln("<li>Flash-Height is not given</li>");
			if(!(this.flashWidth))
				document.writeln("<li>Flash-Width is not given</li>");
			if(!(this.Quality.toLowerCase() == "low" || this.Quality.toLowerCase() == "autolow" || this.Quality.toLowerCase() == "autohigh" || this.Quality.toLowerCase() == "meduim" || this.Quality.toLowerCase() == "high" || this.Quality.toLowerCase() == "best"))
				document.writeln("<br><br><li>Quality property: \""+this.Quality+"\" is not a supported property. Please fill in one of the following: <li style=\"margin-left: 1.5em\">Low</li><li style=\"margin-left: 1.5em\">AutoLow</li><li style=\"margin-left: 1.5em\">AutoHigh</li><li style=\"margin-left: 1.5em\">Meduim</li><li style=\"margin-left: 1.5em\">High</li><li style=\"margin-left: 1.5em\">Best</li></li><br><br>");
			if(!(this.Menu == false || this.Menu == true))
				document.writeln("<li>Menu property: \""+this.Menu+"\" is not a supported property. Please fill either \"true\" or \"false\"</li>");
		}
		else if(which.toLowerCase() == "alt")
		{
			document.writeln("<li>Please set an alternative image path.</li>");
		}
		document.write("</font>");
	}
	
	function detectV()
	{
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;
		if(plugin)
		{
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
				for (var i = 0; i < words.length; ++i)
				{
					if (isNaN(parseInt(words[i])))
						continue;
					var MM_PluginVersion = words[i]; 
				}
			if(MM_PluginVersion)
				return MM_PluginVersion
		}
	}
	
	
	//Flash Settings
	this.Version = 5;
	this.flashWidth = null;
	this.flashHeight = null;
	this.flashSrc = null;
	this.Menu = false;
	this.Quality = "low";
	this.flashBGColor = "#ffffff";
	
	//Alternative Settings
	this.alternSrc = null;
	this.alternAlt = "";
	this.alternWidth = null;
	this.alternHeight = null;
	this.alternLink = null;
	
	//definde Methods
	this.detect = startDetect;
	this.spitFl = spitFlash;
	this.spitAl = spitAlter;
	this.iExploreCheck = iExplore;
	this.errorCheck = checkError;
	this.detectVersion = detectV;
}
