var Shell = function(swfobject) {
		
	this.attachGETParamsToFlashVars = false;
	this.swfobject = swfobject;
	this.defaultFocusedSwfobjectId = null;
	this.timeout = 0;
	
	this.embedSWF = function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, dontFit) {
		
		if (this.attachGETParamsToFlashVars) {
			if (!flashvarsObj) 
				flashvarsObj = {};
			var getVars = this.GETParameters();
			for(var getVar in getVars)
				flashvarsObj[getVar] = getVars[getVar];
		}

		this.swfobject.embedSWF(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj , this.onSwfobjectEmbeded);
		this.defaultFocusedSwfobjectId = replaceElemIdStr;
		if (!dontFit)
			swffit.fit(replaceElemIdStr , widthStr , heightStr);
	}
	
	this.onSwfobjectEmbeded = function(e) {
		
		var call = "window.document.getElementById('" + e.id + "').assignId('" + e.id + "')";
		//window.setTimeout(call , window.Shell.timeout);
	}
	
	this.flashPlayerFocusIn = function(e) {
		
		var keynum = Browser.ie ? e.keyCode : e.which;
		if (keynum == Key.CTRL) {
			window.document.getElementById(this.defaultFocusedSwfobjectId).focus();
		}
	}
	
	this.flashPlayerFocusOut = function(id) {
		
		this.defaultFocusedSwfobjectId = id;
		this.swfobject.getObjectById(id).blur();
	}
	
	this.GETParameters = function() {
				  
		var flashVars = {};
		var strHref = window.location.href;
		if (strHref.indexOf("?") > -1) {
			var strQueryString = strHref.substr(strHref.indexOf("?") + 1);
			var aQueryString = strQueryString.split("&");
			for (var i = 0; i < aQueryString.length; i += 1) {
				var aParam = aQueryString[i].split("=");
				flashVars[aParam[0]] = aParam[1];
			}
		}
		return flashVars;
	}
}

var Browser = function() {
	
	this.ie = (navigator.appName == "Microsoft Internet Explorer");
	this.ie6 = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("6.0") != -1);
	this.ie8 = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("8.0") != -1);
}

var Key = function() {
	
	this.CTRL = 17;
}

window.Shell = new Shell(swfobject);

window.Browser = new Browser();
window.Key = new Key();

window.onload = function() {
	
	window.onfocus = function() {
		try {
			var e = {};
			e.keyCode = Key.CTRL;
			e.which = Key.CTRL;
			window.Shell.flashPlayerFocusIn(e);
		} catch (error) {
		}
	}
	window.document.onkeyup = function(e) {
		window.Shell.flashPlayerFocusIn(e);
	};	
}
