﻿


/// <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 (!mrm.global.isNamespaceDefined("mrm.lexus.utilities")) mrm.global.createNamespace("mrm.lexus.utilities", "1.0");
	
	
	mrm.lexus.utilities.LoadEnhancer = Object.subClass(
		{
			/*
			 =============================
			 CONSTANTS
			 =============================
			 */
				URL_LOADING_SWF : "/assets/flash/DataLoadingDisplay.swf",
				
				LOADING_SWF_W : "100px",
				LOADING_SWF_H : "100px",
				
				LOADING_SWF_ID_FRAGMENT : "loadingSwf_",
				
				FLASH_PLUGINS_PAGE	: "http://www.macromedia.com/go/getflashplayer",
				FLASH_BASE_URL		: "../../",
				
				
				CLASS_LOADING_DISPLAY : "AUTO-DISABLE-DISPLAY",
				
				LOADING_HTML_FRAGMENT_1 :	"<div class='AUTO-DISABLE-DISPLAY'>" +
												"<div class='AUTO-DISABLE-DISPLAY-LOADING-ICON'>" +
													"<div id='",
				LOADING_HTML_FRAGMENT_2 :			"'></div>" +
												"</div>" +
											"</div>",
			
			
			
			/*
			 =============================
			 CONFIGURATION PROPERTIES (instance configuration)
			 =============================
			 */
			
			
			
			/*
			 =============================
			 CONSTRUCTOR
			 =============================
			 */
				init : function ()
				{
					// Attributes / parameters
					var attr			= this._loadingSwfAttributes = {};
					attr.data			= this.URL_LOADING_SWF;
					attr.width			= this.LOADING_SWF_W;
					attr.height			= this.LOADING_SWF_H;
					attr.pluginspage	= this.FLASH_PLUGINS_PAGE;
					
					var params					= this._loadingSwfParameters = {};
					params.align				= "top";
					params.allowfullscreen		= true;
					params.allowscriptaccess	= "sameDomain";
					params.base					= this.FLASH_BASE_URL;
					params.bgcolor				= "#0000ff";
					params.devicefont			= false;
					params.loop					= false;
					params.menu					= true;
					params.play					= true;
					params.quality				= "best";
					params.salign				= "tl";
					params.scale				= "noscale";
					params.wmode				= "transparent";
					
				},
			
			
			
			/*
			 =============================
			 INTERNAL RUN-TIME PROPERTIES
			 =============================
			 */
				_loadingSwfAttributes		: undefined,
				_loadingSwfParameters		: undefined,
			
			
			/*
			 =============================
			 PUBLIC METHODS
			 =============================
			 */
			
				createLoadingState : function (jQueryObject)
				{
					var target = jQueryObject;
					
					// Unique instance props
					var id		= this.LOADING_SWF_ID_FRAGMENT + Math.round(Math.random() * 1000);
					
					var attr	= this._loadingSwfAttributes;
					attr.id		= id;
					attr.name	= id;
					
					// Create html content
					var htmlContentString = this.LOADING_HTML_FRAGMENT_1 + id + this.LOADING_HTML_FRAGMENT_2;
					
					// Add html content to the page
					jQueryObject.append(htmlContentString);
					
					// Add flash content to page
					swfobject.createSWF(attr, this._loadingSwfParameters, id);
				},
				
				
				
				removeLoadingState : function (jQueryObject)
				{
					var target = jQueryObject;
					
					// Find loading container
					var loadingDisplay = target.find("div." + this.CLASS_LOADING_DISPLAY);
					
					if (loadingDisplay.length > 0)
					{
						// Find flash object
						var flObj = loadingDisplay.find("object");
						
						// Get flash object's id
						var id = flObj.attr("id");
						
						// Remove flash object
						swfobject.removeSWF(id);
					}
					
					// Remove loading container
					loadingDisplay.remove();
				}
				
			
			/*
			 =============================
			 INTERNAL METHODS
			 =============================
			 */
				/*
				 =============================
				 UTILITIES
				 =============================
				 */
			
			
			
				/*
				 =============================
				 SETUP
				 =============================
				 */
			
			
			
				/*
				 =============================
				 DISPLAY CREATION
				 =============================
				 */
			
			
			
				/*
				 =============================
				 DISPLAY CONTROL
				 =============================
				 */
			
			
			
				/*
				 =============================
				 INTERNAL EVENT HANDLERS
				 =============================
				 */
		}
	);
