



//---------------------------------------------------------------------
function MPCheck()
{


//document.getElementById('lblOS').innerHTML = 'MacPPC'
	if (document.getElementById('lblOS').innerHTML == 'UNIX')
	{
		MPEnv = mpLINFOX
		mpHeight = mpHeight + mpLINFOXctrlHeight
		try
		{
			document.MPlayer.showlogo = 0
		}
		catch(e)
		{
			document.getElementById("divPlayer").innerHTML = "<br><br><br><font color='gray'>Please have the <a target='_new' href='http://mplayerplug-in.sourceforge.net/download.php'>mplayer plug-in</a> installed to view this presentation.</font>"
			return 1
		}
	}
	else if (document.getElementById('lblOS').innerHTML.toUpperCase().indexOf('WIN') != -1 )
	{
		if (document.getElementById('lblBrowser').innerHTML != 'IE')
		{
			MPEnv = mpWINFOX
			mpHeight = mpHeight +  mpWINFOXctrlHeight
			//document.getElementById("divPlayer").innerHTML = "<br><br><br><font color='gray'>Please have the <a target='_new' href='http://www.iol.ie/~locka/mozilla/plugin.htm#download'>ActiveX plug-in</a> installed to view this presentation.</font>"
		document.getElementById('divPlayer').style.height = mpHeight
		document.getElementById('divSlides').style.height = _clientHeight - mpHeight-10
		document.getElementById('divSlides').style.top -= 2
		}
		else
		{
			mpHeight = mpHeight +  mpWINIEctrlHeight
			MPEnv = mpWINIE
		}
		
	}
	else if (navigator.platform.toUpperCase().indexOf('MAC') != -1 )
	{
		MPEnv = mpMACFOX
		mpHeight = mpHeight +  mpMACFOXctrlHeight
		document.getElementById('divPlayer').style.height = mpHeight
		document.getElementById('divBrowse').style.top = mpHeight+1
		document.getElementById("divPlayer").innerHTML = "<br><br><br><font color='gray'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Install <A href='/WM Components 2.1.dmg'>WMV</A> Plugin if the video does not appear</font>"
	}
	else if(document.getElementById('lblOS').innerHTML.toUpperCase().indexOf('YT') != -1 )
	{
        MPEnv = mpYT
        mpHeight -= 18
    }	    
	//alert(MPEnv)
	
	
	
	return 1

}

