/**
 * 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
 *
 * Modified by Michael Volk for legibility.
 *
 */

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();
}

// _5 = minimum req'd Flash version
deconcept.SWFObject = function(swfSrc, id, w, h, minSupportedVersion, bgColor, quality, _8, _9, _a) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = _a ? _a : "detectflash";
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if (swfSrc) {
		this.setAttribute("swf", swfSrc);
	}
	if (id) {
		this.setAttribute("id", id);
	}
	if (w) {
		this.setAttribute("width", w);
	}
	if (h) {
		this.setAttribute("height", h);
	}
	this.setAttribute("class",null);
	if (minSupportedVersion) {
		this.setAttribute("version", new deconcept.PlayerVersion(minSupportedVersion.toString().split(".")));
	}
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		deconcept.SWFObject.doPrepUnload = true;
	}
	if (bgColor) {
		this.addParam("bgcolor", bgColor);
	}
	var q = quality ? quality : "high";
	this.addParam("quality", q);
	this.setAttribute("useExpressInstall", false);
	this.setAttribute("doExpressInstall", false);
	var _c = (_8) ? _8 : window.location;
	this.setAttribute("xiRedirectUrl", _c);
	this.setAttribute("redirectUrl", "");
	if (_9) {
		this.setAttribute("redirectUrl",_9);
	}
};

deconcept.SWFObject.prototype = {
	
	useExpressInstall: function(url) {
		this.xiSWFPath = !url ? "expressinstall.swf" : url;
		this.setAttribute("useExpressInstall", true);
	},
	
	setAttribute: function(attrib, value) {
		this.attributes[attrib] = value;
	},
	
	getAttribute: function(attrib) {
		return this.attributes[attrib];
	},
	
	addParam: function(param, value) {
		this.params[param] = value;
	},
	
	getParams: function() {
		return this.params;
	},
	
	addVariable: function(name, value) {
		this.variables[name] = value;
	},
	
	getVariable: function(name) {
		return this.variables[name];
	},
	
	getVariables:function() {
		return this.variables;
	},
	
	getVariablePairs: function() {
		var pairs = new Array();
		var key;
		var variables = this.getVariables();
		for (key in variables) {
			pairs[pairs.length] = key + "=" + variables[key];
		}
		return pairs;
	},
	
	getSWFHTML: function() {
		var html = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute("swf", this.xiSWFPath);
			}
			html = "<embed type=\"application/x-shockwave-flash\" " +
			              "src=\"" + this.getAttribute("swf") + "\" " +
			              "width=\"" + this.getAttribute("width") + "\" " +
			              "height=\"" + this.getAttribute("height") + "\" " + 
			              "style=\"" + this.getAttribute("style") + "\" ";
			html +=       "id=\"" + this.getAttribute("id") + "\" " +
			              "name=\"" + this.getAttribute("id") + "\" ";
			if (this.getAttribute("class")) {
				html +=   "class=\"" + this.getAttribute("class") + "\" ";
			}
			var p = this.getParams();
			for (var key in p) {
				html += [key] + "=\"" + p[key] + "\" ";
			}
			var v = this.getVariablePairs().join("&");
			if (v.length > 0) {
				html += "flashvars=\"" + v + "\"";
			}
			html += "/>";
		} else {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute("swf", this.xiSWFPath);
			}
			html = "<object id=\"" + this.getAttribute("id") + "\" " +
			               "classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " + 
			               "width=\"" + this.getAttribute("width") + "\" " +
			               "height=\"" + this.getAttribute("height") + "\" " +
			               "style=\"" + this.getAttribute("style") + "\" ";
			if (this.getAttribute("class")) {
				html +=    "class=\"" + this.getAttribute("class") + "\" ";
			}
			html += ">";
			html += "<param name=\"movie\" " +
			               "value=\"" + this.getAttribute("swf") + "\" />";
			var p = this.getParams();
			for (var key in p) {
				html += "<param name=\"" + key + "\" " +
				               "value=\"" + p[key] + "\" />";
			}
			var v = this.getVariablePairs().join("&");
			if (v.length > 0) {
				html += "<param name=\"flashvars\" value=\"" + v + "\" />";
			}
			html += "</object>";
		}
		return html;
	},
	
	// pass elementId or the element itself; sets innerhtml of the element to the flash embedding code
	write: function(element) {
		if (this.getAttribute("useExpressInstall")) {
			var expressMinVersion = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressMinVersion) && !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 n = (typeof element == "string") ? document.getElementById(element) : element;
			n.innerHTML = this.getSWFHTML();
			return true;
		} else {
			if (this.getAttribute("redirectUrl") != "") {
				document.location.replace(this.getAttribute("redirectUrl"));
			}
		}
		return false;
	}
};

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


// Determines Flash Player major, minor and revision version numbers
deconcept.PlayerVersion = function(versionNumber) {
	this.major = versionNumber[0] != null ? parseInt(versionNumber[0]) : 0;
	this.minor = versionNumber[1] != null ? parseInt(versionNumber[1]) : 0;
	this.rev   = versionNumber[2] != null ? parseInt(versionNumber[2]) : 0;
};

deconcept.PlayerVersion.prototype.versionIsValid = function(fv) {
	if (this.major < fv.major) {
		return false;
	} if (this.major > fv.major) {
		return true;
	}
	if (this.minor < fv.minor) {
		return false;
	}
	if (this.minor > fv.minor) {
		return true;
	}
	if (this.rev < fv.rev) {
		return false;
	}
	return true;
};

deconcept.util = {
	getRequestParameter: function(_2b) {
		var q = document.location.search || document.location.hash;
		if (_2b == null) { return q; }
		if (q) {
			var _2d = q.substring(1).split("&");
			for (var i = 0; i < _2d.length; i++) {
				if (_2d[i].substring(0,_2d[i].indexOf("=")) == _2b) {
					return _2d[i].substring((_2d[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
};

// Finds OBJECT tags in the HTML document, hides them, and
// strips out any functions attached to them.
// Why? Dunno...
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objectElements = document.getElementsByTagName("OBJECT");
	for (var i = objectElements.length - 1; i >= 0; i--) {
		objectElements[i].style.display = "none";
		for (var x in objectElements[i]) {
			if (typeof objectElements[i][x] == "function") {
				objectElements[i][x] = function() { };
			}
		}
	}
};

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;
	}
}

// Adds getElementById function to document if not already
// provided by document and if document supports 'all' property.
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;