var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";this.compatMode=!1;/*@cc_on var IEver=(@_jscript_version==9)?9:(@_jscript_version==5.8)?8:(@_jscript_version==5.7&&window.XMLHttpRequest)?7:(@_jscript_version==5.6||(@_jscript_version==5.7&&!window.XMLHttpRequest))?6:(@_jscript_version==5.5)?5.5:5;this.compatMode=(this.version!=IEver);this.version=IEver; @*/},searchString:function(b){for(var a=0;a<b.length;a++){var c=b[a].string,d=b[a].prop;this.versionSearchString=b[a].versionSearch||b[a].identity;if(c){if(c.indexOf(b[a].subString)!=-1)return b[a].identity}else if(d)return b[a].identity}}, searchVersion:function(b){var a=b.indexOf(this.versionSearchString);if(a!=-1)return parseFloat(b.substring(a+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.userAgent,subString:"EAWebKit",versionSearch:"EAWebKit",identity:"EAWebKit"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera, identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"}, {string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"EAWebKit",identity:"PS3"},{string:navigator.platform,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"iPad",identity:"iPad"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();
var WebInstaller = WebInstaller ||
{
	forcedMinimumWindowsDLLVersion: "159",
	supportsMac: false,
	name: "SOE Web Installer",
	xpi: "soe.xpi",
	xpiIcon: "icon.png",
	forcedMinimumWindowsDLL: "npsoeact.dll.sig",
	setup: "Install_SOEWebInstaller.exe",
	crx: "SOEWebInstaller.crx",
	dmg: "SOEWebInstaller.dmg",
	cab: "SOEWebInstaller.cab",
	cabVersion: "1,0,3,0",
	activeXID: "000F1EA4-5E08-4564-A29B-29076F63A37A",
	activeXObject: "SOEWebInstaller.1",
	gameName: undefined,
	windowsLibraryVerFile: "ActionVersion.txt",
	macLibraryVerFile: "ActionVersion.txt",
	//windowsControlVerFile: "control.ver",     // Turn this on when we want to upgrade the Windows control
	//macControlVerFile: "control.ver",         // Turn this on when we want to upgrade the Mac control

	fakeMode: (location.search.search('fakeInstaller=1') > 0),
	directMode: (location.search.search("mode=1") > 0) || navigator.userAgent.search("SOEWebKit") >= 0,
	activeX: (window.ActiveXObject !== undefined),

	InitialAttributes: {},
	instance: function(folderName, init) {
		//noinspection AssignmentToFunctionParameterJS
		folderName = folderName || "";
		var obj = this.Plugins[folderName];
		var param;
		if (obj === undefined) {
			obj = new this.Proxy(folderName);
			this.Plugins[folderName] = obj;
			for (param in this.InitialAttributes) {
				obj[param] = this.InitialAttributes[param];
			}
		}
		for (param in init) {
			obj[param] = init[param];
		}
		if ('command' in obj === false) {
			if (folderName === '') {
				obj.command = "initOnly";
			} else {
				obj.command = "install";
			}
		}
		return obj;
	},
	remove: function(folderName) {
		//noinspection AssignmentToFunctionParameterJS
		folderName = folderName || "";
		if (this.Plugins[folderName] !== undefined) {
			this.Plugins[folderName].removeFromPage();
			delete this.Plugins[folderName];
		}
	},
	removeAll: function() {
		for (var key in this.Plugins) {
			this.remove(key);
		}
	},
	loadJS: function(url) {
		var script = document.createElement('script');
		script.type = "text/javascript";
		script.src = url;
		document.getElementsByTagName("head")[0].appendChild(script);
	},
	makePagePath: function(tail) {
		var pathname = location.pathname;
		if (tail.substring(0, 1) === '/') {
			pathname = tail;
		} else {
			var len = pathname.length;
			var ext = pathname.substring(len - 4);
			var i1, i2;
			if (ext === '.htm' || ext === 'html') {
				i1 = pathname.lastIndexOf('/');
				i2 = pathname.lastIndexOf('\\');
				if (i2 > i1) {
					i1 = i2;
				}
				pathname = pathname.substring(0, i1);
			}
			if (pathname.substring(pathname.length - 1) !== '/') {
				pathname += "/";
			}
			pathname += tail;
		}
		return location.protocol + "//" + location.host + pathname;
	},
	init: function() {
		if ('jsPath' in this === false) {
			var scripts = document.getElementsByTagName("script");
			var path = scripts[scripts.length - 1].src;
			this.jsPath = path.substring(0, path.lastIndexOf('/') + 1);
		}
		if (this.jsPath.substring(0, 4) !== "http") {
			this.jsPath = this.makePagePath(this.jsPath);
		}
		if ('pluginPath' in this === false) {
			this.pluginPath = this.jsPath;
		}
		if (this.pluginPath.substring(0, 4) !== "http") {
			this.pluginPath = this.makePagePath(this.pluginPath);
		}
		this.httpPluginPath = this.pluginPath;
		if (this.httpPluginPath.substring(0, 5) === 'https') {
			this.httpPluginPath = ['http', this.httpPluginPath.substring(5)].join('')
		}

		this.Plugins = {};
		this.Proxy = function(folderName) {
			this.width = 0;
			this.height = 0;
			this.outputVersion = 2;
			this.folder = folderName;
		};
		this.Proxy.prototype = {
			parentId: "",
			domId: "",
			isOnPage: function() {
				return ('pluginObj' in this);
			},
			initialized: false,
			digestRead: false,
			needRestart: false,
			readyToLaunch: false,
			addToPage: function(parentId) {
				this.readyToLaunch = false;
				if (this.isOnPage()) {
					this.removeFromPage();
				}
				if ('src' in this) {
					if (this.src.substring(0, 4) !== "http") {
						this.src = WebInstaller.makePagePath(this.src);
					}
					if (this.src.substring(0, 5) === 'https') {
						this.src = ['http', this.src.substring(5)].join('')
					}
				}
				if (parentId === undefined) {
					if (this.parentId !== "") {
						//noinspection AssignmentToFunctionParameterJS
						parentId = this.parentId;
					}
				}
				else {
					this.parentId = parentId;
				}
				this.addDefaultParams();

				if (this.checkBeforeAddingToPage()) {
					var plugin = new WebInstaller.Helper(parentId, this.folder);
					if (this.oldOnInit) {
						this.oldOnInit = null;
					}
					if (this.oldOnStateChange) {
						this.oldOnStateChange = null;
					}
					if (this.oldOnReady) {
						this.oldOnReady = null;
					}
					for (var property in this) {
						if (property in WebInstaller.Proxy.prototype === false) {
							var value = this[property];
							if (property.toLowerCase() === 'oninit') {
								this.oldOnInit = value;
							}
							else if (property.toLowerCase() === 'onstatechange') {
								this.oldOnStateChange = value;
							}
							else if (property.toLowerCase() === 'onready') {
								this.oldOnReady = value;
							}
							else if (typeof value === 'function') {
								plugin.addParam(property, "WebInstaller.Plugins['" + this.folder + "']." + property);
							}
							else if (property !== 'folder') {
								plugin.addParam(property, value);
							}
						}
					}
					plugin.addParam('onInit', "WebInstaller.Plugins['" + this.folder + "'].wrappedOnInit");
					plugin.addParam('onStateChange', "WebInstaller.Plugins['" + this.folder + "'].wrappedOnStateChange");
					plugin.addParam('onReady', "WebInstaller.Plugins['" + this.folder + "'].wrappedOnReady");

					this.pluginObj = plugin.instantiate();
					this.pluginDiv = plugin.container;
					this.domId = plugin.id;
					this.checkAfterAddingToPage();
				}

				return this;
			},
			openFolder: function(folder) {
				if (folder === undefined) {
					this.exec("openFolder");
				} else {
					this.exec("openFolder:" + folder);
				}
				return this;
			},
			getGameList: function(callback) {
				return this.exec("getGameList", callback);
			},
			getGamePath: function(folder, callback) {
				return this.exec("getGamePath:" + folder, callback);
			},
			getHardwareInfo: function(callback) {
				return this.doGetHardwareInfo(callback);
			},
			getDigestInfo: function(callback) {
				var wrappedCallback = function(result) {
					if (typeof result === 'string') {
						result = JSON.parse(result);
						callback(result);
					} else {
						callback.apply(self, arguments);
					}
				};
				if (this.digestRead) {
					this.exec('getDigestInfo', wrappedCallback);
				} else {
					this.gettingDigestInfo = true;
					this.getDigestInfoCallback = wrappedCallback;
				}
                return this;
			},
			getOS: function() {
				return this.exec("getOS");
			},
			getCPUInfo: function() {
				return this.exec("getCPUInfo");
			},
			getRAM: function() {
				return this.exec("getRAM");
			},
			getVideoInfo: function() {
				return this.exec("getVideoInfo");
			},
			kill: function(callback) {
				this.readyToLaunch = false;
				return this.exec("kill", callback);
			},
			setLaunchArgs: function(args) {
				//noinspection AssignmentToFunctionParameterJS
				args = args || "";
				// Change this to launchArgs once 123 is released
				this.launchParams = args;
				this.exec("setLaunchArgs:" + args);
				return this;
			},
			setConfigLaunchArgs: function(args) {
				//noinspection AssignmentToFunctionParameterJS
				args = args || "";
				this.configLaunchArgs = args;
				this.exec("setConfigLaunchArgs:" + args);
				return this;
			},
			changeParam: function(param, value) {
				this[param] = value;
				this.exec("changeParam:" + param + "=" + value);
				return this;
			},
			changeLocalLog: function(value) {
				this.exec("changeLocalLog:" + value);
				return this;
			},
			changeRemoteLog: function(value) {
				this.exec("changeRemoteLog:" + value);
				return this;
			},

			cancel: function() {
				this.readyToLaunch = false;
				return this.temporaryChangeCommand("cancel");
			},
			pause: function() {
				return this.temporaryChangeCommand("pause");
			},
			resume: function() {
				return this.temporaryChangeCommand("resume");
			},

			status: function() {
				return this.changeCommand("status");
			},
			statusOnly: function() {
				this.readyToLaunch = false;
				return this.changeCommand("statusOnly");
			},
			updateOnly: function() {
				this.readyToLaunch = false;
				return this.changeCommand("updateOnly");
			},
			fullScan: function() {
				this.readyToLaunch = false;
				return this.changeCommand("fullScan");
			},
			install: function() {
				return this.changeCommand("install");
			},
			uninstall: function() {
				this.readyToLaunch = false;
				return this.changeCommand("uninstall");
			},
			launch: function() {
				return this.changeCommand("launch");
			},
			configLaunch: function() {
				return this.changeCommand("configLaunch");
			},

			temporaryChangeCommand: function(command) {
				var lastCommand = this.command;
				var ret = this.changeCommand(command);
				this.command = lastCommand;
				return ret;
			},
			executeIfExists: function(command) {
				if (command in this && typeof this[command] === 'function') {
					this[command]();
					return true;
				}
				else {
					return false;
				}
			},
			oldOnInit: null,
			oldOnStateChange: null,
			oldOnReady: null,
			gettingDigestInfo: false,
			onPluginInstallInit: null,
			onPluginInstallComplete: null,
			pluginInstallRunning: false,
			wrappedOnPluginInstallInit: function() {
				if (this.onPluginInstallInit !== null && !this.pluginInstallRunning) {
					this.pluginInstallRunning = true;
					this.doCallback(this.onPluginInstallInit, arguments);
				}
			},
			wrappedOnPluginInstallComplete: function() {
				if (this.onPluginInstallComplete !== null && this.pluginInstallRunning) {
					this.pluginInstallRunning = false;
					this.doCallback(this.onPluginInstallComplete, arguments);
				}
			},
			wrappedOnInit: function() {
				this.initialized = true;
				WebInstaller.hideOverlay();
				this.wrappedOnPluginInstallComplete();
				var state = arguments[0];
				if (state === 'ready' || state === 'readyIdle' || state === 'runUntilLaunch') {
					this.readyToLaunch = true;
				}
				if (arguments[1] === 'integrity=needRestart') {
					this.needRestart = true;
				}
				this.doCallback(this.oldOnInit, arguments);
			},
			wrappedOnStateChange: function() {
				var state = arguments[1];
				this.digestRead = (state != 'init');
				if (this.digestRead && this.gettingDigestInfo) {
					this.gettingDigestInfo = false;
					var self = this;
					setTimeout(function() {
						self.exec('getDigestInfo', self.getDigestInfoCallback);
					}, 1);
				}
				this.doCallback(this.oldOnStateChange, arguments);
			},
			wrappedOnReady: function() {
				this.readyToLaunch = (this.command !== 'uninstall');
				this.doCallback(this.oldOnReady, arguments);
			},
			wrappedExecCallback: [],
			doCallback: function(callback, args) {
				var self = this;
				setTimeout(function() {
					if (typeof(callback) === 'function') {
						callback.apply(self, args);
					} else if (typeof(callback) === 'string') {
						var values = '"' + Array.prototype.join.call(args, '", "') + '"';
						eval([callback, '(', values, ')'].join(''));
					}
				}, 1);
			}
		};

		if (BrowserDetect.OS === 'Mac') {
			this.Proxy.prototype.addDefaultParams = function() {
				if ('library' in this === false && 'macLibraryVerFile' in WebInstaller) {
					if (WebInstaller.macLibraryVerFile.substring(0, 4) !== "http") {
						WebInstaller.macLibraryVerFile = WebInstaller.httpPluginPath + WebInstaller.macLibraryVerFile;
					}
					this.library = WebInstaller.macLibraryVerFile;
				}
				if ('control' in this === false && 'macControlVerFile' in WebInstaller) {
					if (WebInstaller.macControlVerFile.substring(0, 4) !== "http") {
						WebInstaller.macControlVerFile = WebInstaller.httpPluginPath + WebInstaller.macControlVerFile;
					}
					this.control = WebInstaller.macControlVerFile;
				}
			};
		}
		else if (BrowserDetect.OS === 'Windows') {
			this.Proxy.prototype.addDefaultParams = function() {
				if ('dllVersion' in this === false && 'forcedMinimumWindowsDLLVersion' in WebInstaller) {
					this.dllVersion = WebInstaller.forcedMinimumWindowsDLLVersion + ":" + WebInstaller.httpPluginPath + WebInstaller.forcedMinimumWindowsDLL;
				}
				if ('library' in this === false && 'windowsLibraryVerFile' in WebInstaller) {
					if (WebInstaller.windowsLibraryVerFile.substring(0, 4) !== "http") {
						WebInstaller.windowsLibraryVerFile = WebInstaller.httpPluginPath + WebInstaller.windowsLibraryVerFile;
					}
					this.library = WebInstaller.windowsLibraryVerFile;
				}
				if ('control' in this === false && 'windowsControlVerFile' in WebInstaller) {
					if (WebInstaller.windowsControlVerFile.substring(0, 4) !== "http") {
						WebInstaller.windowsControlVerFile = WebInstaller.httpPluginPath + WebInstaller.windowsControlVerFile;
					}
					this.control = WebInstaller.windowsControlVerFile;
				}
			};
		}
		else {
			this.Proxy.prototype.addDefaultParams = function() {
			};
		}

		if (this.directMode) {
			this.external = window.external;
			this.setupDirectMode();
		}
		else {
			this.showOverlay = function() {
				if (('jQuery' in window) === false) {
					this.loadJS('https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');
					var interval = setInterval(
						function() {
							if ('jQuery' in window) {
								clearInterval(interval);
								WebInstaller.loadJS(WebInstaller.jsPath + 'WebInstaller.curtain.js');
							}
						},
						1
					);
				}
				else {
					this.loadJS(this.jsPath + 'WebInstaller.curtain.js');
				}
			};
			this.hideOverlay = function() {};
			this.Helper = function(parentId, folder) {
				//noinspection AssignmentToFunctionParameterJS
				parentId = parentId || "__pluginParent";
				this.parent = document.getElementById(parentId);
				if (!this.parent) {
					this.parent = document.createElement("div");
					this.parent.setAttribute("id", parentId);
					document.getElementsByTagName("body")[0].appendChild(this.parent);
				}
				this.id = "WebInstaller_" + folder.replace(/[^a-zA-Z0-9_]*/g, '');
				this.initArray();
				if (folder.length > 0) {
					this.addParam("folder", folder);
				}
			};

			if (this.activeX) {
				this.Helper.prototype.initArray = function() {
					this.attribs = ["<object id=\"" + this.id + "\" classid=\"CLSID:" + WebInstaller.activeXID + "\" codebase=\"" + WebInstaller.pluginPath + WebInstaller.cab + "#Version=" + WebInstaller.cabVersion + "\""];
					this.params = [];
				};
				this.Helper.prototype.addParam = function(name, value) {
					if (name === "width" || name === "height") {
						this.attribs.push(name + "=\"" + value + "\"");
					}
					else {
						this.params.push("<param name=\"" + name + "\" value=\"" + value + "\">");
					}
				};
				this.Helper.prototype.instantiate = function() {
					this.attribs.push(">");
					this.params.push('<span id="soe-web-installer-fallback" style="display:none;">&nbsp;</span>');
					this.params.push("</object>");
					var obj = this.attribs.join(" ") + this.params.join("\n");
					this.container = document.createElement("div");
					this.container.setAttribute("id", "Div_" + this.id);
					this.container.innerHTML = obj;
					this.parent.appendChild(this.container);
					return document.getElementById(this.id);
				};
				this.pluginDetected = function() {
					//noinspection EmptyCatchBlockJS,UnusedCatchParameterJS
					try {
						var obj = new ActiveXObject(this.activeXObject);
						var valid = (obj !== null);
						delete obj;
						return valid;
					}
					catch(e) {
					}
					return false;
				};
				this.Proxy.prototype.checkBeforeAddingToPage = function() {
					if (navigator.userAgent.indexOf('Win64') >= 0) {
						BrowserDetect.version = '64';
						WebInstaller.showOverlay();
						return false;
					}
					return true;
				};
				this.Proxy.prototype.checkAfterAddingToPage = function() {
					if (!WebInstaller.pluginDetected()) {
						var self = this;
						var checkI = 0, checksMaxSecs = 1.0, checkDelay = 13, checksMax = (checksMaxSecs * 1000 / checkDelay), checkCount = 0;
						checkI = setInterval(function() {
							var fallback = document.getElementById('soe-web-installer-fallback');

							if (self.initialized) {
								clearInterval(checkI);
							} else if (fallback || ++checkCount >= checksMax) {
								clearInterval(checkI);
								self.wrappedOnPluginInstallInit();
								WebInstaller.showOverlay();
							}
						}, checkDelay);
					}
				};
			}
			else {
				if (BrowserDetect.OS === 'Windows') {
					if (BrowserDetect.browser === 'Firefox') {
						this.Helper.prototype.getPluginsPage = function() {
							return "codebase=\"" + WebInstaller.pluginPath + WebInstaller.xpi + "\" pluginspage=\"" + WebInstaller.pluginPath + WebInstaller.setup + "\"";
						};
					}
					else {
						this.Helper.prototype.getPluginsPage = function() {
							return "";
						};
					}
				}
				else if (BrowserDetect.OS === "Mac") {
					this.Helper.prototype.getPluginsPage = function() {
						return "pluginspage=\"" + WebInstaller.pluginPath + WebInstaller.dmg + "\"";
					};
				}
				else {
					this.Helper.prototype.getPluginsPage = function() {
						return "";
					};
				}

				this.Helper.prototype.initArray = function() {
					this.attribs = ["<embed", "type=\"application/vnd.sony.soe\"", "class=\"SOEInstaller\"", this.getPluginsPage()];
					this.addParam("name", this.id);
					this.addParam("id", this.id);
				};
				this.Helper.prototype.addParam = function(name, value) {
					this.attribs.push(name + "=\"" + value + "\"");
				};
				this.Helper.prototype.instantiate = function() {
					this.attribs.push("></embed>");
					var obj = this.attribs.join(" ");
					this.container = document.createElement("div");
					this.container.setAttribute("id", "Div_" + this.id);
					this.container.innerHTML = obj;
					this.parent.appendChild(this.container);
					return document.getElementById(this.id);
				};
				this.refreshPlugins = function() {
					navigator.plugins.refresh();
				};
				this.pluginDetected = function() {
					var daPlugins = ["SOE Web Installer", "Free Realms Installer", "Station Installer"];
					this.refreshPlugins();

					// if plugins array is there and not fake
					if (navigator.plugins && navigator.plugins.length > 0) {
						var pluginsArrayLength = navigator.plugins.length;
						// for each plugin...
						var numFound = 0;
						for (var pluginsArrayCounter = 0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++) {
							// loop through all desired names and check each against the current plugin name
							for (var namesCounter = 0; namesCounter < daPlugins.length; namesCounter++) {
								// if desired plugin name is found in either plugin name or description
								if ((navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
									(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0)) {
									// this name was found
									numFound++;
									return true;
								}
							}
						}
					}

					return false;
				};
				this.Proxy.prototype.checkBeforeAddingToPage = function() {
					if (WebInstaller.pluginDetected()) {
						return true;
					}
					if (BrowserDetect.OS === 'Windows' && BrowserDetect.browser === 'Firefox' && 'createdTrigger' in WebInstaller === false) {
						WebInstaller.createFirefoxInstallTrigger = function() {
							this.createdTrigger = true;
							var settings = {URL: this.pluginPath + this.xpi, IconURL: this.pluginPath + this.xpiIcon};
							if (this.hash !== undefined) {
								settings.Hash = this.hash;
							}
							var settingsObject = {};
							settingsObject[this.name] = settings;
							InstallTrigger.install(settingsObject);
						};
						WebInstaller.createFirefoxInstallTrigger();
					}
					this.wrappedOnPluginInstallInit();
					WebInstaller.showOverlay();
					var checkI = null, checkDelay = 250, self = this;
					checkI = setInterval(function() {
						if (WebInstaller.pluginDetected()) {
							clearInterval(checkI);
							WebInstaller.hideOverlay();
							self.wrappedOnPluginInstallComplete();
							self.addToPage();
						}
					}, checkDelay);
					return false;
				};
				this.Proxy.prototype.checkAfterAddingToPage = function() {
					return true;
				};
			}
			this.Proxy.prototype.removeFromPage = function() {
				if (this.isOnPage()) {
					this.pluginDiv.parentNode.removeChild(this.pluginDiv);
					delete this.pluginObj;
					delete this.pluginDiv;
				}
				return this;
			};
			this.Proxy.prototype.actionVersion = function() {
				if (this.isOnPage()) {
					return this.pluginObj.ActionVersion;
				}
				return undefined;
			};
			this.Proxy.prototype.masterVersion = function() {
				if (this.isOnPage()) {
					return this.pluginObj.MasterVersion;
				}
				return undefined;
			};
			this.Proxy.prototype.changeCommand = function(command) {
				this.command = command;
				if (this.isOnPage()) {
					try {
						this.pluginObj.Do(command);
					}
					catch(c) {
						if ('launchPath' in this === false) {
							this.launchPath = "true";
						}
						var name = this.folder;
						setTimeout(
							function() {
								WebInstaller.instance(name).addToPage();
							},
							1
						);
					}
				}
				return this;
			};
			this.Proxy.prototype.exec = function(command, callback) {
				if (this.isOnPage()) {
					try {
						var ret = this.pluginObj.Do(command);
						if (callback === undefined) {
							return ret;
						} else {
							if (typeof(callback) === 'function') {
								callback.call(this, ret);
							} else {
								window[callback].call(this, ret);
							}
						}
					}
					catch(e) {}
				}
                return this;
			};
			this.Proxy.prototype.doGetHardwareInfo = function(callback) {
				if (this.isOnPage()) {
					var info = {
						'os': this.pluginObj.Do('getOS'),
						'ram': this.pluginObj.Do('getRAM'),
						'cpu': this.pluginObj.Do('getCPUInfo'),
						'video': this.pluginObj.Do('getVideoInfo')
					};
					if (typeof(callback) === 'function') {
						callback.call(this, info);
					} else {
						window[callback].call(this, info);
					}
				}
				return this;
			};
		}
		if (this.fakeMode) {
			this.loadJS(this.jsPath + 'FakeInstaller.js');
		}
		this.init = function() {
		}
	},
	setupDirectMode: function() {
		this.Helper = function(parentId, folder) {
			this.folder = folder;
			this.id = folder;
			WebInstaller.external.createPlugin(folder);
		};
		this.hideOverlay = function() {
		};
		this.Proxy.prototype.actionVersion = function() {
			return WebInstaller.external.pluginVersion;
		};
		this.Proxy.prototype.masterVersion = function() {
			return 0;
		};
		this.Proxy.prototype.exec = function(command, callback) {
			if (this.isOnPage()) {
				if (callback === undefined) {
					return WebInstaller.external.sendJavascriptToPlugin(this.folder, command);
				}
				if (typeof(callback) === 'function') {
					var len = this.wrappedExecCallback.length;
					this.wrappedExecCallback.push(callback);
					callback = "WebInstaller.Plugins['" + this.folder + "'].wrappedExecCallback[" + len + "]";
				}
				WebInstaller.external.sendJavascriptToPlugin(this.folder, command, callback);
			}
		};
		this.Proxy.prototype.wrappedHardwareCallback = function() {
			var info = {
				'os': WebInstaller.external.os,
				'ram': WebInstaller.external.ram,
				'cpu': WebInstaller.external.cpu,
				'video': WebInstaller.external.video
			};
			if (typeof(this.hardwareCallback) === 'function') {
				this.hardwareCallback.call(this, info);
			} else {
				window[this.hardwareCallback].call(this, info);
			}
		};
		this.Proxy.prototype.hardwareCallback = "";
		this.Proxy.prototype.doGetHardwareInfo = function(callback) {
			if (this.isOnPage()) {
				this.hardwareCallback = callback;
				WebInstaller.external.sendJavascriptToPlugin(this.folder, "getHardwareInfo", "WebInstaller.Plugins['" + this.folder + "'].wrappedHardwareCallback");
			}
			return this;
		};
		this.Proxy.prototype.removeFromPage = function() {
			if (this.isOnPage()) {
				WebInstaller.external.destroyPlugin(this.folder);
				delete this.pluginObj;
				delete this.pluginDiv;
			}
			return this;
		};
		this.pluginDetected = function() {
			return true;
		};
		this.Helper.prototype.addParam = function(name, value) {
			if (name === 'src') {
				this.src = value;
			}
			else if (name === 'command') {
				this.command = value;
			}
			else {
				WebInstaller.external.addPluginParam(this.id, name, value);
			}
		};
		this.Helper.prototype.instantiate = function() {
			if ('src' in this) {
				WebInstaller.external.performPluginCommand(this.id, this.src, this.id, this.command);
			}
			this.container = "";
			return this.folder;
		};
		this.Proxy.prototype.changeCommand = function(command) {
			this.command = command;
			if (this.isOnPage()) {
				WebInstaller.external.sendJavascriptToPlugin(this.folder, command);
			}
			return this;
		};
		this.Proxy.prototype.checkBeforeAddingToPage = function() {
			return true;
		};
		this.Proxy.prototype.checkAfterAddingToPage = function() {
			return true;
		};
	}
};
WebInstaller.init();

