


/// <reference path="../jQuery/1.3.2/jquery-1.3.2-vsdoc.js" />


/*
 *****************************************************************
 * CLASS TEMPLATE
 *****************************************************************
 *
 * Class description :
 *
 * Author : 
 */


	//Check that namespace into which the Class definition will be creates has been defined & if not then create
	if (!manheim.global.isNamespaceDefined("manheim.portfolio.common.display")) manheim.global.createNamespace("manheim.portfolio.common.display", "1.0");
	
	
	manheim.portfolio.common.display.SwfHost = Object.subClass(
		{
			/*
			 =============================
			 CONSTANTS
			 =============================
			 */
				DEFAULT_TARGET_FLASH_VERSION : "9.0.48",
				
				DEFAULT_REPLACEMENT_ID_FRAGMENT : "swfObjectInstanceID",
				
				DEFAULT_ALTERNATIVE_CONTENT :	"<div class='flash-alternative-content-container'>" + 
												"<h6>System requirements:</h6>" +
												"<p>To view this content it is necessary to have Flash Player version <strong>9.0.45</strong> or greater installed on your computer. Please ensure that you have the latest version of the Flash Player installed.</p>" + 
												"<p><a href='http://get.adobe.com/flashplayer/' target='_blank'>Click here</a> to download the latest version of the Flash Player from <a href='http://www.adobe.com' target='_blank'>www.adobe.com</a></p>" +
												"</div>"
												,
				
				
				FLASH_VAR_HOST_CLASS_INSTANCE : "hostJSClassInstanceID",
				
				
				
				
			/*
			 =============================
			 CONFIGURATION PROPERTIES (instance configuration)
			 =============================
			 */
			
			
			
			/*
			 =============================
			 CONSTRUCTOR
			 =============================
			 */
				init : function (classInstanceID, replacementTargetParentID, replacementTargetID, swfInstanceID, targetFlashVersion, swfAttributesObject, swfParametersObject, swfFlashVars, deferSwfSetup)
				{
					// Save class instance
					if (classInstanceID) this._classInstanceID	= classInstanceID;
					
					// Save replacement target parent id
					this._replacementTargetParentID	= replacementTargetParentID;
					
					// Save replacement target id (auto generate if !supplied)
					if (replacementTargetID) this._replacementTargetID = replacementTargetID;
					else
					{
						this._replacementTargetID = ((classInstanceID) ? classInstanceID : "") + this.DEFAULT_REPLACEMENT_ID_FRAGMENT;
					}
					
					// Save swf instance id 
					this._swfInstanceID = swfInstanceID;
					
					// Save target id
					if (targetFlashVersion) this._targetFlashVersion = targetFlashVersion;
					
					// Save attributes and parameters objects
					this._swfAttributesObject = swfAttributesObject;
					this._swfParametersObject = swfParametersObject;
					
					// Save any flash vars
					if (swfFlashVars) this._swfFlashVars = swfFlashVars;
					
					// Create swf
					if (!deferSwfSetup) this._setupSwfObject();
				},
			
			
			
			/*
			 =============================
			 INTERNAL RUN-TIME PROPERTIES
			 =============================
			 */
				_classInstanceID			: undefined,
				_replacementTargetParentID	: undefined,
				_replacementTargetID		: undefined,
				
				_swfInstanceID				: undefined,
				
				_targetFlashVersion			: undefined,
				_swfAttributesObject		: undefined,
				_swfParametersObject		: undefined,
				_swfFlashVars				: undefined,
				
				//reference to generated swf object for easy referencing
				_swfObject					: undefined,
			
			
			
			/*
			 =============================
			 PUBLIC METHODS
			 =============================
			 */
				 /*
				 -----------------------------
				 UTILITIES -- not currently in use - enable as required
				 -----------------------------
				 */
					/*
					alertFlashPlayerVersion : function ()
					{
						var playerVersion = swfobject.getFlashPlayerVersion();
						alert("manheim.portfolio.common.display.SwfExternalDataHost.alertFlashPlayerVersion() \nInstalled Flash player : \nmajorVersion = " + playerVersion.major + " // minorVersion = " + playerVersion.minor + " // releaseVersion = " + playerVersion.release);
					},
					*/
					
					isSwfObjectInstanceDefined : function ()
					{
						return (this.getSwfObject()) ? true : false;
					},
					
					
					getSwfObject : function ()
					{
						if (this._swfObject) return this._swfObject;
					},
					
			
			
			/*
			 =============================
			 INTERNAL METHODS
			 =============================
			 */
				/*
				 -----------------------------
				 SWF OBJECT CREATION
				 -----------------------------
				 */
					_setupSwfObject : function ()
					{
						//alert("manheim.portfolio.common.display.SwfExternalDataHost : _setupSwfObject");
						
						var version = (this._targetFlashVersion) ? this._targetFlashVersion : this.DEFAULT_TARGET_FLASH_VERSION;
						
						if (swfobject.hasFlashPlayerVersion(version))
						{
							this._generateSwfObject();
						}
						else 
						{
							// User doesn't have correct flash version therefore display alternative content
							var parent = $("#" + this._replacementTargetParentID);
							var target = parent.find("#" + this._replacementTargetID);
							
							// If target exists the remove it
							if (target.length > 0) target.remove();
							
							// Add alternative content to parent
							parent.append(this.DEFAULT_ALTERNATIVE_CONTENT);
						}
					},
					
					
					_generateSwfObject : function ()
					{
						// Test if targetID element exists in parent
						// If not then create an empty replacement target within the target Parent with the correct target ID
						
						var parent = "#" + this._replacementTargetParentID;
						var target = parent + " #" + this._replacementTargetID;
						
						if ($(target).length == 0)
						{
							$(parent).append("<div id='" + this._replacementTargetID + "'></div>")
						}
						
						// Add class namespace property to the swf object via flashvars property
						// This allows the flash object to target any ExternalInterface method calls to the correct Class instance
						
						// Generate flash vars 
						// Including (if supplied) the default class namespace property
						//
						var vars = "";
						if (this._classInstanceID) vars = this.FLASH_VAR_HOST_CLASS_INSTANCE + "=" + this._classInstanceID;
						if (this._swfFlashVars) vars += this._swfFlashVars;
						
						if (vars != "")
							this._swfParametersObject.flashvars = vars;
						
						// Create and store object
						this._swfObject = swfobject.createSWF(this._swfAttributesObject, this._swfParametersObject, this._replacementTargetID);
					},
			
					
					
					_removeSwfObject : function ()
					{
						swfobject.removeSWF(this._swfInstanceID);
						
						// Clear local reference 
						this._swfObject = undefined;
					}
					
			
				/*
				 =============================
				 SETUP
				 =============================
				 */
			
			
			
				/*
				 =============================
				 DISPLAY CREATION
				 =============================
				 */
			
			
			
				/*
				 =============================
				 DISPLAY CONTROL
				 =============================
				 */
			
			
			
				/*
				 =============================
				 INTERNAL EVENT HANDLERS
				 =============================
				 */
		}
	);




