        function updateHTML(elmId, value) {
          document.getElementById(elmId).innerHTML = value;
        }
				
				function updateTimeLine(){
					currTime = getCurrentTime();
					totTime = getDuration();
					percentTime = currTime/totTime;
					marginTime = percentTime * 200;
					document.getElementById("videoControlsTimeLineBtn").style.paddingLeft = marginTime + "px";
				}

        function setytplayerState(newState) {
          updateHTML("playerstate", newState);
        }
				
				function onYouTubePlayerReady(playerId) {
          ytplayer = document.getElementById("rodaytplayer");
          setInterval(updateytplayerInfo, 250);
          updateytplayerInfo();
          ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
					loadFirstVideo("0");
        }

        function onytplayerStateChange(newState) {
          //setytplayerState(newState);
					//Als player stopt
					if(newState == "0"){
						playpause = document.getElementById("videoControlsPlay");
						playpause.innerHTML = "<a href='javascript:void(0)' onclick='play();'><img src='/images/videomodule_playBtn.png' /></a>"
					}
					//Als player speelt
					if(newState == "1"){
						playpause = document.getElementById("videoControlsPlay");
						playpause.innerHTML = "<a href='javascript:void(0)' onclick='pause();'><img src='/images/videomodule_pauseBtn.png' /></a>"
					}
					//Als player pauseert
					if(newState == "2"){
						playpause = document.getElementById("videoControlsPlay");
						playpause.innerHTML = "<a href='javascript:void(0)' onclick='play();'><img src='/images/videomodule_playBtn.png' /></a>"
					}
        }

        function updateytplayerInfo() {
          //updateHTML("bytesloaded", getBytesLoaded());
          //updateHTML("bytestotal", getBytesTotal());
          //updateHTML("videoduration", getDuration());
          //updateHTML("videotime", getCurrentTime());
          //updateHTML("startbytes", getStartBytes());
          //updateHTML("volume", getVolume());
					updateTimeLine();
        }
				
				function regExpReplacer(str){
					var regExp=/\r|\n|\r\n/gi;
					return str.replace(regExp, '<br />\n')
				}
				
				function loadFirstVideo(num, catSrc){
					//loadNewVideo("K_9RIZG17z4", "0");
					//firstvideo = document.getElementById("ytPlayerInfoVideoID").innerHTML;
					if(catSrc == "0"){
						htmlID = "ytVid";
					} else if(catSrc == "1") {
						htmlID = "ytCats1Vid";
					} else if(catSrc == "2") {
						htmlID = "ytCats2Vid";
					} else if(catSrc == "3") {
						htmlID = "ytCats3Vid";
					} else {
						htmlID = "ytVid";
					}
					firstvideo = document.getElementById(htmlID+num+"URL").innerHTML;
					firstvideoTitle = document.getElementById(htmlID+num+"Title").innerHTML;
					firstvideoRating = document.getElementById(htmlID+num+"Rating").innerHTML;
					firstvideoTime = document.getElementById(htmlID+num+"Time").innerHTML;
					firstvideoDesc = document.getElementById(htmlID+num+"Desc").innerHTML;
					//var regExp=/\n/gi;
					var regExp=/\r|\n|\r\n/gi;
					firstvideoDesc = firstvideoDesc.replace(regExp,"<br />");
					//document.getElementById("videoDataContent").getElementsByTagName("h3")[0].innerHTML = firstvideoTitle;
					document.getElementById("videoDataContent").innerHTML = "<h3>"+firstvideoTitle+"</h3>"+firstvideoDesc+"<div id='videoDataContentRating'><a href='javascript:void(0)' onclick=\"tb_show('', '/modules/ytvideo/rating.asp?v="+firstvideo+"&KeepThis=true&TB_iframe=true&height=295&width=373&modal=true')\">stemmen</a>:&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onclick=\"tb_show('', '/modules/ytvideo/rating.asp?v="+firstvideo+"&KeepThis=true&TB_iframe=true&height=295&width=373&modal=true')\">"+firstvideoRating+"</a></div>"
					//document.getElementById("videoDataContentRating").innerHTML = "stemmen:&nbsp;&nbsp;&nbsp;" + firstvideoRating;
					loadNewVideo(firstvideo, "0");
				}

        // functions for the api calls
        function loadNewVideo(id, startSeconds) {
          if (ytplayer) {
            ytplayer.loadVideoById(id, startSeconds);
          }
        }

        function cueNewVideo(id, startSeconds) {
          if (ytplayer) {
            ytplayer.cueVideoById(id, startSeconds);
          }
        }

        function play() {
          if (ytplayer) {
            ytplayer.playVideo();
          }
        }

        function pause() {
          if (ytplayer) {
            ytplayer.pauseVideo();
          }
        }

        function stop() {
          if (ytplayer) {
            ytplayer.stopVideo();
          }
        }

        function getPlayerState() {
          if (ytplayer) {
            return ytplayer.getPlayerState();
          }
        }

        function seekTo(seconds) {
          if (ytplayer) {
            ytplayer.seekTo(seconds, true);
          }
        }

        function getBytesLoaded() {
          if (ytplayer) {
            return ytplayer.getVideoBytesLoaded();
          }
        }

        function getBytesTotal() {
          if (ytplayer) {
            return ytplayer.getVideoBytesTotal();
          }
        }

        function getCurrentTime() {
          if (ytplayer) {
            return ytplayer.getCurrentTime();
          }
        }

        function getDuration() {
          if (ytplayer) {
            return ytplayer.getDuration();
          }
        }

        function getStartBytes() {
          if (ytplayer) {
            return ytplayer.getVideoStartBytes();
          }
        }

        function mute() {
          if (ytplayer) {
            ytplayer.mute();
          }
        }

        function unMute() {
          if (ytplayer) {
            ytplayer.unMute();
          }
        }
        
        function getEmbedCode() {
          alert(ytplayer.getVideoEmbedCode());
        }

        function getVideoUrl() {
          alert(ytplayer.getVideoUrl());
        }
        
        function setVolume(newVolume) {
          if (ytplayer) {
            ytplayer.setVolume(newVolume);
          }
        }

        function getVolume() {
          if (ytplayer) {
            return ytplayer.getVolume();
          }
        }

        function clearVideo() {
          if (ytplayer) {
            ytplayer.clearVideo();
          }
        }
				