function MPGetPluginHTML(srcFile)
{
      //  mpHeight -= 18
//alert(mpHeight)
	var pluginHTML 
	if (MPEnv == mpLINFOX || MPEnv == mpWINFOX)
		pluginHTML = '<embed  id="MPlayer" name="MPlayer" autostart=0  width="' + mpWidth + '" height="' + mpHeight + '" type="application/x-ms-wmp" Controller="true" Target="myself"  src=' + '"' + srcFile + '" showstatusbar=0 showcontrolbar=0 stretchtofit=1 enablecontextmenu=0 invokeurls=0></embed>'
	else if (MPEnv == mpMACFOX )
	{
		//mpWidth = 340
		//mpHeight = 316
		srcFile = srcFile.replace(" ","%20")
		pluginHTML = '<embed  id="MPlayer" name="MPlayer" scale="aspect" enablejavascript="true" type="video/quicktime" width="' + mpWidth + '" height="' + mpHeight + '" Controller="true" Target="myself" autoplay="true" src="dummy.mov" qtsrc=' + '"' + srcFile + '"></embed>'
		//pluginHTML = "QT_WriteOBJECT_XHTML('" + srcFile + "', '420', '341', '', 'autoplay', 'true', 'emb#bgcolor', 'black', 'align', 'middle')"===== src="dummy.mov" qt
//alert(pluginHTML )
	}
	else if (MPEnv == mpWINIE  )
	{
		//6BF52A52-394A-11D3-B153-00C04F79FAA6
		pluginHTML = '<object id="MPlayer" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" type="application/x-oleobject" ' 
		pluginHTML += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" '
        pluginHTML += 'width="' + mpWidth + '" height="' + mpHeight + '"  >\r\n'
        pluginHTML += '<param name="filename" value="' + srcFile + '">\r\n'
        pluginHTML += '<param name="autostart" value="true">\r\n'
        pluginHTML += "<br><br><br><font color='gray'>Please have the <a target='_new' href='http://www.iol.ie/~locka/mozilla/plugin.htm#download'>ActiveX plug-in</a> installed to view this presentation.</font>\r\n"
        pluginHTML += '</object>\r\n'
	}
	else if (MPEnv == mpYT)
	{
        pluginHTML ='<div id="divYT"><font color=white>You need Flash player 8+ and JavaScript enabled to view this video.</font></div>'

	}
	return pluginHTML
}
//---------------------------------------------------------------------
function MPInit()
{
	if (MPEnv == mpWINIE)
	{
        document.MPlayer.strecthToFit = 0
        document.MPlayer.InvokeURLs = false
        document.MPlayer.enableContextMenu = false
		document.getElementById('divPlayPos').style.posLeft = 427 //294 //200
		document.getElementById('divPlayPos').style.posTop = 35 //364 //337
		document.getElementById('divPlayPos').className = 'divPlayPosIE'
        
	}
	else if (MPEnv == mpWINFOX)
	{
        document.MPlayer.strecthToFit = true
        document.MPlayer.settings.invokeURLs = false
        document.MPlayer.enableContextMenu = false
        document.MPlayer.showStatusBar = false
        document.MPlayer.controls.play()
	//alert(document.MPlayer.settings.invokeURLs)
        
		document.getElementById('divPlayPos').style.left = 427 //294
		document.getElementById('divPlayPos').style.top = 35 //364
		document.getElementById('divPlayPos').className = 'divPlayPosIE'
	}
	else if (MPEnv == mpLINFOX)
	{
	
	}
	else if (MPEnv == mpMACFOX)
	{
    // document.getElementById('divPlayPos').style.leftPos = 
	document.MPlayer.SetURL(_wmv)
		document.getElementById('divPlayPos').style.left = 427 //294
		document.getElementById('divPlayPos').style.top = 35 //364
		document.getElementById('divPlayPos').className = 'divPlayPosIE'
	//alert(document.MPlayer.GetURL())
	}
	else if (MPEnv == mpYT)
	{
		document.getElementById('divPlayPos').display = 'none'
        var params = { allowScriptAccess: "always", menu: "false", play: "true" };
        var atts = { id: "MPlayer" };
        swfobject.embedSWF("http://www.youtube.com/v/" +document.getElementById('lblBrowser').innerHTML + "&rel=0&color1=0x006699&color2=0x54abd6&enablejsapi=1&playerapiid=MPlayer", 
                           "divYT", "420", "356", "8", null, null, params, atts);
   
	
/*    	pluginHTML ='<object id=MPlayer width="' + mpWidth + '" height="' + mpHeight + '"><param name="movie" value="http://www.youtube.com/v/' 
    	pluginHTML += document.getElementById('lblBrowser').innerHTML  //ITQ-zVYg2rg
    	pluginHTML += '&hl=en&fs=1&rel=0&color1=0x006699&color2=0x54abd6&enablejsapi=1&playerapiid=MPlayer"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>"'
    	pluginHTML +='<embed id=MPlayer src="http://www.youtube.com/v/'
    	pluginHTML +=document.getElementById('lblBrowser').innerHTML  //ITQ-zVYg2rg
    	pluginHTML += '&hl=en&fs=1&rel=0&color1=0x006699&color2=0x54abd6&enablejsapi=1&playerapiid=MPlayer" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"'
    	pluginHTML +=' width="' + mpWidth + '" height="' + mpHeight + '"  ></embed></object>'
    	*/
   	}
}

//---------------------------------------------------------------------
function MPSeek(seekPos)
{
	if (MPEnv == mpWINIE)
	{
        document.MPlayer.currentPosition = seekPos
	}
	else if (MPEnv == mpWINFOX)
	{
        document.MPlayer.controls.currentPosition = seekPos
	}
	else if (MPEnv == mpLINFOX)
	{
		document.MPlayer.Seek(seekPos)
	}
	else if (MPEnv == mpMACFOX)
	{
		document.MPlayer.SetTime(seekPos*document.MPlayer.GetTimeScale())
	}
	else if (MPEnv == mpYT)
	{
	    document.MPlayer.seekTo(seekPos,true)
	}
}

