function ChangePlaylistIndex(playlist, index, videoLink) {
	if (BrowserDetect.OS == "Mac") {
		for (var item in requiredPlaylists.split("|")){
			if(requiredPlaylists.split("|")[item]==playlist){
				playlistindex=item
			}
		}
		location.href = baseURL+"viewer.html?cat="+playlistindex+"&pl="+videoLink;
	} else {
		OldURL = Player.URL;
		if (baseURL+"playlists/"+playlist+".asx" == OldURL) {
			media = Player.currentPlaylist.item(index);
			Player.controls.playItem(media);
		} else {
			OldPlaylistName = Player.currentPlaylist.name;
			Player.URL = baseURL+"playlists/"+playlist+".asx";
			intervalloopcount = 0;
			Globalindex=index
			//GlobalOldPlaylistName=OldPlaylistName
			PlayIndexInterval = setInterval(PlayIndex, 500);
		}
	}
}
if (BrowserDetect.OS == "Mac") {
	///////////////////////////////////////////////
	//Mediaplayer / Flash injectors -- EOLAS
	/**/

	function Write_Media_Player(videosrc, divname) {

		if (!videosrc) {
			videosrc = "http://ohsama.tv/playlists/videoclip.asx";
		}
		videoString = ' \
					  <object id="Player" type="video/x-ms-wmv" data="'+videosrc+'" width="480px" height="360px">\
				        <param name="src" value="'+videosrc+'" valuetype="ref" type="'+videosrc+'">\
				        <param name="animationatStart" value="1">\
				        <param name="transparentatStart" value="1">\
				        <param name="autoStart" value="1">\
				        <param name="ShowControls" value="0">\
				        <param name="ShowDisplay" value="0">\
				        <param name="ShowStatusBar" value="0">\
				        <param name="loop" value="0">\
				        <param name="displaysize" value="0">\
				        <strong>Error:</strong> Embedding <a href="'+videosrc+'">'+videosrc+'</a> with the <a href="http://www.microsoft.com/windows/windowsmedia/download/plugin.aspx">Windows Media Plugin</a> failed.\
				    </object>';

		document.getElementById(divname).innerHTML = videoString;
		Player = document.getElementById('Player');
		Player.Play();
	}

} else if (BrowserDetect.OS == "Windows") {
	function ChangeVolume(volume) {
		Player.settings.volume = volume;
	}
	function ChangeProgress(progress) {
		Player.controls.currentPosition = progress;
	}

	function fastForward() {
		Player.controls.fastForward();
	}
	function fastReverse() {
		Player.controls.fastReverse();
	}
	function previous() {
		Player.controls.previous();
	}
	function next() {
		Player.controls.next();
	}
	function fullScreen() {
		Player.fullScreen = true;
	}
	function mute(mode) {
		Player.settings.mute = mode;
	}
	function PlayMedia(url) {
		Player.URL = url;
		Player.controls.play();
	}

	function PlayIndex(index, OldPlaylistName) {
		intervalloopcount++;
		if (OldPlaylistName != Player.currentPlaylist.name) {
			media = Player.currentPlaylist.item(Globalindex);
			Player.controls.playItem(media);
			clearInterval(PlayIndexInterval);
	
		}
	}
	/*
	
	*/
	///////////////////////////////////////////////
	//Mediaplayer / Flash injectors -- EOLAS
	/**/

	function Write_Media_Player(videosrc, divname) {
		if (!videosrc) {
			videosrc = "http://ohsama.tv/playlists/videoclip.asx";
		}
		if (-1 != navigator.userAgent.indexOf("MSIE")) {
			document.write('<object id="Player" name="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="" type="application/x-oleobject" align="middle" height="360" width="480">');
			document.write('<param id="Url" name="Url" value="'+videosrc+'">');
			//    <!--<param name="Url" value="">-->')
			document.write('<param name="enableContextMenu" value="false">');
			document.write('<param name="animationatStart" value="false">');
			document.write('<param name="autoStart" value="true">');
			document.write('<param name="stretchToFit" value="true">');
			document.write('<param name="displaysize" value="4">');
			document.write('<param name="mute" value="0">');
			document.write('<param name="bufferingtime" value="3">');
			document.write('<param name="showgotobar" value="0">');
			document.write('<param name="enablefullscreencontrols" value="true">');
			document.write('<param name="showstatusbar" value="false">');
			document.write('<param name="showControls" value="false">');
			document.write('<param name="WindowlessVideo" value="true">');
			document.write('<param name="uimode" value="none">');
			document.write('</object>');
		} else {
			document.write('<OBJECT id="Player" ');//CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
			document.write(' type="application/x-ms-wmp"');
			document.write(' src="'+videosrc+'"');
			document.write(' autostart="true" showControls="false" showstatusbar="false" bgcolor="white" name="Player" ');
			//document.write(' WindowlessVideo=1 ');//this makes it look really bad in Firefox
			document.write(' width="480" height="360"');
			document.write('uiMode="none")');
			document.write('<embed src="'+videosrc+'" ');
			document.write('uiMode="none" mute="0" width="480" height="360" autostart="true" id="Player" showControls="false" showstatusbar="false" bgcolor="white" name="Player"></embed>');
			document.write(' </OBJECT>');

			Player = document.getElementById('Player');
			setTimeout("Player.Play()",500);
		}
		//ChangeVolume(0)
	}
}

	function Flash_updateData() {
		if (BrowserDetect.OS.indexOf("Windows")>-1){
			var d = new Date();
			//document.getElementById("output").innerHTML=Player.URL +" "+ d.getTime()
			if (Player.URL == undefined && BrowserDetect.OS != "Mac") {
				window.location.reload();
			}
			if (Player.URL && Player.URL != "" && Player.URL != undefined) {
				start_index = Player.URL.lastIndexOf("/");
				end_index = Player.URL.lastIndexOf(".");
				playlistname = Player.URL.substring(start_index+1, end_index);
				target = document.getElementById("output");
				count = Player.currentPlaylist.count;
				CurrentMediaURL = Player.currentMedia.sourceURL;
				for (i=0; i<Player.currentPlaylist.count; i++) {
					if (CurrentMediaURL == Player.currentPlaylist.item(i).sourceURL) {
						CurrentIndex = i;
					}
				}
				DataforFlash = new Array(Player.currentMedia.duration, Player.controls.currentPosition, Player.status, playlistname, Player.settings.mute, CurrentIndex);
				thisMovie("controlbar").updateFlashData(DataforFlash);
			}
		}
		else{
			thisMovie("controlbar").updateFlashData(videoReference);
		}
	}



	function PlayPause(playmode) {
		if (BrowserDetect.OS == "Windows") {
			if (playmode == "play") {
				Player.controls.play();
			} else {
				Player.controls.pause();
			}
		}else{
			if (playmode == "play") {
				Player.Play();
			} else {
				Player.Pause();
			}
		}
	}
