<!--
if (location.hash && location.hash.substring(0,4) != "#com") {
	locationArray = location.hash.substring(1).split("-");
	chapter = Number(locationArray[1]);
	video = locationArray[0];
	// startparams = new Array();
	// startparams[video] = new Array();
	if (typeof(chapters[video]) == 'undefined')	{
		startparams[video]["haschapters"] = false;
		startparams[video]["start"] = 0;
		startparams[video]["autostart"] = false;
	} else {
		startparams[video]["haschapters"] = true;
		startparams[video]["start"] = chapters[video][chapter];
		startparams[video]["autostart"] = true;
	}	
}
//start render jwplayer
renderplayer = function(clipfile,clipid,captions,replaceid,skin,startpos,sitevar,image) {
	/**
	---parameters:---
	clipfile: filename (zonder pad) van de flv
	clipid: id van de te schrijven object/embed tag
	captions: optionele TimedText (XML) captions file
	replaceid: id van de te vervangen div
	skin: te gebruiken skin (zonder pad, moet staan in /sites/tvklasse/files/flash)
	startpos: eventuele startpositie
	sitevar: optionele parameter om aan te geven om welke site het gaat, wordt momenteel enkel gebruikt voor breedte/hoogte
	image: optionele parameter voor thumb
	*/
	var div = document.getElementById(replaceid);
	div.innerHTML = "Bezig met inladen...";  
	var clipidArray = clipid.split("-");
	var clipid_base = clipidArray[0]; 
	if (typeof(startparams) == 'undefined') {
		startparams= new Array();		
	}
	if (typeof(startparams[clipid_base]) == 'undefined') {		
		startparams[clipid_base] = new Array();
		startparams[clipid_base]["autostart"] = false;
		startparams[clipid_base]["start"] = 0;
	}    
	div.innerHTML = "Inladen stap 4...";	
	if (typeof(chapters) == 'undefined') {
		startparams[clipid_base]["haschapters"] = false;
	} else if (typeof(chapters[clipid_base]) == 'undefined') {
		startparams[clipid_base]["haschapters"] = false;
	} else {
		startparams[clipid_base]["haschapters"] = true;
	}
	if (sitevar == 'kvo') {
		var width = 480;
		var height = 271;
	} else if (sitevar == 'kvl') {
		var width = 550;
		var height = 309;
	} else {
		var width = 550;
		var height = 309;
	}
	var s1 = new SWFObject('http://www.klasse.be/sites/tvklasse/files/flash/player_4_5.swf',clipid,width,height,'9','#ffffff');
	s1.addParam('allowfullscreen','true');
	s1.addParam('name',clipid);
	s1.addParam('allowscriptaccess','always');
	s1.addParam('wmode','opaque');
	s1.addVariable('bufferlength','5');
	s1.addVariable('dock','true');
	s1.addVariable('controlbar','over');	
	s1.addVariable('streamer', 'lighttpd');
	s1.addVariable('file','http://www.klasse.be/sites/tvklasse/files/movie/'+clipfile);
	if (typeof(startparams) != 'undefined') {
		/* alert('startparams'); */
		s1.addVariable('start', startparams[clipid_base]["start"]);
		s1.addVariable('autostart', startparams[clipid_base]["autostart"]);
	} else if (typeof(startpos) != 'undefined') {
		/* alert('start_pos'); */
		s1.addVariable('start', startpos);
		s1.addVariable('autostart', 'true');
	} else {
		s1.addVariable('start', '0');
		s1.addVariable('autostart', 'false');
	}
	if (skin) {
		//s1.addVariable('skin', 'http://www.klasse.be/sites/tvklasse/files/flash/'+skin);
	}
	if (captions) {
		s1.addVariable('captions', 'http://www.klasse.be/sites/tvklasse/files/movie/'+captions);
		s1.addVariable('plugins', 'captions-1,googlytics-1');
	} else {
		s1.addVariable('plugins', 'googlytics-1');
	}
	if (image) {
		s1.addVariable('image', 'http://www.klasse.be/sites/tvklasse/files/movie/'+image);
	}
	s1.write(replaceid);
}
$(document).ready(function() {
	// begin jwplayer
	var time = null;
	var player = null;
	players = new Array();
	playertimes = new Array();
	var t_tv = 0;
	t_array = [];
	switch (location.hostname) {
		case "www.maks.be":
		case "maks.be":
		case "www.leerlingenkaart.be":
		case "leerlingenkaart.be":
			t_url = "http://www.maks.be/makstv.php?q=makstv/t";
			break;
		default:
			t_url = "http://www.klasse.be/tvklasse/t";
	}
	site = location.pathname;
	site = location.hostname+site;
	timeMonitor = function(obj) {
		var time = obj.position;	
		var baseidarray = obj.id.split("-");
		var baseid = baseidarray[0];
		playertimes[baseid] = time;
		timedivfive = Math.floor(time/5); // elke 5 seconden
		if (t_array.indexOf(timedivfive) == -1) {
			var state = player.getConfig().state;
			t_array.push(timedivfive);
			$.ajax({
				method: "get",
				dataType: "script",
				url: t_url+"/"+baseid+"/"+t_tv+"/"+Math.floor(time)+"/"+state+"/"+site,
				success: function(html) {
					if (html != '') {
						t_tv = html;
					}
				}
			});
			
		}
		if (startparams[baseid]["haschapters"] == true) {
			playertimes[baseid] = time;
			var currentchapter = null;
			chaptersarray = chapters[baseid];
			for (el in chaptersarray) {
				var nextel = Number(el)+1;
				var nexttime = 0;
				if (typeof(chaptersarray[nextel]) == 'undefined') {
					nexttime = chaptersarray[el]+10000;
				} else {
					nexttime = chaptersarray[nextel];
				}
				if (time > 1 && time >= chaptersarray[el] && time < nexttime && currentchapter != el) {
					jumpchapterdisplay(baseid,el);
					currentchapter = el;
				}
			}
		}
	};
	playerReady = function(thePlayer) {
		player = window.document[thePlayer.id];
		players.push(player);				
		player.addModelListener('TIME', 'timeMonitor');
	}
	jumpchapterdisplay = function(clip,chapter) {
		$("#"+clip+"-chapters tr").removeClass("active");
		$("#"+clip+"-chapter"+chapter).addClass("active");	
		location.hash = clip+"-"+chapter;
	}
	jumpchapter = function(clip,chapter){
		position = chapters[clip][chapter];
		var targetplayer = window.document[clip+"-jwplayer"];
		targetplayer.sendEvent('SEEK',position);
		targetplayer.sendEvent('PLAY',1);
		jumpchapterdisplay(clip, chapter);
	}
});
//-->