// JavaScript Document

// Browser sniff -- the following code does a very simple browser check and rates the 
//     browser as either Internet Explorer on a Win32 platform or not, so that we 
//     know to use the ActiveX model, or the plug-in Model.
var sBrowser = navigator.userAgent;  
if ((sBrowser.indexOf("IE") > -1) && (navigator.platform == "Win32"))
{	//document.write("IE");
	sBrowser = "IE";
} else {
	sBrowser = "nonIE";
	//document.write("not IE");
}
// end browser sniff
function liveevent(tittel, goaltime, runthis,image){
var height="355";
var width="525";
var randomnumber=Math.round(Math.random()*1000);
var randomtext=String(randomnumber)+"";
	var queries="?tittel="+tittel+"&goaltime="+goaltime+"&runthis="+runthis+"&image="+image+"&random="+randomtext;
	var src="liveevent.swf";
	var l1 = '<object ID="MediaPlayer1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">';
	var l2 = '<param name="movie" value="'+src+queries+'" />';
	var l3 = '<param name="quality" value="high" />';
	var l4 = '<embed ID="MediaPlayer1" src="'+src+queries+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>';
	var l5 = '</object>';
	var allLines=l1+l2+l3+l4+l5;
	document.getElementById('videoPlayer').innerHTML=allLines;
	
}
function newURL(selectedVideo, filetype){
	if(filetype=="W"){
	if (sBrowser == "IE") {
					var zeheight = "295";
					var showit = "0";
				} else {
					var showit = "1";
					var zeheight = "355";
					}
	var l1='<div valign="center" align="center"><object ID="MediaPlayer1" width=525 height='+zeheight+' classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'; 
	var l2='	codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"';
	var l3='        standby="Loading Microsoft® Windows® Media Player components..." ';
	var l4=' type="application/x-oleobject"><PARAM NAME="FileName" VALUE="'+selectedVideo+'">';
	var l5='  <PARAM NAME="ShowControls" VALUE="'+showit+'"><param name="displaybackcolor" value="0"><param name="displayforecolor" value="0"><EMBED type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"';
	var l6=' SRC="'+selectedVideo+'" name="MediaPlayer1" width=525 height='+zeheight+' ShowControls='+showit+' displayforecolor="0" displaybackcolor=”0”> </EMBED></object></div>';
	var l7='<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="525" height="60" accesskey="4" tabindex="4" title="kontrollpanel"><param name="movie" value="kontrollpanel.swf" /><param name="quality" value="high" /><embed src="kontrollpanel.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="525" height="60"></embed></object>';
	if (sBrowser == "IE") {
	var allLines=l1+l2+l3+l4+l5+l6+l7;
		//alert(allLines);
		document.getElementById('videoPlayer').innerHTML=allLines;
	} 
		else {
		var allLines=l1+l2+l3+l4+l5+l6;
		document.getElementById('videoPlayer').innerHTML=allLines;
	};
		
	} else if(filetype=="Q"){
	var showit="true";
	var zeheight="295";
	var l1='<div valign="center" align="center"><object ID="Quicktime" width=355 height='+zeheight+' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'; 
	var l2='	CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"';
	var l3='    ';
	var l4=' type="application/x-oleobject"><PARAM NAME="BGCOLOR" VALUE="WHITE"><PARAM NAME="SRC" VALUE="'+selectedVideo+'">';
	var l5='  <PARAM NAME="controller" VALUE="'+showit+'"><EMBED type="video/quicktime" pluginspage = "http://www.apple.com/qtactivex/qtplugin.cab"';
	var l6=' SRC="'+selectedVideo+'" showlogo=false  BGCOLOR="white" name="Quicktime" width=450 height='+zeheight+' controller='+showit+' displayforecolor="0" displaybackcolor=”0”> </EMBED></object></div>';
	//if (sBrowser == "IE") {
	//var allLines=l1+l2+l3+l4+l5+l6+l7;
	//document.getElementById('videoPlayer').innerHTML=allLines;
	//} 
	//else {
	var allLines=l1+l2+l3+l4+l5+l6;
	document.getElementById('videoPlayer').innerHTML=allLines;
	
	//};

	}else if(selectedVideo.length<5){
var width ="525";
var height= "355";
var src = 'videoplayer.swf';
var queries='?flid='+selectedVideo;
var l1 = '<div align="center"><object ID="MediaPlayer1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">';
	var l2 = '<param name="movie" value="'+src+queries+'" />';
	var l3 = '<param name="quality" value="high" />';
	var l4 = '<embed ID="MediaPlayer1" src="'+src+queries+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>';
	var l5 = '</object></div>';
var allLines=l1+l2+l3+l4+l5;

document.getElementById('videoPlayer').innerHTML=allLines;
	};
};
function showClick() // This function is called by the btnShowControls button.
                     // It sets the ShowControls property of Media Player to true.
{
	if (sBrowser == "IE") {
		document.MediaPlayer1.ShowControls = true;
	} else {
		document.MediaPlayer1.SetShowControls(true);
	}
}

function hideClick() // This function is called by the btnHideControls button.
                     // It sets the ShowControls property of Media Player to false.
{
	if (sBrowser == "IE") {
		document.MediaPlayer1.ShowControls = false;
	} else {
		document.MediaPlayer1.SetShowControls(false);
	}
}
function stopPlaying(){
document.MediaPlayer1.Stop();
}
function startPlaying(){
document.MediaPlayer1.Play();
}
function pausePlaying(){
document.MediaPlayer1.Pause();
}
function muteClick() // This function is called by the "Mute" button.
                     // It toggles the state of the Mute property of the Media Player.
{
	var bMuteState;

	if (sBrowser == "IE") {
		bMuteState = document.MediaPlayer1.Mute;
	} else {
		bMuteState = document.MediaPlayer1.GetMute();
	}

	if (bMuteState == true) {
		//document.myButtons.btnMute.value="Mute";
		if (sBrowser == "IE") {
			document.MediaPlayer1.Mute = false;
		} else {
			document.MediaPlayer1.SetMute(false);
		}
	} else {
		//document.myButtons.btnMute.value="Un-Mute";
		if (sBrowser == "IE") {
			document.MediaPlayer1.Mute = true;
		} else {
			document.MediaPlayer1.SetMute(true);
		}
	}
}
function seekit(position){
document.MediaPlayer1.CurrentPosition= parseFloat(position);
}
