﻿if(typeof(flashElementsIndex) == "undefined"){
	var flashElementsIndex = 0;
}

if(typeof(swfobjectloaded) == "undefined"){
	var swfobjectloaded = false;
}

function loadSWF(elementId, flashUrl, width, height, quality, scale, loop, fpversion, wmode, altcontent, expressinstallUrl)
{
	checkLoaded();
	
	function checkLoaded() {
		
		checkForSWFObject();
		
		if(typeof(swfobject) != "undefined") {
			writeSWF();
		} else {
			setTimeout(checkForSWFObject, 50);
		}
	}
	
	function writeSWF() {
		
		if (swfobject.hasFlashPlayerVersion("6.0.65")) {
			/*
			*	swfobject 2.1 replaces the target element with a flash embed element.  MOSS strips out non-supported elements
			*	when it saves the page, so would strip out the flash element (and not replace its holder).  This code creates
			*	a nested element to add the flash content into.
			*/
			var holder = document.createElement("div");
				holder.id = "flash_element"+flashElementsIndex;
			document.getElementById(elementId).appendChild(holder);
			
			swfobject.embedSWF(flashUrl, "flash_element"+flashElementsIndex, width, height, fpversion, expressinstallUrl, {}, {menu:"false", quality:quality, wmode:wmode, scale:scale, salign:"lt", loop:loop, allowScriptAccess:"always"}, {});
			/*
			*	IE scripting-in-a-form fix.
			*/
			window["flash_element"+flashElementsIndex] = document.getElementById("flash_element"+flashElementsIndex);
			
			flashElementsIndex++;
		} else {
			/*
			*	If the correct version of the Flash Plugin is not installed on the users' computer, then we add a (CIO specified)
			*	no flash message.
			*/
			document.getElementById(elementId).innerHTML = altcontent;
		}
	}
}

function checkForSWFObject() {
	/*
	*	This function detects whether swfobject is embedded in the page.  If it is not (which it should be) then we switch
	*	to a backup source file stored publically on the Google AJAX libraries site.
	*/
	if(typeof(swfobject) != "undefined"){
		isLoaded();
	} else {
		//
	}
	
	function isLoaded() {
		swfobjectloaded = true;
	}
}