
	// detect Flash plugin and version
	function detectFlash()
	{
			flashinstalled = 0;
			flashversion = 0;
			flashversion_ns = 0;
			MSDetect = "false";
			
			// Check plugin for non IE browser
			if (navigator.plugins && navigator.plugins.length)
			{
				x = navigator.plugins["Shockwave Flash"];
				if (x)
				{
					flashinstalled = 2;
					if (x.description)
					{
						y = x.description;
						flashversion = y.charAt(y.indexOf('.')-1);
					}
				}
				else flashinstalled = 1;
				
				// we don't need to bother to check for flash 2
				/*if (navigator.plugins["Shockwave Flash 2.0"])
				{
					flashinstalled = 2;
					flashversion = 2;
				}*/

				// we need a seperate value for NS, to find out 
				// whether it supports wmode,( it only supports it from flash version 6,0,0,65 )
				flashversion_ns = flashversion;
			}
			else if (navigator.mimeTypes && navigator.mimeTypes.length)
			{
				x = navigator.mimeTypes['application/x-shockwave-flash'];
				if (x && x.enabledPlugin)
					flashinstalled = 2;
				else
					flashinstalled = 1;
			}
			else
			{
				// now comes the IE detection
				MSDetect = "true";
				vVBscript='';			
				vVBscript =('<SCR' + 'IPT LANGUAGE=VBScript\> \n')
				vVBscript +="\n on error resume next" ;
				vVBscript +="\n If MSDetect = \"true\" Then";
				vVBscript +="\n For i = 2 to 6";
				vVBscript +="\n If Not(IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & i))) Then";
				vVBscript +="\n Else";
				vVBscript +="\n flashinstalled = 2";
				vVBscript +="\n flashversion = i";
				vVBscript +="\n End If";
				vVBscript +="\n Next";
				vVBscript +="\n End If";
				vVBscript +="\n If flashinstalled = 0 Then";
				vVBscript +="\n flashinstalled = 1";
				vVBscript +="\n End If";
				vVBscript += ('</SCR' + 'IPT\> \n')
				document.write(vVBscript);
			}
		}
		
	// function to write out flash if flash is installed
	// otherwise write out alternative content.
	function outputFlash(moviename,width,height,wmode,vArg)
	{
		detectFlash();
		var moviename,width,height,wmode
		var vObjectTag = vEmbedTag = '';
		
		if (vArg) vArg = vArg
		else vArg = '';
				
		if (flashinstalled == 2)
		{
			// we need flash 6 for NS
			// TODO: get minor version
			if (flashversion_ns >= 6)
			{
				vEmbedTag = '<EMBED'
							+ ' src="' + moviename + vArg +'" loop="false" menu="false" quality="high" scale="noscale"'
							+ ' wmode="' + wmode + '" bgcolor="#ffffff"  WIDTH="' + width + '" HEIGHT="' + height + '" ALIGN=""'
							+ ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
							+ '</EMBED>';
			}
			else
			{
				// TODO: replace with proper alternative content
				vEmbedTag = "<h2>Please <a href='/error/flash.html'>upgrade</a> your Flash player</h2>";
			}
		
			// For IE flash 5 will do
			if (flashversion >= 5)
			{
				vObjectTag ='\n<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
							+'\ncodebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"'
							+'\nWIDTH="' + width + '" HEIGHT="' + height + '" id="' + moviename + '" ALIGN="">'
							+'\n<PARAM NAME="movie" VALUE="' + moviename + vArg + '"> <PARAM NAME="loop" VALUE="false"> <PARAM NAME="menu" VALUE="false">'
							+'\n<PARAM NAME="quality" VALUE="high"><PARAM NAME="scale" VALUE="noscale"><PARAM NAME="wmode" VALUE="' + wmode + '">'
							+'\n<PARAM NAME="bgcolor" VALUE="#ffffff">'
							+vEmbedTag
							+'\n</OBJECT>\n';
				
				document.write(vObjectTag);
			}
			else document.write("<h2>Please <a href='/error/flash.html'>upgrade</a> your Flash player</h2>");	
		}
		else if (flashinstalled == 1) document.write("<h2>Please <a href='/error/flash.html'>upgrade</a> your Flash player</h2>");
	}