/*
	attributes.data			= ".swf";
	attributes.id			= "testFlashObject_1";
	attributes.name			= "testFlashObject_1";
	attributes.width		= "100%";
	attributes.height		= "100%";
	attributes.pluginspage	= "http://www.macromedia.com/go/getflashplayer";

	
	params.align				= "top";
	params.allowfullscreen		= true;
	params.allowscriptaccess	= "sameDomain";
	params.bgcolor				= "#0000ff";
	params.devicefont			= false;
	params.loop					= true;
	params.menu					= true;
	params.play					= true;
	params.quality				= "best";
	params.salign				= "tl";
	params.scale				= "default";
	params.wmode				= "transparent";
	
	
	************************************************************************************
	ATTRIBUTES
	************************************************************************************
	
		data		: swf url
		id			: NOTE: when undefined, the object element automatically inherits the id from the alternative content container element
		name		:
		width		:
		height		:
		pluginspage	: "http://www.macromedia.com/go/getflashplayer";
		
		styleclass	: (used instead of class, because this is also an ECMA4 reserved keyword) 
		align		: 
	
	************************************************************************************
	************************************************************************************
	
	************************************************************************************
	PARAMETERS
	************************************************************************************
	
		play				: true (d) || false
		loop				: true (d) || false
		menu				: true (d) || false
		quality				: low || autolow || autohigh || medium || high || best
		scale				: default (showall) || noorder || exactfit || noscale
		align**				: l || t || r || b										[ ** NOT SURE IF THIS PROPERTY IS SUPPORTED BY swfObject AS NOT MENTIONED IN DOCUMENTATION ]
		salign				: l || t || r || b || tl || tr || bl || br
		wmode				: window || opaque || transparent (may slow animation performance)
		bgcolor				: [hexadecimal RGB value]
		base				: or [base directory] or [URL]. Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files
		swliveconnect
		flashvars
		devicefont			: DON'T USE as all fonts should be internally defined -- NEVER RELY ON USER FONTS!!!
		allowscriptaccess	: never || sameDomain || always
		seamlesstabbing		: true (d) || false
		allowfullscreen		: true || false (d)
		allownetworking		: all (d) || internal || none							[see http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001079.html]

	************************************************************************************
	************************************************************************************
	
	
	************************************************************************************
	FLASH PLAYER VERSIONS
	************************************************************************************
	
		see ( http://www.flexdeveloper.eu/forums/actionscript-3-0/flash-player-version-history/ )
		 
		- 10.0.12.36	- 15th October 2008 (Astro release - Adaptive streaming & Vector support)(Full release notes)
		- 9.0.151.0		- 6th November 2008 (Security update for those unable to upgrade to 10 - users of Microsoft Windows 98, Windows ME, Mac OS X 10.1 to 10.3 and Red Hat Enterprise Linux 3 and 4)
		- 9.0.124.0		- 9th April 2008
		- 9.0.115.0		- 3rd December 2007 (Movie-star release - H.264 support)
		- 9.0.48.0		- 22nd September 2007
		- 9.0.47.0		- 10th July 2007
		- 9.0.45.0		- 12th April 2007
		- 9.0.28.0		- 15th November 2006
		- 9.0.20.0		- 10th August 2006
		- 9.0.18.0		- 30th June 2006
		- 9.0.16.0		- 27th June 2006

		CURRENTLY TESTING FOR : [ 9.0.48.0 ]
	
	************************************************************************************
	************************************************************************************
	
*/






