
var flashVersionReqd='9.0.0';


/**
 * Plays media object, regardless of type, in the innerdiv and
 * then positions the outerdiv in the viewable screen center.
 */
function playFbMediaObject(   theDivId ,
	                          mediatypeid ,
	                          fileurl ,
	                          w ,
	                          h ,
	                          staticfileurl ,
	                          staticw ,
	                          statich,
	                          bordercol , // color lie #554433
	                          borderwid , // px
	                          showsound , // 0=no sound controls, 1=yes
	                          pausefirstframe,  // 0=no, 1=yes dark on lite, 2=yes, lite on dark
	                          faceboxcloseimg,
	                          title)
{	
	_gel( theDivId ).style.width=(w + 20) + 'px';
	
	var theHtml = "<div style=\"width:\"" + (w+2) +  "px\">";

	_gel( theDivId ).innerHTML = '';

	
	if( title != null && title != '' )
	{
		var titleDiv = '<h2>' + title + '</h2>';
		theHtml += titleDiv;
	}
	
	// image
	if( mediatypeid == 2 )
		theHtml += '<img class="noborder" style="margin-left:-10px" src=\"' + fileurl + '\" width=\"' + w + '\" height=\"' + h + '\" border=\"0\"/>';

	// audio with static file
	else if( mediatypeid == 3 && staticfileurl != '' )
	{
	   var imgtag = "<img src=\"" + staticfileurl + "\" style=\"margin-left:-10px\" width=\"" + staticw + "\" height=\"" + statich + "\" border=\"0\"/>";

	   theHtml += imgtag;
	}

	// the inner div
	if( mediatypeid != 2 )
		theHtml += "<div style=\"margin-left:-11px;margin-top:0px;border:0px\"><div id=\"" + theDivId + "i3\"></div></div>";

	// close button
	theHtml += "<div style=\"height:26px;border:0px\" onclick=\"closeFbWin(\'" + theDivId + "\')\"><img class=\"close\" style=\"cursor:pointer;float:right;padding:2px\" src=\"misc/facebox/" + faceboxcloseimg + "\"/></div>";

	theHtml += "</div>";
	
	// add the html to the outer div
	_gel( theDivId ).innerHTML = theHtml;

	var flashvars = {};
	var params = {};
	var attributes = {};

	// swf
	if( mediatypeid == 6 )
	{
        swfobject.embedSWF( fileurl , theDivId + 'i3' , w , h , '8.0.0','/st/misc/js/swfobject20/expressInstall.swf', flashvars, params, attributes);
	}

	// media player needed
	else if( mediatypeid != 2 )
	{
		if( typeof bordercol != 'undefined' )
			flashvars.bc=encodeURIComponent(bordercol);

		if( typeof borderwid != 'undefined' )
		{

			if( mediatypeid == 3 )
				borderwid=0;

			 flashvars.bw=borderwid + '';
			 w += 2*borderwid;
			 h += 2*borderwid;
		}

		else
			borderwid=0;

		if( typeof showsound != 'undefined' )
			flashvars.snd= showsound ? '1' : '0';

		// if( pausefirstframe == 1 )
		// 	flashvars.pause1 = '1';

		if( fileurl.indexOf( '.mp4' ) > 0 )
			flashVersionReqd = '9.0.115';

		flashvars.showstop='true';
		flashvars.showskip='false';
		flashvars.screencolor='0xffffff';
		//flashvars.displayclick='none';
		//flashvars.controlbar='over'
		flashvars.file = encodeURIComponent(fileurl);
		flashvars.autostart = 'true';
		flashvars.width = w + '';

		// audio
		if( mediatypeid != 3 )
			flashvars.height = h + '';
		// else
		// 	flashvars.height = '20';

		var params = {};
		params.bgcolor='#ffffff';
		params.wmode = 'transparent';
		params.allowFullScreen='true';

		var attributes = {};
		attributes.id = 'vmpl';
		attributes.name = 'vmpl';

		var fullFlashHgt = h + 20;

		if( mediatypeid == 3 )
			fullFlashHgt = 20; //  + 2*borderwid;

        swfobject.embedSWF( '/st/misc/players/st/STMediaPlayer.swf' , theDivId + 'i3' , w , fullFlashHgt , flashVersionReqd ,'/st/misc/js/swfobject20/expressInstall.swf', flashvars, params, attributes);
	}

	// now show it.
	$("#" + theDivId ).overlay({ mask: {color:'#fff',loadSpeed:200,opacity:0.7}, load:false });
	
	$("#" + theDivId ).overlay().load();


}

function closeFbWin( theDivId )
{
	$("#" + theDivId ).overlay().close();	
}
