function MPlayer(o){
	/////////////////////////////////////////////////////////////
	// **** Initialize ****
	var version				= "2.0",
		template			= (o["template"]) ? o["template"] : "",
		name				= (o["name"])     ? o["name"]     : "mediaPlayer",
		width				= (o["width"])    ? o["width"]    : 100,
		height				= (o["height"])   ? o["height"]   : 100,
		templateUrl			= "",
		wfUrl				= "",
		playFrameUrl		= "/shared/media/mplayer.jsp",
		flvPlayerFrameUrl	= "/shared/media/mp_flvPlayer.jsp",
		isSafari			= ( navigator.userAgent.toLowerCase() ).indexOf("safari") > -1,
		pagePath			= "";

	/////////////////////////////////////////////////////////////
	// **** Public Params ****
	this.config           = getParamObject();
	this.playerObj        = null;
	this.isAudOrVid       = null;
	this.playerFrame      = null;
	this.workflowFrame    = null;
	this.adFrame          = null;
	this.playerFrameUrl   = null;
	this.loginRequired    = null;
	this.workflowFrameUrl = null;
	this.isActiveXEnabled = null;
	this.customCtrls      = true;
	this.isNested         = ( this.config != null && this.config["_mp"] ) ? true : false;
	if(this.isNested){ window.top["mplayerObj"] = this; }
	if(this.isNested){
		this.isActiveXEnabled = MPlayer.checkActiveX();
		this.playerFrame      = getDisplayFrame("p");
		this.workflowFrame    = getDisplayFrame("w");
		if (!!this.config.adType && this.config.adType=='flash'){
			this.adFrame = getDisplayFrame('companionAdContainer');
		}
	}
	this.isFlv           = null;

	/////////////////////////////////////////////////////////////
	// **** Public Methods ****
	this.getVersion        = function(){ return version; };
	this.setWorkflow       = function(url){ wfUrl = url; };
	this.setPlayerFrameUrl = function(url){ playFrameUrl = url; };
	this.setReferer        = function(url){ pagePath = url; };
	this.preLaunch         = function(o){ return true; };
	this.postLaunch        = function(o){};
	this.initPlayer        = function(o){};
	this.setTemplate          = function(t){ template = t; };
	this.setWidth             = function(w){ width = w; };
	this.setHeight            = function(h){ height = h; };
	//---------- play
	this.play = function(o){
		var mpObj;

		if((!!o.host && o.host == 'external') || window==window.top || !window.top.mplayerObj) { 
            mpObj=this; 
        } else if (!!window.top.mplayerObj) {
            mpObj=window.top.mplayerObj;
        }

		if(this.isNested && mpObj.preLaunch(o) ) { 
            mpObj.initPlayer(o); 
        } else if( mpObj.preLaunch(o) ) { 
            launch(o); 
        }
		mpObj.postLaunch(o);
	};
	//---------- runGenericRules
	this.runGenericRules = function(o){		

		var stream_type = ( o.type ) ? o.type.split("_") : ["v", "free"],
		    av, q,
            mediaId,
            catCode,
            nsId,
            startOffset,
            endOffset,
            debugParam,
            mtype,
            pUrl, 
            murl,
            playerURLConfig;

			
        if( this.config.isFreeWheelSite && !o.isFreeWheelSite && !!this.adFrame ) {
               this.adFrame.hide();
        }

        this.isAudOrVid = stream_type[0];
		this.loginRequired = (stream_type[1] != "free");
        this.config.flv    = o.flv;
        this.config.isFreeWheelSite = o.isFreeWheelSite;
        this.config.fwCompanionSize = o.fwCompanionSize;

		if( o.adUrl ) { this.config.adUrl = o.adUrl; }

		av = "&av=" + this.isAudOrVid;
		q = (wfUrl.indexOf("?")>-1) ? "&" : "?";

        if( this.config.isFreeWheelSite ) {
            if ( !this.adFrame ) {
                this.adFrame = getFreeWheelAdContainer("companionAdContainer", MPlayer.BANNER_VIEW.w, MPlayer.BANNER_VIEW.h);
            } else {
                this.adFrame.moveTo(MPlayer.BANNER_VIEW.x, MPlayer.BANNER_VIEW.y);
            }
        }

		if(this.loginRequired){

			mediaId     = o.f_id || o.w_id || o.r_id || "NULL";
            catCode     = ( o.catCode )   ? "&catCode=" + o.catCode          : "";
            nsId        = ( o.nsId )      ? "&namespaceId=" + o.nsId         : "";
            startOffset = ( o.start )     ? "&startOffsetSeconds=" + o.start : "";
            endOffset   = ( o.end )       ? "&endTimeSeconds=" + o.end       : "";
            debugParam  = ( mediaId==="NULL" ) ? "&refPath=" + pagePath              : "";

			this.workflowFrameUrl = wfUrl + q + "mediaId=" + unescape( mediaId ) + startOffset + endOffset + nsId + catCode + av + debugParam;

		} else {

			mediaId     = o.f_id || o.w_id || o.r_id || "NULL";
			mtype = "";
            pUrl  = (!!o.flv || (!!this.config.adType && this.config.adType=='flash')) ? flvPlayerFrameUrl : playFrameUrl;
            murl  = (o[mtype="w"]) ? unescape(o.w) : (o[mtype="r"]) ? unescape(o.r) : (o[mtype="flv"]) ? unescape(o.flv) : "NULL";

            playerURLConfig = {
                "mediaId" : mediaId,
                "mtype"   : mtype,
                "pUrl"    : pUrl,
                "murl"    : murl,
                "av"      : av
            };
            
            if( o.flv || this.config.flv ) {
                playerURLConfig.w = MPlayer.PLAYER_VIEW.w;
                playerURLConfig.h = MPlayer.PLAYER_VIEW.h;
                playerURLConfig.isFreeWheelSite = !!this.config.isFreeWheelSite;
                playerURLConfig.fwCompanionSize = this.config.fwCompanionSize;

                try{ mp_swf.setControls(false); } catch( e ) {} // turn off flash custom controls
            } else if( !!this.isActiveXEnabled ) {
                try{ mp_swf.setControls(true); } catch( e ) {} // turn on flash custom controls for IE
            }

            setPlayerFrameUrl.call( this, playerURLConfig);

		}
		if (mtype=='w' && !!this.isActiveXEnabled){ try{ mp_swf.setControls(true); }catch(e){} } // display custom controls for wmv 
		else { try{ mp_swf.setControls(false); }catch(e){} } // hide custom controls for flv
		try{ mp_swf.setVariable("mplayer_killResize", ( this.isAudOrVid=='a' ? 'yes' : 'no' ) ); }catch(e){} // set flash skin vars
		if (!!o.streamType){
			bam.tracking.track({
				async_media:{
					mediaID: (o["id"]) ? o.id : (o["w_id"]) ? o.w_id : "Not Available",
					playerType: (!!o.flv) ? "Flash" : "Windows Media Player",
					playerContext:"Media Player",
					contextVersion:"2.1",
					streamType:o.streamType,
					bitRate:"Not Available"
				}
			});
		}

	};

	//---------- setDisplay
	this.setDisplay = function(){
		if( !!this.playerObj ) { this.playerObj.kill(); }
		if( !!this.adFrame && !!this.adFrame.init ) {
			var bannerView = MPlayer.BANNER_VIEW || {w:728, h:90, x:544, y:88};
			this.adFrame.init(bannerView,unescape(this.config.adBannerUrl));
		}
		if(this.loginRequired){
			this.playerFrame.hide();
			try{
				if(isSafari && mp_swf){
					//This is a hack to fix an issue in Google Chrome, where the 
					// height is being set to 47px on the embed element.  If something 
					//breaks elsewhere, uncomment below.
					//mp_swf.height= MPlayer.WORKFLOW_VIEW.x + "px";
					mp_swf.height= MPlayer.WORKFLOW_VIEW.h;
				}
			}catch(e){}
			this.workflowFrame.init(MPlayer.WORKFLOW_VIEW, this.workflowFrameUrl);
		}
		else{
			var aView;
			this.workflowFrame.hide();
			if( !!this.config.resize ) {
				var size = this.config.resize.split("x");
				try{
					if(isSafari && mp_swf){
						mp_swf.height="600px";
					}
				}catch(e){}
				aView = {w:size[0], h:size[1], x:null, y:null};
			}
			else{ aView = MPlayer.PLAYER_VIEW; }
			
			this.playerFrame.init(aView, this.playerFrameUrl);

		}
	};

	//---------- postWorkflow
	this.postWorkflow = function(o){
		this.workflowFrame.hide();

		var mtype = "",
			pUrl  = (!!o.flv || this.config.flv || (!!this.config.adType && this.config.adType==='flash' && !!this.config.adUrl && this.config.adUrl!=='')) ? flvPlayerFrameUrl : playFrameUrl,
            murl,
            av,
            mediaId,
            playerURLConfig;

        mediaId = this.config.f_id || this.config.w_id || this.config.r_id || "NULL";
        mtype = o.type;
        murl  = o.url;
        av    = "&av=" + this.isAudOrVid;

        playerURLConfig = {
            "mediaId" : mediaId,
            "mtype" : mtype,
            "pUrl"  : pUrl,
            "murl"  : murl,
            "av"    : av
        };

        if( o.flv || this.config.flv ) {
            playerURLConfig.w = MPlayer.PLAYER_VIEW.w;
            playerURLConfig.h = MPlayer.PLAYER_VIEW.h;
            playerURLConfig.isFreeWheelSite = !!this.config.isFreeWheelSite;
            playerURLConfig.fwCompanionSize = this.config.fwCompanionSize;

            try{ mp_swf.setControls(false); } catch( e ) {} // turn off flash custom controls
        } else if( !!this.isActiveXEnabled ) {
            try{ mp_swf.setControls(true); } catch( e ) {} // turn on flash custom controls for IE
        }

		setPlayerFrameUrl.call( this, playerURLConfig );
        
		this.playerFrame.init(MPlayer.PLAYER_VIEW, this.playerFrameUrl);
	};

	/////////////////////////////////////////////////////////////
	// **** Private Methods ****
	function launch(o){
		var _left, _top;
		//var playedFromUrl = window.location.pathname;
		//o.refPath = playedFromUrl; // referer url
		buildUrl(o);
		if( width > screen.availWidth-12 ) width = screen.availWidth - 12;
		if( height > screen.availHeight-48 ) height = screen.availHeight - 48;
		_left = (screen.availWidth - width - 12) / 2;
		_top = (screen.availHeight - height - 48) / 2;
		void( window.open(templateUrl, name, "width=" + width + ",height=" + height + ",left=" + _left + ",top=" + _top) );
	}
	//---------- buildUrl
	function buildUrl(o){
		var q = "", d = "";
		o["_mp"] = "1"; //used to check if in player
		for(var key in o){
			d = (q=="") ? "" : "&";
			q += d + key + "=" + escape(o[key]);
		}
		if(template.indexOf("?")>-1) templateUrl = template + "&" + q;
		else templateUrl = template + "?" + q;
	}
	//---------- getParamObject
	function getParamObject(){
		var q = document.location.search;
		if(q!=""){
			var p = {};
			q = ( q.substring(1) ).split("&");
			for(var x=0; x<q.length; x++){
				var tmp = q[x].split("=");
				switch( typeof p[tmp[0]] ){
					case "undefined" : p[tmp[0]] = tmp[1]; break;
					case "string"    : _tmp = p[tmp[0]]; p[tmp[0]] = [_tmp,tmp[1]]; break;
					case "object"    : _tmp = p[tmp[0]].length; p[tmp[0]][_tmp] = tmp[1]; break;
				}
			}
			return p;
		}
		else return null;
	}
	//---------- getDisplayFrame
	function getDisplayFrame(id){
		var f     = document.createElement("iframe"), 
			fs    = f.style, 
			mpObj = window.top["mplayerObj"];

		f.id               = id;
		f.frameBorder      = "0";
		f.scrolling        = "no";
		fs.position        = "absolute";
		fs.top             = "-2000px";
		fs.left            = "-2000px";
		fs.zIndex          = "99999";
		fs.backgroundColor = "#000";
		fs.width           = "1px";
		fs.height          = "1px";
		f.hide             = function(){
								this.moveTo(-2000, -2000); 
								if(this.id=="w" && this["closeBtn"]){ this.closeBtn.className	= "wfCloseBtnOff"; }
							};
		f.moveTo           = function(x,y){
								this.previousLeft = this.style.left;
								this.previousTop = this.style.top;
								this.style.top = x+"px";
								this.style.left = y+"px";
								if(this.id=="w" && this["closeBtn"]){ this.closeBtn.className	= "wfCloseBtn"; }
							};
		f.resizeTo         = function(w,h){
								this.style.width = w+"px";
								this.style.height = h+"px";
							};
		f.show             = function(){
								this.style.left = (this["previousLeft"]) ? this.previousLeft : "0";
								this.style.top = (this["previousTop"]) ? this.previousTop : "0";
							};
		f.init             = function(view, url){
                                var container = ( !!arguments[ 2 ] ) ? arguments[ 2 ] : document.body; // append frame to optional 'container' argument or to document.body
                                    
								if(this.id=="p" && view.h!=null && (!mpObj.isActiveXEnabled || !mpObj.customCtrls) && !mpObj.isFlv) view.h += 85;
								if(this.id=="w"){ this.closeBtn = getCloseFrameBtn(this); }
								if(view.w!=null && view.h!=null) this.resizeTo(view.w, view.h);
								if(view.x!=null && view.y!=null) this.moveTo(view.x, view.y);

								container.appendChild(this);

								if(url!=null) this.src = url;
							};
		return f;
	}

    function getFreeWheelAdContainer( id, w, h ) {
        /*
		var fwContainer = document.createElement( "div" ),
            fws = fwContainer.style,
            adFrame,
            
            fwProxy,
            fwForm,
            fwInput,
            fwIframeContainer;
            

		fwContainer.id      = id;
		fws.position        = "absolute";
		fws.top             = "-2000px";
		fws.left            = "-2000px";
		fws.zIndex          = "99999";
		fws.backgroundColor = "#000";
		fws.width           = "1px";
		fws.height          = "1px";

        // freewheel ad manager DOM code
        fwProxy           = document.createElement( "span" );
        fwProxy.id        = "external_sidebar";
        fwProxy.className = "_fwph";

        // freewheel form
        fwForm = document.createElement( "form" );
        fwForm.id            = "_fw_form_external_sidebar";
        fwForm.style.display = "none";

        // freewheel hidden input field
        fwInput = document.createElement( "input" );
        fwInput.id = "_fw_input_external_sidebar";
        fwInput.setAttribute( "type", "hidden" );
        fwInput.setAttribute( "name", "_fw_input_external_sidebar" );
        fwInput.setAttribute( "value", "w=" + w + "&h=" + h + "&envp=g_js&sflg=-nrpl" );
        
        // freewheel iframe container 
        fwIframeContainer = document.createElement( "span" );
        fwIframeContainer.id        = "_fw_container_external_sidebar";
        fwIframeContainer.className = "_fwac";

        // append freewheel DOM elements to our DOM
        fwForm.appendChild( fwInput );
        fwProxy.appendChild( fwForm );
        fwProxy.appendChild( fwIframeContainer );

        fwContainer.appendChild( fwProxy );
		*/
		/*
        <span id="external_sidebar" class="_fwph">
          <form id="_fw_form_external_sidebar" style="display:none">
          <input type="hidden" name="_fw_input_external_sidebar" id="_fw_input_external_sidebar" value="w=300&h=250&envp=g_js&sflg=-nrpl">
          </form>
          <span id="_fw_container_external_sidebar" class="_fwac">
            <iframe id="companionAd" frameborder="0" scrolling="no"></iframe>
          </span>
        </span>
        */
		/*
        // freewheel ad container interface is the same as getDisplayFrame() objs
		fwContainer.hide = function(){
                this.moveTo(-2000, -2000); 
            };
		fwContainer.moveTo          = function(x,y){
                this.previousLeft = this.style.left;
                this.previousTop = this.style.top;
                this.style.top = x+"px";
                this.style.left = y+"px";
            };
		fwContainer.resizeTo        = function(w,h){
                this.style.width = w+"px";
                this.style.height = h+"px";
            };
		fwContainer.show            = function(){
                this.style.left = (this["previousLeft"]) ? this.previousLeft : "0";
                this.style.top = (this["previousTop"]) ? this.previousTop : "0";
            };
		fwContainer.init = function(view, url){
            adFrame = getDisplayFrame( "companionAd" );
            document.body.appendChild( fwContainer );

            if(view.w!=null && view.h!=null) this.resizeTo(view.w, view.h);
            if(view.x!=null && view.y!=null) this.moveTo(view.x, view.y);

            view.x = 0;
            view.y = 0;

            adFrame.init( view, "", fwIframeContainer );

            // can only run init once!
            delete( this.init );
        };

        return fwContainer;
		*/
    }

	//---------- getCloseFrameBtn
	function getCloseFrameBtn(f){
		var d  = document.createElement("div"),
			ds = d.style;
		d.wfFrame   = f;
		d.innerHTML = "&nbsp;";
		d.className = "wfCloseBtn";
		d.onclick   = function(){ this.wfFrame.hide(); };
		document.body.appendChild(d);
		return d;
	}

    /**
     * Sets url and parameters for Player IFrame
     * @private
     */
    function setPlayerFrameUrl( p ) {

        var pfURL = [],
            width  = "w=",
            height = "h=";

        width  += p.w || 512;
        height += p.h || 332;

		if (!!this.config.flv || (!!this.config.adType && this.config.adType==='flash' && !!this.config.adUrl && this.config.adUrl!=='')){
			//this.customControls = false; // turn off custom controls
			this.isFlv          = true;

            // configure player and content url
            pfURL.push( p.pUrl + "?url=" + escape( p.murl ) );
            pfURL.push( "mediaId=" + p.mediaId );

            // flv player basic setup and skinning
            pfURL.push( width );
            pfURL.push( height );
            pfURL.push( "format=" + p.mtype );
            pfURL.push( "autoplay=true" );
            pfURL.push( "bgColorBody=000" );
            pfURL.push( "skin=" + escape( this.config.skin || "/flash/video/v2/skins/mlb_mediaLandingSkin.swf") );

            // doubleclick ad hack (for WBC)
            if(!!this.config.adUrl) {
                pfURL.push( 'adUrl=' + escape(this.config.adUrl) );
            }
            if( !!this.config.adBannerUrl ) {
                pfURL.push( 'adBannerUrl=' + escape(this.config.adBannerUrl) );
            }
            if( !!this.config.domain ) {
                pfURL.push('domain=' + this.config.domain );
            }
            
            // freewheel ad
            if( !!p.isFreeWheelSite) {
                pfURL.push( "isFreeWheelSite=" + p.isFreeWheelSite );
            }
            if( !!p.fwCompanionSize) {
                pfURL.push( "fwCompanionSize=" + p.fwCompanionSize );
            }

            this.playerFrameUrl = pfURL.join( '&' ) + p.av;

			if (this.playerObj !== null){ this.playerObj=null; }
		} else {
			this.isFlv = false;
			this.playerFrameUrl = p.pUrl + "?media_url=" + escape(p.murl) + "&format=" + p.mtype + p.av;
		}
    }
}