//---------------------------------------------------------------------
function MPPlay()
{
	if (MPEnv == mpWINIE)
	{
        document.MPlayer.Play()
	}
	else if (MPEnv == mpWINFOX)
	{
        document.MPlayer.controls.Play()
	}
	else if (MPEnv == mpLINFOX)
	{
        document.MPlayer.Play()
	}
	else if (MPEnv == mpMACFOX)
	{
		document.MPlayer.Play()
	}
	else if (MPEnv == mpYT)
	{
		document.MPlayer.playVideo()
	}
}

//---------------------------------------------------------------------
function MPGetState()
{
    try{
	if (MPEnv == mpWINIE)
	{
        var playState = document.MPlayer.playState
		switch (playState){
			case 0:
				_playState = "stopped";
				break;
			case 1:
				_playState = "paused";
				break;
			case 2:
				_playState = "playing";
				break;
			case 6:
				_playState = "buffering...";
				break;
			default:
				_playState = "";
		}
	}
	if ( MPEnv == mpWINFOX)
	{
        var playState = document.MPlayer.playState
		switch (playState){
			case 1:
				_playState = "stopped";
				break;
			case 2:
				_playState = "paused";
				break;
			case 3:
				_playState = "playing";
				break;
			case 6:
				_playState = "buffering...";
				break;
			default:
				_playState = "";
		}
	}
	else if (MPEnv == mpLINFOX)
	{
        var playState = document.MPlayer.playState
		switch (playState){
			case 1:
				_playState = "stopped";
				break;
			case 2:
				_playState = "paused";
				break;
			case 3:
				_playState = "playing";
				break;
			default:
				_playState = "";
		}
	}
	else if (MPEnv == mpMACFOX)
	{
//document.getElementById('divTitle').innerHTML = document.MPlayer.GetPluginStatus()
        var playState = document.MPlayer.GetPluginStatus()
		if (playState == 'Playable')
				_playState = "playing";
				//_playState = "Complete";
		else if (playState == 'Loading')
				_playState = "paused";
		else if (playState == 'Complete')
				_playState = "playing";

	  //_playState = "playing";			
	}
	else if (MPEnv == mpYT)
	{
        var playState = document.MPlayer.getPlayerState()
		switch (playState){
		    case 0:
				_playState = "stopped";
				break;
			case 1:
				_playState = "playing";
				break;
			case 2:
				_playState = "paused";
				break;
			case 3:
				_playState = "buffering";
				break;
			default:
				_playState = "";
		}
	}
	}catch(e){}
    return _playState 
}

//---------------------------------------------------------------------
function MPGetPosition()
{
	if (MPEnv == mpWINIE)
	{
        return document.MPlayer.currentPosition
	}
	else if (MPEnv == mpWINFOX)
	{
        return document.MPlayer.controls.currentPosition
	}
	else if (MPEnv == mpLINFOX)
	{
        return document.MPlayer.getTime()
	}
	else if (MPEnv == mpMACFOX)
	{
		return document.MPlayer.GetTime()/document.MPlayer.GetTimeScale()
	}
	else if (MPEnv == mpYT)
	{
		return document.MPlayer.getCurrentTime()
	}

}

//---------------------------------------------------------------------
function MPGetDuration()
{
	if (MPEnv == mpWINIE)
	{
        return document.MPlayer.duration
	}
	else if (MPEnv == mpWINFOX)
	{
        return document.MPlayer.currentMedia.duration
	}
	else if (MPEnv == mpLINFOX)
	{
        return document.MPlayer.getDuration()
	}
	else if (MPEnv == mpMACFOX)
	{
		return (document.MPlayer.GetDuration()/document.MPlayer.GetTimeScale())
	}
	else if (MPEnv == mpYT)
	{
		return (document.MPlayer.getDuration())
	}

}
