var FlashHandler = {
	all : {},
	
	//Load the flash objects thats in div tags onto the page
	LoadFlash : function ()
	{
		var arrDivs;
		arrDivs = document.getElementsByTagName("div");
		for(var i=0;i<arrDivs.length;i++)
		{
			//Find the flash divs
			if (arrDivs[i].id != null)
			{
				if (arrDivs[i].id.indexOf("flashdiv") >= 0)
				{
					var strFlashText = "";
					var strFlashDivText = arrDivs[i].innerHTML;
					arrDivs[i].title = "";
					//alert(strFlashDivText);
					var objFlashObject = new FlashObject(arrDivs[i].id, strFlashDivText);
					objFlashObject.RenderDivHTML();
				}
			}
		}
	}
		
};

function FlashObject (strFlashDivName, strFlashDivText)
{
	this.name = strFlashDivName;
	this._Attributes = {};
	var arrFlashSettings = strFlashDivText.split("|");
	
	for(var j=0;j<arrFlashSettings.length; j++)
	{
		var arrFlashAttrib = arrFlashSettings[j].split("=")
		
		//Check if the arrFlashAttrib is 2 elements, only add those that conform to it
		if (arrFlashAttrib.length == 2)
		{
			this.AddAttribute(arrFlashAttrib[0], arrFlashAttrib[1]);
		}
	}
	
	FlashHandler.all[strFlashDivName] = this;
};

FlashObject.prototype.AddAttribute = function (strName, strValue) {
	var objAttrib = new FlashAttribute(strName, strValue);
	//alert(objAttrib.name + " " + objAttrib.value);
	this._Attributes[strName] = objAttrib;
};

FlashObject.prototype.RenderDivHTML = function () {
	//Get a handle on the div
	var objFlashDIV = document.getElementById(this.name);
	if (objFlashDIV != null)
	{
		objFlashDIV.innerHTML = this;
	}
};

FlashObject.prototype.toString = function() {
	var strFlashText = "";
	strFlashText = "<OBJECT id=" + this.name + "_object codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 height=" + this._Attributes["height"].value + " width=" + this._Attributes["width"].value + " classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 VIEWASTEXT>";	
	strFlashText += "<PARAM NAME='_cx' VALUE='10583'>";
	strFlashText += "<PARAM NAME='_cy' VALUE='7938'>";
	strFlashText += "<PARAM NAME='FlashVars' VALUE=''>";
	strFlashText += "<PARAM NAME='Movie' VALUE='" + this._Attributes["url"].value + "'>";
	strFlashText += "<PARAM NAME='Src' VALUE='" + this._Attributes["url"].value + "'>";
	strFlashText += "<PARAM NAME='WMode' VALUE='Opaque'>";
	strFlashText += "<PARAM NAME='Play' VALUE='-1'>";
	strFlashText += "<PARAM NAME='Loop' VALUE='-1'>";
	strFlashText += "<PARAM NAME='Quality' VALUE='High'>";
	strFlashText += "<PARAM NAME='SAlign' VALUE=''>";
	strFlashText += "<PARAM NAME='Menu' VALUE='0'>";
	strFlashText += "<PARAM NAME='Base' VALUE=''>";
	strFlashText += "<PARAM NAME='AllowScriptAccess' VALUE='always'>";
	strFlashText += "<PARAM NAME='Scale' VALUE='ShowAll'>";
	strFlashText += "<PARAM NAME='DeviceFont' VALUE='0'>";
	strFlashText += "<PARAM NAME='EmbedMovie' VALUE='0'>";
	strFlashText += "<PARAM NAME='BGColor' VALUE='999999'>";
	strFlashText += "<PARAM NAME='SWRemote' VALUE=''>";
	strFlashText += "<EMBED src='" + this._Attributes["url"].value + "' menu=false quality=best wmode=opaque bgcolor=#999999  WIDTH='" + this._Attributes["width"].value + "' HEIGHT='" + this._Attributes["height"].value + "' NAME='" + this.name + "_object' ALIGN=''";
	strFlashText += "TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>";
	strFlashText += "</OBJECT>";
	
	return strFlashText;
};

function FlashAttribute(strName, strValue) {
	this.name	= strName;
	this.value	= strValue;
};