$(document).ready(function(){	
	initMainContentClick();
  showHeaderBar();
});


// FAQ foldout structure and open/close functionality.
function showSubSiteMenu(objA) {
	if (objA.parentNode.getElementsByTagName("ul")[0] == null) return;
	
	var currentFold = objA.parentNode.getElementsByTagName("ul")[0];
	var	allFolds = currentFold.getElementsByTagName("ul");
		
	if (currentFold.style.display == "none" || currentFold.style.display == "")	{
		currentFold.style.display = "block";	
		
		checkSubSiteMenuIcons(objA);	
		objA.className = "active";
	} else {
		currentFold.style.display = "none";		
		objA.className = "";	
		for (var i=0; i<allFolds.length; i++) {
			allFolds[i].style.display = "none";
			allFolds[i].className = "";
			checkSubSiteMenuIcons(objA);
		}
	}
}

function initMainContentClick(){
	/* Functie voor de "Lees verder" functionaliteit van de hoofd content */
	$(".content_click_detail").click(function(){
		$(this).hide();        	        	
		$(this).nextAll(".hidden_detail:first").show();    
		});
};

// Check to see whether FAQ items have subitems, and assign icons accordingly.
// Also, make sure that, when a main item and subitems have been closed, the icons are reset.
function checkSubSiteMenuIcons(objA) {
	var allFolds = objA.parentNode.getElementsByTagName("ul");
	
	if(allFolds) {
		for (var f = 0; f < allFolds.length; f++) {				
			var listItems = allFolds[f].getElementsByTagName("li");
						
			for (var i = 0; i < listItems.length; i++) {
				if(listItems[i].getElementsByTagName("ul").length == 0) {
					if(listItems[i].getElementsByTagName("a")[0]) listItems[i].getElementsByTagName("a")[0].className = "active";
				} else {
					if(listItems[i].getElementsByTagName("a")[0]) listItems[i].getElementsByTagName("a")[0].className = "";
				}
			}
		}
	}	
}

// Het pop-up scherm ten behoeven van de Sitemap
function pop_me_up(title,link){
	window.open(link
             ,'title'
             ,'width=600,height=800,top=100,left=100,scrollbars=yes,toolbar=no,titlebar=no,location=no,menubar=no,status=no'
             );			   
}


function showHeaderBar() {
  if ($('td.header').length > 0) {
    $('#headerbar').show();
    $('#clear').show();
  } else {
    $('#headerbar').hide();
    $('#clear').hide();    
  }
}
