/***********    onload acties     ***********/
addLoadEvent(correctPNG);
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;
}
 
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";
			}
		}
	}
}


function OneStat_Pageview()
{
    var d=document;
    var sid="447453";
    var CONTENTSECTION="";
    var osp_URL=d.URL;
    var osp_Title=d.title;
    var t=new Date();
    var p="http"+(d.URL.indexOf('https:')==0?'s':'')+"://stat.onestat.com/stat.aspx?tagver=2&sid="+sid;
    p+="&url="+escape(osp_URL);
    p+="&ti="+escape(osp_Title);
    p+="&section="+escape(CONTENTSECTION);
    p+="&rf="+escape(parent==self?document.referrer:top.document.referrer);
    p+="&tz="+escape(t.getTimezoneOffset());
    p+="&ch="+escape(t.getHours());
    p+="&js=1";
    p+="&ul="+escape(navigator.appName=="Netscape"?navigator.language:navigator.userLanguage);
    if(osp_URL!=d.URL) p+="&ol="+escape(d.URL);
    if(typeof(screen)=="object"){
       p+="&sr="+screen.width+"x"+screen.height;p+="&cd="+screen.colorDepth;
       p+="&jo="+(navigator.javaEnabled()?"Yes":"No");
    }
    d.write('<img id="ONESTAT_TAG" border="0" width="1" height="1" src="'+p+'" >');
}

//OneStat_Pageview();

