
<!--

/*
 *	izk_mp
 *
 *		@author		Isaac Rivera
 *		@version	1.0
 *		@date		09/30/2005
 *
 *		A DalaiLlama wrapper/decorator singleton class adds support for a <DIV> 
 *		embedded player to "float" above other browser content such as a flash 
 *		application. Provides a unified and consistent interface to access  
 *		DalaiLlama.
 *	
 *	CONSTRUCTOR
 *
 *		Returns a izk_mp instance wrapping the DalaiLlama  object passed as 
 *		argument. This izk_mp object should be a singleton that masks the  
 *		izk_mp Class constructor.
 *
 *		@param	dalaiObject: an instance of DalaiLlama
 */
this.izk_mp = function(mpObject) {
	//	save a reference to the DalaiLlama object:
	this.player = window.mp;
	//	save a reference to the <DIV> which 
	//	contains the DalaiLlama object:
	this.layer = window.document.getElementById("__IZK_MP_LAYER__");
	//	save a reference to the syle of the layer:
	this.style = this.layer.style;
	//	save a refrence to the iframe of the player:
	this.iframe = window.document.getElementById( "_AVID_IFRAME_" );
	//	curtain properties:
	if(!(this.curtain = window.document.getElementById("IZKcurtainDiv"))) this.curtain = false;
	this.curtainFrame = (this.curtain) ? window.document.getElementById("ac_frame") : null;
	this.curtainFrameStyle = (this.curtain) ? this.curtainFrame.style : null;
	
	this.isMac = (window.navigator.userAgent.indexOf("Macintosh") > -1) ? true : false;
	
	this.browser = (window.navigator.userAgent.indexOf("Safari") > -1) ? "safari" : 
						(window.navigator.userAgent.indexOf("Netscape") > -1) ? "netscape" :
						(window.navigator.userAgent.indexOf("Firefox") > -1) ? "firefox" : "ie";
						
	this.invisible_constant = "-10000px";
	this.currentLeft = this.style.left;
};

/*
 *	METHOD	setRect
 *
 *		Sets the area and top-left coordinates of  the <DIV> containing DalaiLlama
 *
 *		@param	top:	CSS string indicating distance in pixels from the top of the  
 *			document
 *		@param	left: CSS string indicating distance in pixels from the left of the 
 *			document
 *		@param	width: CSS string indicating <DIV> container's width in pixels
 *		@param	height: CSS string indicating <DIV> container's height in pixels
 */
this.izk_mp.prototype.setRect = function(left, top, width, height) {
	this.setPosition(left, top);
	this.setSize(width, height);
};

/*
 *	METHOD	setPosition
 *
 *		Sets the top-left coordinates of the <DIV> containing DalaiLlama
 *
 *		@param	top: CSS string indicating distance in pixels from the top of the  
 *			document
 *		@param	left: CSS string indicating distance in pixels from the left of the
 *			document
 */
this.izk_mp.prototype.setPosition = function(left, top) {
	this.setLeft(left);
	this.setTop(top);
};

/*
 *	METHOD	setLeft
 *
 *		Sets the left coordinate of the <DIV> containing DalaiLlama
 *
 *		@param	left: CSS string indicating distance in pixels from the left of the
 *			document
 */
this.izk_mp.prototype.setLeft = function(left) {
	this.style.left = left;
	if(left != this.invisible_constant)
		this.currentLeft = left;
};

/*
 *	METHOD	setTop
 *
 *		Sets the top coordinate of the <DIV> containing DalaiLlama
 *
 *		@param	top: CSS string indicating distance in pixels from the top of the
 *			document
 */
this.izk_mp.prototype.setTop = function(top) {
	this.style.top = top;
};

/*
 *	METHOD	setSize
 *
 *		Sets the area of the <DIV> containing DalaiLlama
 *
 *		@param	width: CSS string indicating <DIV> container's width in pixels
 *		@param	height: CSS string indicating <DIV> container's height in pixels
 */
this.izk_mp.prototype.setSize = function(width, height) {
	this.setWidth(width);
	this.setHeight(height);
};

/*
 *	METHOD	setWidth
 *
 *		Sets the width of the <DIV> containing DalaiLlama
 *
 *		@param	width: CSS string indicating <DIV> container's width in pixels
 */
this.izk_mp.prototype.setWidth = function(width) {
	this.style.width = width;
};

/*
 *	METHOD	setHeight
 *
 *		Sets the height of the <DIV> containing DalaiLlama
 *
 *		@param	width: CSS string indicating <DIV> container's height in pixels
 */
this.izk_mp.prototype.setHeight = function(height) {
	this.style.height = height;
};

/*
 *	METHOD	play
 */
this.izk_mp.prototype.play = function(widget, media, captions, options) {
	this.player.play(widget, media, captions, options);
	this.show();
};

/*
 *	METHOD	playlist
 */
this.izk_mp.prototype.playlist = function(widget, pls, type, start, startid) {
	this.player.playlist(widget, pls, type, start, startid);
	this.show();
};

/*
 *	METHOD	show
 *
 *		makes the <DIV> element visible
 */
this.izk_mp.prototype.show = function() {
	//this.debugTrace();
	if(!this.isVisible()) {
		this.setLeft(this.currentLeft);
	}
	if(this.curtain) {
		this.curtainFrameStyle.display = "none";
		this.curtainFrame.src = "";
		window.currentItem = null;
		window.newPlayerInstance = true;
		window.g_MotifId = null;
		window.g_expandOnLoad = false;
	}
};

/*
 *	METHOD	hide
 *
 *		hides the <DIV> element
 */
this.izk_mp.prototype.hide = function() {
	//this.debugTrace();
	if(this.isVisible()) {
		if(this.isMac && this.browser == "safari") {
			this.iframe.contentDocument.open();
			this.iframe.contentDocument.write("");
			this.iframe.contentDocument.close();
		} else {
			this.iframe.src = "";
		}
		this.setLeft(this.invisible_constant);
		if(this.curtain) {
			this.curtainFrameStyle.display = "none";
			this.curtainFrame.src = "";
			window.currentItem = null;
			window.newPlayerInstance = true;
			window.g_MotifId = null;
			window.g_expandOnLoad = false;
		}
	}
};

/*
 *	METHOD	isVisible
 *	
 *		@returns	Boolean indicating whether the <DIV> element is visible or not
 */
this.izk_mp.prototype.isVisible = function() {
	if(this.style.left == this.invisible_constant) {
		return false;
	}
	return true;
};

/*
 *	Make singleton instance:
 */

this.izk_mp = new this.izk_mp();

//-->
