var in_Punt= Array();
var out_Punt= Array();
var length_Punt= Array();

function whichOne(){ 	//	from the slider to the list of spekers or subjects 
 if(!ankers)return false;
	for (var i=0; i< ankers.length;i++){	
	in_Punt[i] = eval(ankers[i])[1];
	out_Punt[i] = eval(ankers[i])[2];
	length_Punt[i] = (out_Punt[i] - in_Punt[i]);
}
}

function fragDuration(Movtijd){			//		change the timestamp to 00:00:00 	
		var	Sec = Movtijd/600;
		Sec=Math.floor(Sec)
		var	minn= Sec/60
		h= Sec/3600
		minn=((minn < 1) ? "00" : Math.floor(minn));
		var	Sec=Sec-(minn*60)
		Sec=((Sec < 10) ? ":0" : ":")+Sec		
		tijd="["+minn+Sec+"]";
		return tijd;
}

	var	old_anker = null ;
function passToOther(cur_Time){ //		control from the video to anchor links 
	for (var i=0; i< ankers.length; i++){
		if (cur_Time >= in_Punt[i] && cur_Time <= out_Punt[i]){
			if (old_anker != ankers[i]){
			changeClass('list_Deelnemers');
			document.getElementById(ankers[i]).className = "linkr";
			writeLinksAnkers(ankers[i]);
  			old_anker = ankers[i];
    		}
		}
	}
}


function writeAnkers(){ 	//			Read and write a list of deelnemers
	whichOne();
var container = document.getElementById("list_Deelnemers");
	for (var i=0; i< ankers.length;i++){
	var arr = eval (ankers[i]);
//	var arrr = eval (ankers[i]);
	var oLi= document.createElement("li");
	var oA= document.createElement("a");
		oA.setAttribute("class","linkg");
		oA.setAttribute("id", ankers[i]);
		oLi.appendChild(oA);
	var oText= document.createTextNode(arr[0]+" ");
	var oText1= document.createTextNode(fragDuration(length_Punt[i]));
	oA.appendChild(oText);
	oLi.appendChild(oText1);
	container.appendChild(oLi);
	eventHandler();	
	}	
}

function eventHandler(){
	var container = document.getElementById("list_Deelnemers");	//	ul id's 
	var	oA = container.getElementsByTagName("a");
		for (var i=0; i< oA.length;i++){	
			oA[i].onclick= function(){
					changeClass('list_Deelnemers');
					var anker =eval(this.getAttribute('id'));
					this.className = "linkr";
					settijdTo(eval(anker[1]));
					writeLinksAnkers(this.getAttribute('id'));
					var alLinks = "alleLinks";
					setTimeout("M_changeVisible('"+alLinks+"')",500);
									}
				} 
}

function writeLinksAnkers(ank){	//	write the related links to spekers or subjects in links box
	var ankerName = eval(ank);
	var contain = document.getElementById('linkIntern');
	var containE = document.getElementById('linkExtern');
	contain.innerHTML = "";
	containE.innerHTML = "";
	var oLi= document.createElement("li");
	var oAp= document.createElement("a");
	oAp.setAttribute("class","linkg");
	oAp.setAttribute("href","#");
	oLi.appendChild(oAp);
	var oText= document.createTextNode(ankerName[3]);
	oAp.appendChild(oText);
	contain.appendChild(oLi);
	oAp.onclick = function(){this.className = "linkr";InsertedLink("extern",ankerName[4]);setTimeout('window.focus()',3000);}
	
	var oLi= document.createElement("li");					
	var oAi= document.createElement("a");
	oAi.setAttribute("class","linkg");
	oAi.setAttribute("href","#");
	oLi.appendChild(oAi);
	var oText= document.createTextNode(ankerName[5]);
	oAi.appendChild(oText);
	contain.appendChild(oLi);
	oAi.onclick = function(){this.className = "linkr";InsertedLink("extern",ankerName[6]);setTimeout('window.focus()',3000);}

	var oLi= document.createElement("li");	//	write externe link				
	var oAi= document.createElement("a");
	oAi.setAttribute("class","linkg");
	oAi.setAttribute("href","#");
	oLi.appendChild(oAi);
	var oText= document.createTextNode(ankerName[7]);
	oAi.appendChild(oText);
	containE.appendChild(oLi);	
	oAi.onclick = function(){this.className = "linkr";InsertedLink("intern",ankerName[8]);setTimeout('window.focus()',3000);}
}

function InsertedLink(name,L){
var interneUrl=L;
var newVenster = name;
newVnster=window.open(interneUrl,name,'toolbar=yes,location=yes,menubar=no,scrollbars=yes,resizable=yes,width=780,height=575'); 
setTimeout('newVnster.focus()',500);return false;
}


function M_changeVisible(ob) {	//	take care of behavior of link and movie list groep
	var alleLinks = document.getElementById("alleLinks").style.visibility ="hidden";
	var allemovies = document.getElementById("alleMovies").style.visibility ="hidden";
	var obj = document.getElementById(ob).style.visibility ="visible";
	if (ob == "alleLinks"){
	document.getElementById('geLinks').className = "linkr";
	document.getElementById('geMovies').className = "linkg";
				}else{
	document.getElementById('geLinks').className = "linkg";
	document.getElementById('geMovies').className = "linkr";		
				}	
}



function changeClass(tar){
	var container = document.getElementById(tar);
	var oA = container.getElementsByTagName("a");

	for (var i=0; i< oA.length;i++){
	oA[i].className = "linkg";

	}
}