//Playlist scrollable maken met jQuery
$(document).ready(function() {             
 
 		//playlist scrollbaar maken
    $("div#videoModule").scrollable({

			items:'div#tblVideos',
			size:4,
			/*  
					default selector for nested element that will have  
					"move backwards" action automatically bind to it 
			*/ 
			prev:'a.tblVideosScrollUp',        
			// default selector for "move onwards" action 
			next:'a.tblVideosScrollDown'
		
		});   
		
 		//Wedstrijdenplaylist scrollbaar maken
    $("div#catsListWrapper1").scrollable({

			items:'div#tblCatsVideos_1',
			size:3,
			/*  
					default selector for nested element that will have  
					"move backwards" action automatically bind to it 
			*/ 
			prev:'a.videoCatsListScrollUp_1',        
			// default selector for "move onwards" action 
			next:'a.videoCatsListScrollDown_1'
		
		});  
		
 		//Rapportageplaylist scrollbaar maken
    $("div#catsListWrapper2").scrollable({

			items:'div#tblCatsVideos_2',
			size:3,
			  
//					default selector for nested element that will have  
//					"move backwards" action automatically bind to it 
//			 
			prev:'a.videoCatsListScrollUp_2',        
			// default selector for "move onwards" action 
			next:'a.videoCatsListScrollDown_2'
		
		});  
		
 		//Wedstrijdenplaylist scrollbaar maken
    $("div#catsListWrapper3").scrollable({

			items:'div#tblCatsVideos_3',
			size:3,
			/*  
					default selector for nested element that will have  
					"move backwards" action automatically bind to it 
			*/ 
			prev:'a.videoCatsListScrollUp_3',        
			// default selector for "move onwards" action 
			next:'a.videoCatsListScrollDown_3'
		
		});  
		
		
		//Links van nieuwe playlists opvangen en aan iframe doorsturen
		$("a[rel='flvplayer']").click(function(){
			$("iframe#flvPlayerFrame").attr("src", this.href);
			return false;
		});
 
 
});
        
