/**************************************************************************/
/***  File:	flashplugin.js						***/
/***  Author:	Peter Saitz						***/
/***  Copyright:kreative|zone°						***/
/***  Created:	2000/09/20  New, based on source-code of Colin Moock	***/
/***		            http://www.moock.org/webdesign/flash (Saitz)***/
/***  Changes:	2004/08/16  Upper-/lowercase function names (Saitz)	***/
/***		2004/08/17  Extend the script with:			***/
/***		            strBgColor, strScale, strSalign, strWmode,	***/
/***		            strFlashvars (Thomas J. Sebestyen)		***/
/***		2004/10/05  eliminate lowercase function names;		***/
/***		            add ShockwaveFlash.7 to VBSCript (Thomas)	***/
/***		2005/02/17  add strVariable for Links for alternate	***/
/***		            image (Thomas)				***/
/***									***/
/***									***/
/***  Tested:	Windows:   Netscape 4.03, 4.6, 4.6.1, 4.7, 7.1		***/
/***		           Internet Explorer 4.0, 5.0, 6.0		***/
/***		Macintosh: Netscape 4.07, 4.5, 4.6, 4.7			***/
/***									***/
/***  Hints:	The following code must be in the <head> part:		***/
/***		<script language="javascript" type="text/javascript">	***/
/***			flashVBScript();	// init flash for IE	***/
/***		</script>						***/
/**************************************************************************/

//--- global variables ---
var nFlashVersion = 0;							// flash version


//=== global methods ========================================================

//--- VBScript-Code for Flash in Internet Explorer ---
function flashVBScript()
	{
	if((navigator.appVersion.indexOf("MSIE") > 0) &&		// Internet Explorer
	   (navigator.appVersion.indexOf("Windows") > 0))		// running on Windows?
		{
		document.write('<scr' + 'ipt language="VBScript"\>\n');
		document.write('on error resume next\n');
		document.write('nFlashVersion = 0\n');
		document.write('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2")) then nFlashVersion = 2\n');
		document.write('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")) then nFlashVersion = 3\n');
		document.write('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")) then nFlashVersion = 4\n');
		document.write('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")) then nFlashVersion = 5\n');
		document.write('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")) then nFlashVersion = 6\n');
		document.write('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")) then nFlashVersion = 7\n');
		document.write('</scr' + 'ipt\>\n\n');
		}
	}


//--- get flash version number ---
function getFlashVersion()
	{
	var strDescription = "";

	if(navigator.plugins)
		{
		if(navigator.plugins["Shockwave Flash 2.0"])		// Flash 2 
			{
			nFlashVersion = 2;
			}
		else if(navigator.plugins["Shockwave Flash"])		// Flash 3 or higher
			{
			strDescription = navigator.plugins["Shockwave Flash"].description;
			nFlashVersion = parseInt(strDescription.charAt(strDescription.indexOf(".") - 1));
			}
		}
	else if(navigator.userAgent.indexOf("WebTV") >= 0)		// WebTV ?
		{
		nFlashVersion = 2;
		}

	return nFlashVersion;
	}


//--- check if user has right flash version ---
function isFlashInstalled(nVersion)
	{
	if(getFlashVersion() >= nVersion)
		return true;

	return false;
	}


//--- output HTML for flash ---
function flashAnimation(strFlashURL, nWidth, nHeight, bPlay, bLoop, bMenu, strQuality,
                        strBgColor, strScale, strSAlign, strWMode, strFlashVars,
                        strLayerName)
	{
	var strPlay = (bPlay) ? "false" : "true";
	var strLoop = (bLoop) ? "false" : "true";
	var strMenu = (bMenu) ? "true" : "false";
	strQuality = (strQuality == "") ? "high" : strQuality;		// high quality is default
	strBgColor = (strBgColor == "") ? "" : strBgColor;
	strScale = (strScale == "") ? "showall" : strScale;		// show all is default
	strSAlign = (strSAlign == "") ? "" : strSAlign;
	strWMode = (strWMode == "") ? "" : strWmode;
	strFlashVars = (strFlashVars == "") ? "" : encodeURIComponent(strFlashVars);
	var layer = getFlashLayer(strLayerName);

	layer.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width=' + nWidth + ' height=' + nHeight + ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">\n');
	layer.write('\t\t\t<param name="movie" value="' + strFlashURL + '">\n');
	layer.write('\t\t\t<param name="play" value="' + strPlay + '">\n');
	layer.write('\t\t\t<param name="loop" value="' + strLoop + '">\n');
	layer.write('\t\t\t<param name="menu" value="' + strMenu + '">\n');
	layer.write('\t\t\t<param name="quality" value="' + strQuality + '">\n');
	layer.write('\t\t\t<param name="bgcolor" value="' + strBgColor + '">\n');
	layer.write('\t\t\t<param name="scale" value="' + strScale + '">\n');
	layer.write('\t\t\t<param name="salign" value="' + strSAlign + '">\n');
	layer.write('\t\t\t<param name="wmode" value="' + strWMode + '">\n');
	layer.write('\t\t\t<param name="flashvars" value="' + strFlashVars + '">\n');
	layer.write('\t\t\t<embed type="application/x-shockwave-flash" src="' + strFlashURL + '" width=' + nWidth + ' height=' + nHeight + ' play="' + strPlay + '" loop="' + strLoop + '" menu="' + strMenu + '" quality="' + strQuality + '" bgcolor="' + strBgColor + '" scale="' + strScale + '"salign="' + strSAlign + '" wmode="' + strWMode + '" flashvars="' + strFlashVars + '" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>\n');
	layer.write('\t\t</object>\n');
	}


//--- output alternative image ---
function alternativeImage(strImageURL, nWidth, nHeight, strMapName, strOnMouseOverText,
                          strVariable, strLayerName)
	{
	var strMap = (strMapName == "") ? "" : " usemap=\"#" + strMapName + "\"";
	var strOverOut = (strOnMouseOverText == "") ? "" : " onmouseover=\"window.status='" + strOnMouseOverText + "'; return true;\" onmouseout=\"window.status=''; return true;\"";
	var layer = getFlashLayer(strLayerName);

	if(strVariable != "")
		layer.write('<a style="text-decoration:none;" onmouseover="window.status=\'\'; return true;" onmouseout="window.status=\'\'; return true;" href="' + strVariable + '"><img src="' + strImageURL + '" width="' + nWidth + '" height="' + nHeight + strMap + strOverOut +'" border="0"></a>');
	else
		layer.write('<img src="' + strImageURL + '" width="' + nWidth + '" height="' + nHeight + strMap + strOverOut +'" border="0">');
	}


//=== private methods =======================================================

//--- get flash layer ---
function getFlashLayer(strLayerName)
	{
	if((strLayerName != null) &&
	   (strLayerName != "")   &&
	   (navigator.appName.indexOf("Netscape") >= 0))
		return eval("document." + strLayerName + ".document");
	else
		return eval("document");
	}

