/*
 * 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(fpl, id, width, height, ver, bgcolor, quality, loc, redirect, detect) {
	if (!document.getElementById) return;
	this.DETECT_KEY = detect ? detect : "detectflash";
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if (fpl) this.setAttribute("swf", fpl);
	if (id) this.setAttribute("id", id);
	if (width) this.setAttribute("width", width);
	if (height) this.setAttribute("height", height);
	if (ver) this.setAttribute("version", new deconcept.PlayerVersion(ver.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);
	this.addParam("quality", quality ? quality : "high");
	this.setAttribute("useExpressInstall", false);
	this.setAttribute("doExpressInstall", false);
	this.setAttribute("xiRedirectUrl", loc ? loc : window.location);
	this.setAttribute("redirectUrl", "");
	if (redirect) this.setAttribute("redirectUrl", redirect);
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = path ? path : "expressinstall.swf";
		this.setAttribute("useExpressInstall", true);
	},
	setAttribute: function(key, value) {
		this.attributes[key] = value;
	},
	getAttribute: function(key) {
		return this.attributes[key];
	},
	addParam: function(key, value) {
		this.params[key] = value;
	},
	getParams: function() {
		return this.params;
	},
	addVariable: function(key, value) {
		this.variables[key] = value;
	},
	getVariable: function(key) {
		return this.variables[key];
	},
	getVariables: function() {
		return this.variables;
	},
	getVariablePairs: function() {
		var p = new Array();
		var key;
		var vars = this.getVariables();
		for (key in vars) p[p.length] = key + "=" + vars[key];
		return p;
	},
	getSWFHTML: function() {
		var output = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute("swf", this.xiSWFPath);
			}
			var params = this.getParams();
			var vars = this.getVariablePairs().join("&");
			output = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\" id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" ";
			for (var key in params) output += [key] + "=\"" + params[key] + "\" ";
			if (vars.length > 0) output += "flashvars=\"" + vars + "\"";
			output += "/>";
		} else {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute("swf", this.xiSWFPath);
			}
			var params = this.getParams();
			var vars = this.getVariablePairs().join("&");
			output = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\">";
			output += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />";
			for (var key in params) output += "<param name=\"" + key + "\" value=\"" + params[key] + "\" />";
			if (vars.length > 0) output += "<param name=\"flashvars\" value=\"" + vars + "\" />";
			output += "</object>";
		}
		return output;
	},
	write: function(id) {
		if (this.getAttribute("useExpressInstall")) {
			var ver = new deconcept.PlayerVersion([6, 0, 65]);
			if (this.installedVer.versionIsValid(ver) && !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 e = (typeof id == "string") ? document.getElementById(id) : id;
			e.innerHTML = this.getSWFHTML();
			return true;
		} else {
			if (this.getAttribute("redirectUrl") != "") document.location.replace(this.getAttribute("redirectUrl"));
		}
		return false;
	}
}
deconcept.SWFObjectUtil.getPlayerVersion = function() {
	var ver = new deconcept.PlayerVersion([0, 0, 0]);
	if (navigator.plugins && navigator.mimeTypes.length) {
		var pl = navigator.plugins["Shockwave Flash"];
		if (pl && pl.description) ver = new deconcept.PlayerVersion(pl.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 x = 3;
			while (axo) {
				try {
					x++;
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + x);
					ver = new deconcept.PlayerVersion([x, 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");
					ver = new deconcept.PlayerVersion([6, 0, 21]);
					axo.AllowScriptAccess = "always";
				}
				catch(e) {
					if (ver.major == 6) return ver;
				}
				try {
					axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				}
				catch(e) {}
			}
			if (axo != null) ver = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return ver;
}
deconcept.PlayerVersion = function(ver) {
	this.major = ver[0] != null ? parseInt(ver[0]) : 0;
	this.minor = ver[1] != null ? parseInt(ver[1]) : 0;
	this.rev = ver[2] != null ? parseInt(ver[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(ver) {
	if (this.major < ver.major) return false;
	if (this.major > ver.major) return true;
	if (this.minor < ver.minor) return false;
	if (this.minor > ver.minor) return true;
	if (this.rev < ver.rev) return false;
	return true;
}
deconcept.util = {
	getRequestParameter: function(p) {
		var q = document.location.search || document.location.hash;
		if (p == null) return q;
		if (q) {
			var loc = q.substring(1).split("&");
			for (var i = 0; i < loc.length; i++) if (loc[i].substring(0, loc[i].indexOf("=")) == p) return loc[i].substring((loc[i].indexOf("=") + 1));
		}
		return "";
	}
}
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var e = document.getElementsByTagName("OBJECT");
	for (var i = e.length - 1; i >= 0; i--) {
		e[i].style.display = "none";
		for (var key in e[i]) if (typeof e[i][key] == "function") e[i][key] = 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;
	}
}
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;
