/** Quote Constant */
var Q = "\"";

/**
 * Prints flash markup within the specified HTML element
 * @param flashContainerID	The ID of the element the markup should be printed within
 * @param data	The flash source file
 * @param width The width of the flash object
 * @param height	The height of the flash object
 * @param bgcolor	The hex code of the background color of the flash object
 * @param altImage	An alternative image to use if Flash is not installed
 * @param altName	A user friendly name for the Flash object
 * @author pmander
 */
function printFlash(flashContainerID, data, width, height, bgcolor, altImage, altName)
{	
	var flashContainer = document.getElementById(flashContainerID);
	var markup;
	
	if(isFlashInstalled())
	{
		if(bgcolor == "")
			bgcolor = "#ffffff";
		
		markup = "<object type=\"application/x-shockwave-flash\" "
					+ "data=" +  Q + data + Q
					+ "width=" + Q + width + Q
					+ "height=" + Q + height + Q + ">"
					+ "<param name=\"movie\" value=" + Q + data + Q + "/>"
					+ "<param name=\"quality\" value=\"high\" />"
					+ "<param name=\"bgcolor\" value=" + Q + bgcolor + Q + " />"
					+ "<embed src=" + Q + data + Q
						+ "type=\"application/x-shockwave-flash\" "
						+ "width=" + Q + width + Q
						+ "height=" + Q + height + Q
						+ "quality=\"high\" "
						+ "bgcolor=" + Q + bgcolor + Q + " >"
					+ "</embed>"
				  + "</object>";
		
		flashContainer.style.background = "none";
				  
	}
	else if(altImage != "")
	{
		markup = "<img src=" + Q + altImage + Q				
					+ "width=" + Q + width + Q
					+ "height=" + Q + height + Q
					+ "alt=" + Q + altName + Q
					+ "style=\"border-width: 0\" />";
					
		flashContainer.style.background = "none";					
	}
	else
	{
		if(altName == "")
			altName = "This feature";		
		
		var url = "http://www.macromedia.com/software/flashplayer/";
		
		//modify this text for different languages
		markup =	"<p><strong>" + altName + " cannot be displayed.</strong></p>" 
				  +	"<p>To benefit from this feature the Macromedia Flash Player plugin must be installed.</p>"
				  + "<p><a target=\"_blank\" href=" + Q + url + Q + ">Download Macromedia Flash Player plugin.</a></p>";
		flashContainer.style.height = height + "px";
		flashContainer.style.width = width + "px";  
		flashContainer.style.overflow = "auto";
	}

	flashContainer.innerHTML = markup;
}

/**
 * Determines if flash is installed 
 */
function isFlashInstalled()
{
 	var flashInstalled = false;

	if(navigator.mimeTypes['application/x-shockwave-flash'] && navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin)
	{
		flashInstalled = true;
	}
	else if(navigator.plugins["Shockwave Flash"])
	{
		flashInstalled = true;
	}
	else if(navigator.appName.indexOf("Internet Explorer"))
	{
		try
		{
			var test = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			flashInstalled = true;
		}
		catch(e) { }
	}		

	return flashInstalled;
}
