// Print functie (haalt bepaalde TD uit de maintable en gooit deze in een popup)
function printPage(template) {

	//niet printen in admindeel
	if (/\/admin\//.test(document.location)) {
		alert('Printen is niet mogelijk binnen de PageProcessor admin omgeving');
		return false;
	}

	if (template == 'vv')
		var print1 = document.getElementById('vvLinks_0_0').innerHTML;
		var print2 = document.getElementById('vvMidden_0_1').innerHTML;

	window.printgedeelte = '<table><tr><td valign=top>'+print1+'</td><td valign=top>'+print2+'</td></tr></table>';

	//disable de links om bladeren via printversie te voorkomen
	window.printgedeelte = window.printgedeelte.replace(/href/gi,"hrefdisabled");
	window.printgedeelte = window.printgedeelte.replace(/onclick/gi,"onclickdisabled");
 
	//open popup en vul deze 
	var w =  window.open('/print.html');
}


function displaySubmenu(el) {
	var nav = document.getElementById('navigatie');
	if (typeof nav == "object") {
		
		//zet alle submenus op hidden
		var allsubmenus = nodes.childNodesBy(nav,'className=subnav',true);
		if (typeof allsubmenus == "object") {
			for (var i in allsubmenus) {
				if (typeof allsubmenus[i] == "object")
					allsubmenus[i].style.display = 'none';
			}
		}
		
		//zet alle tabs op inactief
		var ultabs = nodes.childNodesBy(nav,'className=tabs',true);
		for (var i = 0; i < ultabs[0].childNodes.length; i++) {
			if (ultabs[0].childNodes[i].tagName == 'LI')
				ultabs[0].childNodes[i].className = '';
		}
		
		//toon het juiste submenu
		if (typeof el == "object") {
			var parent = nodes.parentNodeBy(el,'tagName=LI',true);
			if (parent) {
				parent.className = 'active';
				var activesubmenu = nodes.childNodesBy(el.parentNode,'className=subnav',true);
				if (activesubmenu !== '' && typeof activesubmenu[0] == "object") {
					if (activesubmenu[0])
						activesubmenu[0].style.display = 'block';
				}
			}
		}
	}
}

function getActiveSubmenu() {
	var nav = document.getElementById('navigatie');
	if (typeof nav == "object") {
		var alltabs = nodes.childNodesBy(nav,'className=tabs',true);
		if (typeof alltabs[0] == "object") {
			for (var i = 0; i < alltabs[0].childNodes.length; i++) {
				if (alltabs[0].childNodes[i].className == 'active') {
					var atags = nodes.childNodesBy(alltabs[0].childNodes[i],'tagName=A',true);
					if (typeof atags == "object")
						displaySubmenu(atags[0]);
				}
			}
		}
	}
}

// roep functie uit clientjs/styleswitcher.js aan
function initTools() {
	var cookie = readCookie("style");
	var cookie2 = readCookie("color");
	var title = cookie ? cookie : getPreferredStyleSheet();
	var color = cookie2 ? cookie2 : false;
	setActiveStyleSheet(title);
	setActiveStyleSheetColor(color);
}

function initAll() {
	getActiveSubmenu();
	initTools();
}