/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined")
{
	var deconcept = new Object();
}

if(typeof deconcept.util == "undefined")
{
	deconcept.util = new Object();
}

if(typeof deconcept.SWFObjectUtil=="undefined")
{
	deconcept.SWFObjectUtil = new Object();
}

deconcept.SWFObject = function(swf, id, width, height, version, backgroundColor, quality, url, redirectUrl, detectKey)
{
	if(!document.getElementById)
	{
		return;
	}
	
	this.DETECT_KEY = (detectKey) ? detectKey : "detectflash";
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	
	if (swf)
	{
		this.setAttribute("swf", swf);
	}
	
	if (id)
	{
		this.setAttribute("id",id);
	}
	
	if (width)
	{
		this.setAttribute("width",width);
	}
	
	if (height)
	{
		this.setAttribute("height",height);
	}
	
	if (version)
	{
		this.setAttribute("version", new deconcept.PlayerVersion(version.toString().split(".")));
	}
	
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7)
	{
		deconcept.SWFObject.doPrepUnload=true;
	}
	
	if (backgroundColor)
	{
		this.addParam("bgcolor", backgroundColor);
	}
	
	var q = (quality && quality != "undefined") ? quality : "high";
	
	this.addParam("quality", q);
	this.setAttribute("useExpressInstall",false);
	this.setAttribute("doExpressInstall",false);
	var _url = (url) ? url : window.location;
	this.setAttribute("xiRedirectUrl", _url);
	this.setAttribute("redirectUrl", "");
	if (redirectUrl)
		this.setAttribute("redirectUrl", redirectUrl);
};

deconcept.SWFObjectUtil.getPlayerVersion = 
	function ()
	{
		var playerVersion = new deconcept.PlayerVersion([0,0,0]);
		if (navigator.plugins && navigator.mimeTypes.length)
		{
			var swfPlugin = navigator.plugins["Shockwave Flash"];
			if (swfPlugin && swfPlugin.description)
			{
				playerVersion = new deconcept.PlayerVersion(swfPlugin.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));
			}
		}
		else
		{
			var axo = null;
			if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0)
			{
				var axo = 1;
				var majorVersion = 3;
				while (axo)
				{
					try
					{
						majorVersion++;
						axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + majorVersion);
						playerVersion = new deconcept.PlayerVersion([majorVersion,0,0]);
					}
					catch (e)
					{
						axo = null;
					}
				}
			}
			else
			{
				try
				{
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
				}
				catch (e)
				{
					try
					{
						axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
						playerVersion = new deconcept.PlayerVersion([6,0,21]);
						axo.AllowScriptAccess = "always";
					}
					catch (e)
					{
						if(playerVersion.major == 6)
						{
							return playerVersion;
						}
					}

					try
					{
						axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
					}
					catch(e){}
				}

				if (axo != null)
				{
					playerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
				}
			}
		}

		return playerVersion;
	};
		
deconcept.PlayerVersion = 
	function (versionArray)
	{
		this.major = (versionArray[0] != null) ? parseInt(versionArray[0]) : 0;
		this.minor = (versionArray[1] != null) ? parseInt(versionArray[1]) : 0;
		this.rev = (versionArray[2] != null) ? parseInt(versionArray[2]) : 0;
	};
	
deconcept.PlayerVersion.prototype.versionIsValid = 
	function (flashVersion)
	{
		if (this.major < flashVersion.major)
		{
			return false;
		}
		else if (this.major > flashVersion.major)
		{
			return true;
		}
		else if (this.minor < flashVersion.minor)
		{
			return false;
		}
		else if (this.minor > flashVersion.minor)
		{
			return true;
		}
		else if (this.rev < flashVersion.rev)
		{
			return false;
		}

		return true;
	};
		
deconcept.util = {
	getRequestParameter:
	function (key)
	{
		var paramPairs = document.location.search || document.location.hash;
		if(key == null)
		{
			return paramPairs;
		}
			
		if(key)
		{
			var paramArray = paramPairs.substring(1).split("&");
			for(var i = 0; i< paramArray.length; i++)
			{
				if(paramArray[i].substring(0, paramArray[i].indexOf("=")) == key)
				{
					return paramArray[i].substring((paramArray[i].indexOf("=") + 1));
				}
			}
		}
	
		return "";
	}
};
	
