/***********    onload acties     ***********/
try{addLoadEvent(correctPNG);}catch(e){var asd=e;};
addLoadEvent(stripeTables);
addLoadEvent(highlightRows);
addLoadEvent(fnSetURL);

function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != "function")
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function StartExamenProduct(organisatie, product, mindex)
{
	var sURL = 'startexamen.aspx?organisatieid='+organisatie+'&productid='+product+'&index='+mindex;
	var link='https://www.telecursus.org/portal/' + sURL;
	if(document.all){
		var winwidth=window.screen.availWidth;
		var winheight=window.screen.availHeight;
		var sizer=window.open(link,'Toetsvenster','titlebar=no, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+GetWinWidth()+', height='+GetWinHeight()+', left=0, top=0, fullscreen=no');
		if(sizer==null)
		{
			alert("Er is een fout opgetreden bij het openen van een nieuw window.");
		}
		sizer.location=link;
	}
	else{
		window.location=link;
	}
}

function Show(examen,soort){
	var info = document.getElementById("content").getElementsByTagName("div");
	for(var i=0;i<info.length;i++){
		info[i].style.display = "none"
	}
	document.getElementById(examen).style.display = "block";
	if(arguments.length>1){
		document.getElementById(soort).style.display = "block";
	}
}

function stripeTables() {
	if (!document.getElementsByTagName) return false;
	var tables = document.getElementsByTagName("table");
	for (var i=0; i<tables.length; i++) {
  		if(tables[i].className.indexOf("zebra")>=0){
    		var odd = false;
    		var rows = tables[i].getElementsByTagName("tr");
    		for (var j=0; j<rows.length; j++) {
      		if (odd == true) {
        			addClass(rows[j],"odd");
        			odd = false;
      		} else {
        			odd = true;
      		}
    		}
		}
	}
}

function highlightRows() {
	if(!document.getElementsByTagName) return false;
	var rows = document.getElementsByTagName("tr");
	for (var i=0; i<rows.length; i++) {
		if(rows[i].parentNode.parentNode.getAttribute("id")&&rows[i].parentNode.parentNode.getAttribute("id").indexOf("examenoverzicht")>=0){
			rows[i].oldClassName = rows[i].className
			rows[i].onmouseover = function() {
				addClass(this,"highlight");
			}
			rows[i].onmouseout = function() {
				this.className = this.oldClassName
			}
		}
	}
}

function addClass(element,value) {
	if (!element.className) {
		element.className = value;
	} else {
		newClassName = element.className;
		newClassName+= " ";
		newClassName+= value;
		element.className = newClassName;
	}
}

function GetWinWidth(){
	return window.screen.availWidth-4;
}

function GetWinHeight(){
	if(navigator.userAgent.indexOf('NT 5.1')>0){
		return window.screen.availHeight-61;
	}
	else{
		return window.screen.availHeight-51;
	}
}

function urlCheck(){
	//return false;
    var asd = "asd";
}

function fnSetURL(){
	var url = window.location.toString();
	if(url.indexOf("?NoExam")<0){
		urlCheck = StartExamenProduct;
	}else{
		if(document.getElementById("examenoverzicht")){
			var rijen = document.getElementById("examenoverzicht").getElementsByTagName("tr");
			for(var i=0;i<rijen.length;i++){
				var linkje = rijen[i].getElementsByTagName("td")[0].getElementsByTagName("a")[0];
				linkje.style.cursor = "default";
			}
		}
	}
}

