/*
Navigatie Script, voor Internetexplorer 4.0 en Netscape 4.0 en hoger
Geschreven door: Jesse Houwing
*/

function writeFirst(){
	document.writeln("<select name=\"vaklist\" style=\"width: 150px;\" size=\"1\" onChange=\"Adjust();\">");
	document.writeln("<option value=\"\" selected>Kies vak...</option>");

	for (i=0; i< list.length; i++){
		tempVak=list[i];
		document.writeln("<option value=\""+tempVak[1]+"\" style=\"width: 150;\">"+tempVak[0]+"</option>");
	}
	document.writeln("</select>");
}

function printNowPDF( obj )
{
	obj.printWithDialog();
}

function printNowHTML( obj )
{
	obj.focus();
	obj.print();
}

function printNow(){
	// Adapted: Now use Adobe Reader to print

	if ((navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.substring(0,3)) >= 	4.0) | (navigator.appName == "Netscape" && navigator.appVersion.substring(0,3) >= 4.6)){

		// Get document object
		wndObj = parent.text;
		docObj = wndObj.document;

		// Test how to get object
		if ( ! docObj.getElementById )
		{
			// Try to get item
			obj = docObj.getElementById("objPdf");

			// Test object
			if ( obj )
			{
				// Is PDF, print as PDF
				printNowPDF( obj );
			} else {
				// Is normal HTML
				printNowHTML( wndObj );
			}
		} else {
			// Try to get item
			obj = docObj.all["objPdf"];

			// Test object
			if ( obj )
			{
				// Is PDF, print as PDF
				printNowPDF( obj );
			} else {
				// Is normal HTML
				printNowHTML( wndObj );
			}
		}


		parent.select_frame.parent.text.focus();
		//parent.select_frame.parent.text.print();
	}
	else{
		window.alert("Dit werkt niet met oudere browsers!");
	}
}

function getbyVak(vak){
	VakArray=new Array(new Option ("Jaargang...", "", true, true));
	VakTemp1=new Array();
	VakTemp2=new Array(1);
	for (i=0; i<list.length; i++){
		VakTemp1=list[i];
		if (VakTemp1[1]==vak){
			for (j=3; j<VakTemp1.length; j++){
				VakTemp2[0]=new Option ((VakTemp1[j].substring(0,4) +" - "+ VakTemp1[j].substring(4,5)), VakTemp1[j], false);
				VakArray=VakArray.concat(VakTemp2);
			}
		}
	}
	return VakArray;
}

function setYearx(yearx){
	if (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1)<5){
		while (document.layerx.document.vak.yearlist.options[0] != null){
			document.layerx.document.vak.yearlist.options[0]=null;
		}
	
		history.go(0);
	
		for (i=0;i<yearx.length;i++){
			document.layerx.document.vak.yearlist.options[i]=yearx[i];
		}
	}else{
		while (document.vak.yearlist.options[0] != null){
			document.vak.yearlist.options[0]=null;
		}

		for (i=0;i<yearx.length;i++){
			document.vak.yearlist.options[i]=yearx[i];
		}
	}
}

function setVakx(vakx){
	if (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1)<5){
		while (document.layerx.document.vak.vaklist.options[0] != null){
			document.layerx.document.vak.vaklist.options[0]=null;
		}
	
		history.go(0);
	
		for (i=0;i<vakx.length;i++){
			document.layerx.document.vak.vaklist.options[i]=vakx[i];
		}
	}else{
		while (document.vak.vaklist.options[0] != null){
			document.vak.vaklist.options[0]=null;
		}
		for (i=0;i<vakx.length;i++){
			document.vak.vaklist.options[i]=vakx[i];
		}
	}
}

function setAll(){
	tempVak=new Array(1);
	tempVak2=new Array();

	for (i=0; i< list.length; i++){
		tempVak=list[i];	
		tempVak2[0]=new Option (""+tempVak[0], ""+tempVak[1], false);
		returnVak=returnVak.concat(tempVak2);
	}
	setVakx(returnVak);
	
	setYearx(returnYear);
}

function Adjust(){
	if (navigator.appName == "Netscape" && (1*navigator.appVersion.substring(0,1))<5){
		if (document.layerx.document.vak.vaklist.selectedIndex > 0){
			curvak=document.layerx.document.vak.vaklist.options[document.layerx.document.vak.vaklist.selectedIndex].value;
		}else{
		    curvak="";
			parent.select_frame.parent.text.location.replace("../../common/html/start.html");
			parent.select_frame.location.replace("../../common/html/select.html");

  			while (document.layerx.document.vak.yearlist.options[0] != null){
  				document.layerx.document.vak.yearlist.options[0]=null;
	  		}
    	}
	}else{
		if (document.vak.vaklist.selectedIndex > 0){
			curvak=document.vak.vaklist.options[document.vak.vaklist.selectedIndex].value;
		}else{
		    curvak="";
			parent.select_frame.parent.text.location.replace("../../common/html/start.html");
			parent.select_frame.location.replace("../../common/html/select.html");

   			while (document.vak.yearlist.options[0] != null){
  				document.vak.yearlist.options[0]=null;
		  	}
	    }
	}
  	if (curvak != ""){
  		setYearx(getbyVak(curvak));
		parent.select_frame.parent.text.location.replace("../../common/html/nieuw.html");
		parent.select_frame.location.replace("../../common/html/select.html");
  	}
}

function Nav(){
	VakTemp1=new Array();
	if (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1)<5){
		if (document.layerx.document.vak.vaklist.selectedIndex > 0 && document.layerx.document.vak.yearlist.selectedIndex > 0){
			curvak=document.layerx.document.vak.vaklist.options[document.layerx.document.vak.vaklist.selectedIndex].value;
			curyear=document.layerx.document.vak.yearlist.options[document.layerx.document.vak.yearlist.selectedIndex].value;
		}else{
			curvak="";
			curyear="";
		}
	}else{
		if (document.vak.vaklist.selectedIndex > 0 && document.vak.yearlist.selectedIndex > 0){
			curvak=document.vak.vaklist.options[document.vak.vaklist.selectedIndex].value;	
			curyear=document.vak.yearlist.options[document.vak.yearlist.selectedIndex].value;
		}else{
			curvak="";
			curyear="";
		}
	}

	if (curvak=="" || curyear==""){
		window.alert("Maak eerst een selectie!");
	}
	else{
		for (i=0; i<list.length; i++){
			VakTemp1=list[i];
			if (VakTemp1[1]==curvak){
				parent.select_frame.parent.text.location.replace("../../"+afdeling +"/"+ curyear.substring(0,4) +"/"+ curyear.substring(4,5) +"/"+ VakTemp1[1] +"/"+ afdeling + curyear.substring(3,5) + VakTemp1[1] +"i01.html");
				parent.select_frame.location.replace("../../"+afdeling +"/"+ curyear.substring(0,4) +"/"+ curyear.substring(4,5) +"/"+ VakTemp1[1] +"/"+ afdeling + curyear.substring(3,5) + VakTemp1[1] +"n01.html");
			}
		}
	}
}