deconcept.SWFObjectUtil.cleanupSWFs = 
	function()
	{
		var _2f = document.getElementsByTagName("OBJECT");
		for (var i=_2f.length-1;i>=0;i--)
		{
			_2f[i].style.display = "none";
			for (var x in _2f[i])
			{
				if (typeof _2f[i][x]=="function")
				{
					_2f[i][x] = function() { };
				}
			}
		}
	};

deconcept.SWFObject.prototype = {
	useExpressInstall: 
	function (xiSwfPath)
	{
		this.xiSWFPath = (!xiSwfPath) ? "expressinstall.swf" : xiSwfPath;
		this.setAttribute("useExpressInstall", true);
	},
	
	setAttribute:
	function (attributeName, value)
	{
		this.attributes[attributeName] = value;
	},
	
	getAttribute:
	function (attributeName)
	{
		return this.attributes[attributeName];
	},
	
	addParam:
	function (paramName, value)
	{
		this.params[paramName] = value;
	},
	
	getParams:
	function ()
	{
		return this.params;
	},
	
	addVariable:
	function (varName,value)
	{
		this.variables[varName] = value;
	},
	
	getVariable:
	function (varName)
	{
		return this.variables[varName];
	},
	
	getVariables:
	function ()
	{
		return this.variables;
	},
	
	getVariablePairs:
	function ()
	{
		var pairs = [];
		var key;
		var variables = this.getVariables();
		for (key in variables)
		{
			pairs.push(key + "=" + variables[key]);
		}
		
		return pairs;
	},
	
	getSWFHTML:
	function ()
	{
		var htmlStr = "";
		var params = null;
		var pairs = null;
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)
		{
			if (this.getAttribute("doExpressInstall"))
			{
				this.addVariable("MMplayerType","PlugIn");
				this.setAttribute("swf", this.xiSWFPath);
			}
			htmlStr = "<embed type=\"application/x-shockwave-flash\" src=\"" + 
						this.getAttribute("swf") + "\" width=\""+this.getAttribute("width") + 
						"\" height=\"" + this.getAttribute("height") + "\" style=\"" + 
						this.getAttribute("style") + "\"";
			htmlStr += " id=\"" + this.getAttribute("id") + "\" name=\"" +this.getAttribute("id") +	"\" ";
			params = this.getParams();
			for (var key in params)
			{
				htmlStr += [key] + "=\"" + params[key] + "\" ";
			}
			
			pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0)
			{
				htmlStr += "flashvars=\"" + pairs + "\"";
			}
			
			htmlStr += "/>";
		}
		else
		{
			if (this.getAttribute("doExpressInstall"))
			{
				this.addVariable("MMplayerType","ActiveX");
				this.setAttribute("swf",this.xiSWFPath);
			}
			
			htmlStr = "<object id=\"" + this.getAttribute("id") + 
						"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" +
						this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") +
						"\" style=\"" + this.getAttribute("style") + "\">";
			htmlStr += "<param name=\"movie\" value=\"" + this.getAttribute("swf") +"\" />";
			params = this.getParams();
			for (var key in params)
			{
				htmlStr += "<param name=\"" + key + "\" value=\"" + params[key]+"\" />";
			}
			
			pairs = this.getVariablePairs().join("&");
			if (pairs.length > 0)
			{
				htmlStr += "<param name=\"flashvars\" value=\"" + params + "\" />";
			}
			
			htmlStr += "</object>";
		}
		
		return htmlStr;
	},
	
	write:
	function(tag)
	{
		
		if (this.getAttribute("useExpressInstall"))
		{
			var playerVersion = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(playerVersion) && !this.installedVer.versionIsValid(this.getAttribute("version")))
			{
				this.setAttribute("doExpressInstall",true);
				this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl")));
				document.title = document.title.slice(0,47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		
		if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version")))
		{
			var element = (typeof tag == "string") ? document.getElementById(tag) : tag;
			element.innerHTML = this.getSWFHTML();
			return true;
		}
		else
		{
			if (this.getAttribute("redirectUrl")!="")
			{
				document.location.replace(this.getAttribute("redirectUrl"));
			}
		}
		
		return false;
	}
};
	
if (deconcept.SWFObject.doPrepUnload)
{
	if (!deconcept.unloadSet)
	{
		deconcept.SWFObjectUtil.prepUnload = 
			function ()
			{
				__flash_unloadHandler = function() { };
				__flash_savedUnloadHandler = function() { };
				window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
			};
		
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet=true;
	}
}

if (!document.getElementById && document.all)
{
	document.getElementById = 
		function (id)
		{
			return document.all[id];
		};
}

var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject;
var SWFObject = deconcept.SWFObject;