/////// ####################################################################################################
/////// WRITTEN BY TECHNICWEB - 11/05
/////// Fully Compliant With:
///////		- Windows XP
///////				- Internet Explorer 6.0
///////				- Mozilla 1.7.12
///////				- Mozilla Firefox 1.0.7
///////				- Netscape 7.2
///////				- Opera 8.5.0
///////		- Windows 2000
///////				- Internet Explorer 5.0
///////				- Netscape 7.2
///////				- Mozilla 1.7.12
///////				- Firefox 1.0.7
///////				- Opera 8.5.0
///////						
///////	Buggy:
///////		- Apple Mac OSX 10
///////				- All browsers
///////
///////	Purpose:
///////		Manager to render a flash movie programatically, in conjunction with the flashdetectionmanager.
/////// #####################################################################################################

function EstateWeb_Objects_FlashObjectManager(o){
	this.Parameters = new EstateWeb_Objects_FlashParameterCollection(); // Store any parameters that need to be added along with the flash movie
	this.DetectionObject = o; //Object required for flash detection and validation
	this.MovieURL = ""; // Relative or absolute URL of the movie to load
	this.MovieWidth = "100%"; // Initial Width of the movie
	this.MovieHeight = "100%"; // Initial Height of the movie
	this.MovieID = ""; // ID of the <object> tag within the DOM
}

EstateWeb_Objects_FlashObjectManager.prototype.Render = __EstateWeb_Objects_FlashObjectManager_Render;

function __EstateWeb_Objects_FlashObjectManager_Render(){
	// Displays the flash movie in the specified html tag
	this.ControlID = arguments[0];
	if ( this.DetectionObject.Detect() ){
		if ( EstateWeb_Objects_FlashObjectManager_GetObject(this.ControlID) ){
			var sParams = ""; // Will hold list of params ready for display
			var sObjectStartTag = ""; // Will hold object tag with attributes ready for display
			for ( var i = 0; i < this.Parameters.Length(); i ++ ){
				var Item = this.Parameters.Items[i];
				sParams += Item.toString();
			}

			sObjectStartTag = "<object type=\"application/x-shockwave-flash\" data=\""+this.MovieURL+"\"  width=\""+this.MovieWidth+"\" height=\""+this.MovieHeight+"\" "+( this.MovieID ? "id=\'"+this.MovieID+"\"" : "")+" VIEWASTEXT=\"true\">";
			EstateWeb_Objects_FlashObjectManager_GetObject(this.ControlID).innerHTML = (sObjectStartTag + sParams + "</object>");
		}
	} 
}

function EstateWeb_Objects_FlashParameterCollection(){
	this.Items = new Array(); // Holds an Array of type EstateWeb_Objects_FlashParameterItem
}

EstateWeb_Objects_FlashParameterCollection.prototype.Add = __EstateWeb_Objects_FlashParameterCollection_Add;
EstateWeb_Objects_FlashParameterCollection.prototype.Length = __EstateWeb_Objects_FlashParameterCollection_Length;

function __EstateWeb_Objects_FlashParameterCollection_Add(){
	this.Items[this.Items.length] = arguments[0];
}

function __EstateWeb_Objects_FlashParameterCollection_Length(){
	return this.Items.length;
}


function EstateWeb_Objects_FlashParameterItem(name,value){
	this.Name = (name ? name : "");
	this.Value = (value ? value : "");
}

EstateWeb_Objects_FlashParameterItem.prototype.toString = __EstateWeb_Objects_FlashParameterItem_toString;

function __EstateWeb_Objects_FlashParameterItem_toString(){
	return "<param name=\'"+this.Name+"\' value=\'"+this.Value+"\'>";
}

function EstateWeb_Objects_FlashObjectManager_GetObject(ID){
	if (document.getElementById){
		return document.getElementById(ID);
	}else{
		return document.all[ID];
	}
}