/////////////////////////////////////////////////////////////
// **** Public Static Methods ****
//---------- Set Custom Controls
MPlayer.setControls = function(mpo, po){
	var ax = mpo.isActiveXEnabled;

	mpo.stop         = function(){ if(ax) po.controls.stop(); };
	mpo.pause        = function(){ if(ax) po.controls.pause(); };
	mpo.setVolume    = function(v){ if(ax) po.settings.volume=v; };
	mpo.resume       = function(){ if(ax) po.controls.play(); };
	mpo.getMediaTime = function(){ if(ax) return po.controls.currentPosition; };
	mpo.getPlayState = function(){ if(ax) return po.playState; };
	mpo.seek         = function(t){ if(ax) po.controls.currentPosition = t; };
	mpo.fullscreen   = function(){ if(ax && po.playState == 3) po.fullScreen='true'; };
	mpo.hide         = function(){ mpo.playerFrame.hide(); };
	mpo.show         = function(){ mpo.playerFrame.show(); };
	mpo.resizeTo     = function(w,h){
		mpo.playerFrame.resizeTo(w,h);
		if(ax){
			po.height = h;
			po.width  = w;
		}
		else{
			mpo.config.resize = w + "x" + h;
			mpo.play(mpo.config);
		}
	};
	mpo.moveTo = function(x,y){ mpo.playerFrame.moveTo(x,y); };
	mpo.mute = function(){
		if(ax){
			var b = po.mute;
			po.mute = (b=="true") ? "false" : "true";
		}
	};
};
//---------- Get media player plugin object
MPlayer.getPlayerObj = function(o){
	var _obj = null,
	plyr_tpl = (o.type!=null && o.type!="" && MPlayer[o.type]) ? MPlayer[o.type] : "";
	plyr_tpl = plyr_tpl.replace(/\[NAME\]/g, o.name);
	plyr_tpl = plyr_tpl.replace(/\[URL\]/g, o.url);
	plyr_tpl = plyr_tpl.replace(/\[HEIGHT\]/g, o.height);
	plyr_tpl = plyr_tpl.replace(/\[WIDTH\]/g, o.width);
	if(typeof o["resize"]!=undefined && o["resize"]==true){
		plyr_tpl = plyr_tpl.replace(/\[IERESIZE\]/g, "true");
		plyr_tpl = plyr_tpl.replace(/\[OTHERRESIZE\]/g, "4");
	}
	else{
		plyr_tpl = plyr_tpl.replace(/\[IERESIZE\]/g, "false");
		plyr_tpl = plyr_tpl.replace(/\[OTHERRESIZE\]/g, "1");
	}
	if(typeof o["controls"]!=undefined && o["controls"]==true){
		plyr_tpl = plyr_tpl.replace(/\[UIMODE\]/g, "none");
		plyr_tpl = plyr_tpl.replace(/\[CONTROLS\]/g, "0");
	}
	else{
		plyr_tpl = plyr_tpl.replace(/\[UIMODE\]/g, "full");
		plyr_tpl = plyr_tpl.replace(/\[CONTROLS\]/g, "1");
	}
	document.write("<div id='" + o.name + "Wrapper" + "'>" + plyr_tpl + "</div>");
	_obj = document[o.name];
	_obj.wrapper = document.getElementById(o.name + "Wrapper");
	_obj.kill = function(){ try{ this.controls.stop(); } catch(e){ this.wrapper.innerHTML = ""; } };
	return _obj;
};
//---------- Get Player Info
MPlayer.checkActiveX=function(){
	if( ( window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1 ) || window.GeckoActiveXObject ){
		var player=createActiveXObject("WMPlayer.OCX.7");
		if(player){ return true; }
		else{
			player=createActiveXObject("MediaPlayer.MediaPlayer.1");
			if(player){ return true; }
		}
		return false;
	}
	function createActiveXObject(id){
	  var control = null;
	  try{
	    if(window.ActiveXObject){ control = new ActiveXObject(id); }
	    else if(window.GeckoActiveXObject){ control = null; }
	  }catch(e){}
	  return control;
	}
};
//---------- Create SilverLight Player
MPlayer.SilverLightPlayer = function(o){
	var xaml	= (o["xaml"])   ? o["xaml"]   : "",
		name	= (o["name"])   ? o["name"]   : "SLPlayer",
		width	= (o["width"])  ? o["width"]  : 240,
		height	= (o["height"]) ? o["height"] : 180;

	this.preWrite = function(o){ return true; };
	this.getWidth = function(){ return width; };
	this.getHeight = function(){ return height; };
	this.getName = function(){ return name; };
	this.getXaml = function(){ return xaml; };

	this.writePlayer = function(o){
		var writePlayer = this.preWrite(o);
		if( writePlayer ){
			var plyr_tpl = MPlayer["sl"],
				width  = (o["width"])  ? o.width  : this.getWidth(),
				height = (o["height"]) ? o.height : this.getHeight(),
				name   = (o["name"])   ? o.name   : this.getName(),
				xaml   = (o["xaml"])   ? o.xaml   : this.getXaml(),
				mid	   = (o["mid"])    ? o["mid"] : "";
				slUrl  = "/media/player/viral_video_player.jsp?xaml=" + xaml + "&name=" + name + "&width=" + width + "&height=" + height + "&mid=" + mid,
				iframe = "<iframe src='" + slUrl + "' name='" + name + "' id='" + name + "' width='" + width + "' height='" + height + "' marginwidth='0' marginheight='0' scrolling='no' frameborder='0'></iframe>";
			document.write("<div id='" + name + "Frame" + "'>" + iframe + "</div>");
		}
	};
};
MPlayer.emailVideo = function(mediaId, metaId, title){
	var url    ="/media/email/send.jsp?mediaId=" + mediaId + "&metaId=" + metaId + "&title=" + escape(title),
		width  = 500,
		height = 470;
	if( width > screen.availWidth-12 ) width = screen.availWidth - 12;
	if( height > screen.availHeight-48 ) height = screen.availHeight - 48;
	var left = (screen.availWidth - width - 12) / 2,
		top  = (screen.availHeight - height - 48) / 2;
	void( window.open(url, name, "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top) );
};
//---------- object tag templates
MPlayer.w = "<object id='[NAME]' name='[NAME]' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' src='[URL]' width='[WIDTH]' height='[HEIGHT]'><param name='autoStart' value='true'>"+
			"<param name='uiMode' value='[UIMODE]'><param name='animationAtStart' value='0'><param name='transparentAtStart' value='true'><param name='url' value='[URL]'>"+
			"<param name='stretchToFit' value='[IERESIZE]'><param name='defaultFrame' value='wmpEventFrame'><param name='align' value='middle'><param name='showStatusBar' value='1'><param name='showTracker' value='1'><param name='showDisplay' value='false'>"+
			"<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='[URL]' name='[NAME]' id='mplayer' width='[WIDTH]' "+
			"height='[HEIGHT]' autostart='1' displaysize='[OTHERRESIZE]' align='middle' animationatstart='0' transparentatstart='1' showstatusbar='[CONTROLS]' showdisplay='0' showtracker='[CONTROLS]' "+ 
			"showcontrols='[CONTROLS]' defaultFrame='wmpEventFrame' swliveconnect='0' nojava='1'></embed></object>";
MPlayer.q = "<object id='[NAME]' name='[NAME]' width='[WIDTH]' height='[HEIGHT]' classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>"+
			"<param name='src' value='[URL]'><param name='autoplay' value='true'><param name='loop' value='false'><param name='controller' value='true'><param name='scale' value='true'>"+
			"<embed id='test' name='test' width='[WIDTH]' height='[HEIGHT]' type='video/quicktime' pluginspage='http://www.apple.com/quicktime/' src='[URL]' scale='true' autoplay='true' loop='false' "+
			"controller='true'></embed></object>";
MPlayer.r = "<object id='[NAME]' name='[NAME]' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='[WIDTH]' height='[HEIGHT]'>"+
			"<param name='CONTROLS' value='imagewindow'/><param name='AUTOGOTOURL' value='false'/><param name='CENTER' value='true'/>"+
			"<param name='AUTOSTART' value='true'/><param name='CONSOLE' value='[NAME]'/><param name='NOLOGO' value='true'/><param name='SRC' value='[URL]'>"+
			"<embed name='[NAME]' id='[NAME]' type='audio/x-pn-realaudio-plugin' src='[URL]' height='[HEIGHT]' width='[WIDTH]' "+
			"controls='imagewindow' autogotourl='false' center='true' autostart='true' console='[NAME]' nologo='1' /></object>"+
			"<object id='realPlayerControl' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='[WIDTH]' height='30'>"+
			"<param name='CONTROLS' value='ControlPanel'><param name='CONSOLE' value='[NAME]'><embed name='realPlayerControl' type='audio/x-pn-realaudio-plugin' height='30' "+
			"width='319' controls='controlpanel' console='[NAME]' autogotourl='false' src='[URL]' /></object>";