/*
 **************
 * IMPORTANT :: All runtime instance declarations MUST be bound to document 'js-class-setup' event
 **************
 */

$(document).bind("js-class-setup", function() 
{
	// Setup runtime namespace if doesn't exist
	if (!manheim.global.isNamespaceDefined("manheim.portfolio.runtime.display.views")) manheim.global.createNamespace("manheim.portfolio.runtime.display.views", "1.0");
	
	// If it is the homepage
	if ($("body > div.main-container > div.home-container:first").length > 0)
	{
		/*
		 -------------------------------------
		 Generate flash object parameters
		 -------------------------------------
		*/
			var targetIdParent	= "flash-replace-id-homepage-parent";
			var targetId		= "flash-replace-id-homepage";
			
			var targetFlashVersion		= "9.0.48";
			//var targetFlashVersion		= "100";
			
			var swfInstanceID = "swfHomepageFeature"
			
			var w = "922px;"
			var h = "250px;"
			
			var swfAttributes			= {};
			swfAttributes.data			= "/assets/flash/HomepageFeature.swf";
			swfAttributes.id			= swfInstanceID;
			swfAttributes.name			= swfInstanceID;
			swfAttributes.width			= w;
			swfAttributes.height		= h;
			swfAttributes.pluginspage	= "http://www.macromedia.com/go/getflashplayer";
			
			var swfParameters				= {};
			swfParameters.align				= "top";
			swfParameters.allowfullscreen	= false;
			swfParameters.allowscriptaccess	= "sameDomain";
			swfParameters.base				= "../../";/*"http://www.lexus.ucl.dev.portfolio-europe.co.uk";*/
			swfParameters.bgcolor			= "#ffffff";
			swfParameters.devicefont		= false;
			swfParameters.loop				= false;
			swfParameters.menu				= false;
			swfParameters.play				= true;
			swfParameters.quality			= "best";
			swfParameters.salign			= "tl";
			swfParameters.scale				= "noscale";
			swfParameters.wmode				= "opaque"; //transparent


	


		// Create class instance and hence the flash object -- //classInstanceID, replacementTargetParentID, replacementTargetID, swfInstanceID, targetFlashVersion, swfAttributesObject, swfParametersObject, swfFlashVars
		manheim.portfolio.runtime.display.views.homepageFeature = new manheim.portfolio.common.display.SwfHost("manheim.portfolio.runtime.display.views.homepageFeature",
																										 targetIdParent,
																										 targetId,
																										 swfInstanceID,
																										 targetFlashVersion,
																										 swfAttributes,
																										 swfParameters,
																										 undefined,
																										 false
																										);
		
	}
	

});




