/* Script for Flash Player detection and dynamic writes of swf movies vs. alt images */

// global constants - changing these will change the parameters of all swf instances, except when forced by an individual function call.
var FLASH_CONTENT_VERSION = 7;
var FLASH_CLASS_ID = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
var FLASH_CODEBASE = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0';
var FLASH_PLUGINTYPE = 'application/x-shockwave-flash';
var FLASH_PLUGINSPAGE = 'http://www.macromedia.com/go/getflashplayer';
var FLASH_ALLOWSCRIPTACCESS = 'sameDomain';
var FLASH_AUTOPLAY = 'true';
var FLASH_LOOP = 'false';
var FLASH_MENU = 'false';
var FLASH_LIVECONNECT = 'false';
var FLASH_QUALITY = 'high';
var FLASH_DEFAULT_BGCOLOR = '#ffffff';
var FLASH_DEFAULT_ALIGN = '';
var FLASH_DEFAULT_ID = 'flashMovie';

// local variables
var blnFlashCanPlay = false;
var blnIsWinIE = (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1));

/* FUNCTION PARAMETERS GUIDE:
	strMovie - path to the Flash movie [required]
	strImage - path to alternate image content [required]
	strUsemap - name of the imagemap to use [optional - use empty quotes '' if none will be used]
	intWidth - pixel width of the movie/image content
	intHeight - pixel height of the movie/image content
	hexBgcolor - background color for the flash movie [optional - defaults to FLASH_DEFAULT_BGCOLOR]
	strId - id of the Flash object, on pages with more than 1 flash instance these should be unique [optional - defaults to FLASH_DEFAULT_ID]
	strAlign - html alignment of the content [optional - defaults to FLASH_DEFAULT_ALIGN]
	intFlashVersion - version of the Flash Player required to play the content [optional - defaults to FLASH_CONTENT_VERSION]
*/	
function flashWrite(strMovie, strImage, strUsemap, intWidth, intHeight, hexBgcolor, strId, strAlign, intFlashVersion) {
	var blnPluginPresent = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( blnPluginPresent ) {
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		    for (var i = 0; i < words.length; ++i)
		    {
			if (isNaN(parseInt(words[i])))
			continue;
			var intPluginVersion = words[i]; 
		    }
		blnFlashCanPlay = intPluginVersion >= FLASH_CONTENT_VERSION;
	}
	else if (blnIsWinIE) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('blnFlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & FLASH_CONTENT_VERSION)))\n');
		document.write('</SCR' + 'IPT\> \n');
	}

	if ( blnFlashCanPlay ) {
		hexBgcolor = (hexBgcolor !== null) ? hexBgcolor : FLASH_DEFAULT_BGCOLOR;
		strId = (strId !== null) ? strId : FLASH_DEFAULT_ID;
		strAlign = (strAlign !== null) ? strAlign : FLASH_DEFAULT_ALIGN;
		intFlashVersion = (intFlashVersion !== null) ? intFlashVersion : FLASH_CONTENT_VERSION;
		
		document.write('<OBJECT classid="' + FLASH_CLASS_ID + '"');
		document.write('  codebase="' + FLASH_CODEBASE + '" ');
		document.write(' ID="' + strId + '" WIDTH="' + intWidth + '" HEIGHT="' + intHeight + '" ALIGN="' + strAlign + '">');
		document.write(' <PARAM NAME="movie" VALUE="' + strMovie + '"> <PARAM NAME="quality" VALUE="' + FLASH_QUALITY + '"> <PARAM NAME="MENU" VALUE="' + FLASH_MENU + '"> <PARAM NAME="LOOP" VALUE="' + FLASH_LOOP + '"> <PARAM NAME="PLAY" VALUE="' + FLASH_AUTOPLAY + '"> <PARAM NAME="bgcolor" VALUE="' + hexBgcolor + '"> '); 
		document.write(' <EMBED src="' + strMovie + '" quality="' + FLASH_QUALITY + '" play="' + FLASH_AUTOPLAY + '" loop="' + FLASH_LOOP + '" menu="' + FLASH_MENU + '" bgcolor="' + hexBgcolor + '"  ');
		document.write(' swLiveConnect="' + FLASH_LIVECONNECT + '" WIDTH="' + intWidth + '" HEIGHT="' + intHeight + '" NAME="' + strId + '" ALIGN="' + strAlign + '"');
		document.write(' TYPE="' + FLASH_PLUGINTYPE + '" PLUGINSPAGE="' + FLASH_PLUGINSPAGE + '">');
		document.write(' </EMBED>');
		document.write(' </OBJECT>');
	} else{
		document.write('<img src="' + strImage + '" width="' + intWidth + '" height="' + intHeight + '" align="' + strAlign + '" border="0" alt="" usemap="#' + strUsemap + '" />');
	}
}