function Client(params) 
{
	this.__init__ = function(params)
	{
		var def = function (params, name, defaultValue)
		{
			if (typeof(params[name]) == "undefined")
				return defaultValue;
			else
				return params[name];
		}
		
		this.id = def(params, Client.ID, "Main");
		this.src = def(params, Client.SRC, "Main");		
		this.installSrc = def(params, Client.PLAYER_PRODUCT_INSTALL_SRC, "Main");	
		this.bgColor = def(params, Client.BG_COLOR, "#FFFFFF");
		this.wMode = def(params, Client.WMODE, "window");  
		this.portalName = def(params, Client.PORTAL_NAME, "");
		this.gMapsAPIKey = def(params, Client.GOOGLE_MAPS_API_KEY, "");
		
		this._windows = {};		
	}	
	
	this.embed = function()
	{					
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasRequestedVersion = DetectFlashVer(10, 0, 0);
		if (hasProductInstall && (!hasRequestedVersion)) 
		{
			var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
			var MMredirectURL = window.location;
		   	document.title = document.title.slice(0, 47) + " - Flash Player Installation"; 
		   	var MMdoctitle = document.title;		
			AC_FL_RunContent(
				"src", this.installSrc, 
				"id", this.id, 
				"name", this.id,
				"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
				"width", "100%", 
				"height", "100%", 
				"align", "middle", 
				"quality", "high", 
				"bgcolor", this.bgColor,
				"wmode", this.wMode,					
				"allowScriptAccess", "sameDomain", 
				"type", "application/x-shockwave-flash", 
				"pluginspage", "http://www.adobe.com/go/getflashplayer");
		} 
		else if (hasRequestedVersion) 
		{
			var flashVarsDict = {};			
			flashVarsDict["key"] = this.gMapsAPIKey;			
			var flashVarsArray = [];
			for (var k in flashVarsDict)
				flashVarsArray.push(escape(k) + "=" + escape(flashVarsDict[k]));
			var flashVars = flashVarsArray.join("&");			
		
			AC_FL_RunContent(
				"src", this.src, 
				"id", this.id, 
				"name", this.id,
				"FlashVars", flashVars, 
				"width", "100%", 
				"height", "100%", 
				"align", "middle", 
				"quality", "high", 
				"bgcolor", this.bgColor,
				"wmode", this.wMode,						
				"allowScriptAccess", "sameDomain", 
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
			);
		} 
		else 
		{  
		   	document.write('This content requires the Adobe Flash Player <a href=http://www.adobe.com/go/getflash/>Get Flash</a>');
		}
	}		
	
	this.openWindow = function(name, url)
	{
		this.closeWindow(name);
		this._windows[name] =  window.open(url, "_blank");  
	}
	
	this.closeWindow = function(name)
	{
		if (this._windows[name] != undefined)
		{
			if (!this.getWindowClosed(name))
				this._windows[name].close();
			this._windows[name] = undefined;
		}
	}
 
	this.getWindowClosed = function(name)
	{
		if (this._windows[name] != undefined)
			return this._windows[name].closed;
		else
			return true;	
	}	
	
	this.getWindowURL = function(name)
	{
		try
		{
			return this._windows[name].location.href;
		}
		catch(e) { }
		return null;
	}
	 
	this.__init__(params);
}
 
 
 
Client.ID = "id";
 
Client.SRC = "src"
 
Client.PLAYER_PRODUCT_INSTALL_SRC = "installSrc";
 
Client.PORTAL_NAME = "portalName";
 
Client.GOOGLE_MAPS_API_KEY = "gmapsAPIKey";
 
Client.BG_COLOR = "bgColor";
 
Client.WMODE = "wMode";
 
Client._instance = null;
 
Client.embed = function(params)
{
	Client._instance = new Client(params);
	Client._instance.embed();
}
 
Client.getInstance = function()
{
	return Client._instance;
} 