/********************************************************************************************************************************************************************************************
                                                                            FLASH.JS

Copyright © 2007-2008 Illusionator, Inc.

Functions that support the playing of Flash movies.

REQUIRED INCLUDES: swfobject.js for SWFObject 2.0
REQUIRED FILES [if IlsInlineFlash() is ever invoked with "bShowControls" = true]: "ButtonPlay.gif" and "ButtonPause.gif" in the "sImagesDir" directory.

********************************************************************************************************************************************************************************************/

// IlsInlineFlash(sPath, nWidth, nHeight, bShowControls, nBackgroundColor)
//		sPath:				Path, relative to the page that invokes this function, of the Flash movie to be played.  Must be an ".swf" file.
//		nWidth:				Width, in pixels of the Flash movie to be played.
//		nHeight:			Height, in pixels, of the Flash movie to be played.  NOTE: If "bShowControls" is true, the actual displayed video will be 28 pixels taller, because of the
//							controls beneath the movie.
//		bShowControls:		true iff player controls should be displayed beneath the movie.
//		sBackgroundColor:	Hex value of the background color to use (in case there are transparent areas in the movie).  Uses the form "#rrggbb", where "rr" is the hex value of the
//							red component of the color, "gg" is the hex value of the green, and "bb" is the hex value of the blue.
//		sImagesDir:			Path, relative to the page that invokes this function, of the directory that holds the "ButtonPlay.gif" and "ButtonPause.gif" images that are displayed
//							when "bShowControls" is true.  If the value of this argument is not the empty string (for the current directory), it should end in a trailing slash ("/").
//							This argument is ignored (and may be omitted) if "bShowControls" is false.
//	returns:	Nothing
//
// Displays and plays a Flash movie at the place in the HTML file where this function is invoked.

function IlsInlineFlash(sPath, nWidth, nHeight, bShowControls, sBackgroundColor, sImagesDir)
{
	sFlashVersion = "4.0";

	// Dynamically compute a new HTML "id" each time this function is invoked
	if (!IlsInlineFlash.IlsCount) {
		IlsInlineFlash.IlsCount = 0;
	}
	IlsInlineFlash.IlsCount++;
	var sId = "FlashContent" + IlsInlineFlash.IlsCount;

	// If we will be displaying "Play" and "Pause" controls beneath the video, encase the whole video inside of a table so the controls can be in a separate row of the table
	if (bShowControls) {
		document.write('<table border="0" cellspacing="0" cellpadding="0"><tr><td>');
	}

	// Write out, in the place where this function is invoked, the alternative content to be displayed in the event there is no Flash player or JavaScript is not turned on
	document.write('<div id="', sId, '"><table width="', nWidth, '" height="', nHeight, '" cellspacing="0" cellpadding="0"><tr><td>',
		'<p align="center"><b><font color="#FFFF00"><u>NOTE</u>:</font></b><br><font size="2">If you do not see a video here, please make sure you have the latest ',
		'<a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player</a> installed, and that your browser has ',
		'<a href="javascript.htm">JavaScript support turned on</a>. &nbsp;If you still do not see a video here, you probably have a slightly corrupt installation of Adobe Flash Player. &nbsp;Please ',
		'<a href="http://www.adobe.com/go/tn_14157">uninstall</a> and then <a href="http://www.adobe.com/go/getflashplayer">re-install</a> Adobe Flash Player.</font></p></td></tr></table></div>');

	// Generate the code to embed the Flash player using SWFObject 2.0.  Note that the swliveconnect: "true" is needed for Netscape browsers earlier than version 6.2.
	swfobject.embedSWF(sPath, sId, nWidth, nHeight, sFlashVersion, false, false, {bgcolor: sBackgroundColor, swliveconnect: "true"});

	// If we are showing "Play" and "Pause" controls, add them in a separate table row beneath the video
	if (bShowControls) {
		document.write('</td></tr><tr><td>',
			'<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#494949"><tr>',
			'<td width="33%"></td><td width="1"><img border="0" src="', sImagesDir, 'ButtonPlay.gif" width="69" height="28" onClick="IlsGetObj(\'', sId, '\').Play();"></td>',
			'<td width="34%"></td><td width="1"><img border="0" src="', sImagesDir, 'ButtonPause.gif" width="69" height="28" onClick="IlsGetObj(\'', sId, '\').StopPlay();"></td>',
			'<td width="33%"></td></tr></table></td></tr></table>');
	}
} // IlsInlineFlash
