// JavaScript Document
var isUnload = false;
var jscript_support = false;
if (navigator.appName.indexOf("Microsoft") != -1)
{
    jscript_support = true;
}
function setDisplayStyle(id,value)
{
	try
	{
		var obj = document.getElementById(id);
		if( obj )
			obj.style.display = value;
	}
	catch(e)
	{
	}
}

function trim(str)
{
	if(str !=null)
	{
		var space = ' \r\n\t';
		var startIndex,endIndex;
		for( startIndex = 0 ; startIndex < str.length ; startIndex++ )
		{
			if(space.indexOf(str.charAt(startIndex)) == -1)
			break;
		}
		for( endIndex = str.length - 1 ; endIndex > startIndex  ; endIndex-- )
		{
			if(space.indexOf(str.charAt(endIndex)) == -1)
			break;
		}
		return str.substring(startIndex,endIndex+1);
	}
	return str;
}
function setMovieFile(thefileurl,_width,_height,autostart,loop)
{
	if( _width == null )
	{
		_width = 320;
	}
	if( _height == null )
	{
		_height = 240;
	}
	if( autostart == null )
		autostart = 1;
	if( loop == null )
	{
		loop = 1;
	}
	var debug = 0;
	var video=document.getElementById("media");
	if( video )
	{
		thefileurl = trim(thefileurl);//none
		if( jscript_support )
		{
			mediatag = "<object id='Player' width='"+_width+"' height='"+_height+"' classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6'>\
							<param name='url' value='"+thefileurl+"'>\
							<param name='enableContextMenu' value='"+debug+"'>\
							<param name='autoStart' value='"+ autostart +"'>\
							<param name='stretchToFit' value='1'>\
							<param name='uiMode' value='none'>\
							<param name='BufferingTime' value='3'>\
							<param name='windowlessVideo' value='0'>";
			if( loop > 1 )
			{
				mediatag += "<param name='playCount' value='"+loop+"'>";
			}
			mediatag += "<embed type='application/x-mplayer2' width='"+_width+"' height='"+_height+"' src='"+thefileurl+"'\
							enableContextMenu='"+debug+"'\
							autoStart='1'\
							stretchToFit='1'\
							showControls='0'\
							showTracker='1'\
							showStatusBar='1'\
							showPositionControls='0'\
							BufferingTime='3'\
							AutoSize='0'\
							windowlessVideo='0'";
							
							 
			if( loop > 1 )
			{
				mediatag += " playCount='"+loop+"'";
			}
			mediatag += "></embed></object>";
			var status=document.getElementById("status");
			try
			{
				status.style.display ="";
			}
			catch(e)
			{
			}
		}
		else
		{
			mediatag = "<embed type='application/x-mplayer2' id='Player' width='"+_width+"' height='"+(_height+42)+"' src='"+thefileurl+"'\
							enableContextMenu='"+debug+"'\
							autoStart='"+autostart+"'\
							stretchToFit='1'\
							showStatusBar='1'\
							showPositionControls='0'\
							BufferingTime='3'\
							AutoSize='0'";
			if( loop > 1 )
			{
				mediatag += " playCount='"+loop+"'";
			}
			mediatag += "></embed>";
		}
		video.innerHTML = mediatag;
		//alert(video.innerHTML);
		/*if( jscript_support )
		{
			Player.settings.setMode("autoRewind", false);
		}*/
	}
}
function setMovieFile1(thefileurl,_width,_height,autostart,loop)
{
	if( _width == null )
	{
		_width = 320;
	}
	if( _height == null )
	{
		_height = 240;
	}
	if( autostart == null )
		autostart = 1;
	if( loop == null )
	{
		loop = 1;
	}
	var debug = 0;
	var video=document.getElementById("media");
	if( video )
	{
		thefileurl = trim(thefileurl);//none
		if( jscript_support )
		{
			mediatag = "<object id='Player' width='"+_width+"' height='"+_height+"' classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6'>\
							<param name='url' value='"+thefileurl+"'>\
							<param name='enableContextMenu' value='"+debug+"'>\
							<param name='autoStart' value='"+ autostart +"'>\
							<param name='stretchToFit' value='1'>\
							<param name='uiMode' value='mini'>\
							<param name='showPositionControls' value='0'>\
							<param name='BufferingTime' value='3'>\
							<param name='showStatusBar' value='1'>\
							<param name='showTracker' value='0'>\
							<param name='windowlessVideo' value='0'>";
			if( loop > 1 )
			{
				mediatag += "<param name='playCount' value='"+loop+"'>";
			}
			mediatag += "<embed type='application/x-mplayer2' width='"+_width+"' height='"+_height+"' src='"+thefileurl+"'\
							enableContextMenu='"+debug+"'\
							autoStart='1'\
							stretchToFit='1'\
							showControls='0'\
							showTracker='0\
							showStatusBar='1'\
							showPositionControls='0'\
							BufferingTime='3'\
							AutoSize='0'\
							windowlessVideo='0'";
							
							 
			if( loop > 1 )
			{
				mediatag += " playCount='"+loop+"'";
			}
			mediatag += "></embed></object>";
			var status=document.getElementById("status");
			try
			{
				status.style.display ="";
			}
			catch(e)
			{
			}
		}
		else
		{
			mediatag = "<embed type='application/x-mplayer2' id='Player' width='"+_width+"' height='"+(_height+42)+"' src='"+thefileurl+"'\
							enableContextMenu='"+debug+"'\
							autoStart='"+autostart+"'\
							stretchToFit='1'\
							showStatusBar='1'\
							showPositionControls='0'\
							BufferingTime='3'\
							AutoSize='0'";
			if( loop > 1 )
			{
				mediatag += " playCount='"+loop+"'";
			}
			mediatag += "></embed>";
		}
		video.innerHTML = mediatag;
		//alert(video.innerHTML);
		/*if( jscript_support )
		{
			Player.settings.setMode("autoRewind", false);
		}*/
	}
}