


// function pCardLayout switches between divs by hiding (display:none) the last active div  and showing the activated one (display:block)
// it uses the anchors that call the function as reference to the divs that need to be hidden or activated
var pHolder; 				// pHolder stores the active reference (anchor) 
var pCount = 0;				// the function uses count to check if it's the first time the function, because in initialy there is no reference yet
var pElementId;				// pElementId gets the attribute 'pref' from the anchors (current(pHolder) and new(pThis) anchor) which is used as reference to the div  

function pCardLayout(pThis) {  //pThis is the anchor that's clicked, it's used as reference
	
	if(pCount == 0) { //checks if it's not the first time the function is called. If it's the first time pHolder still has to be initialized.
		pHolder = document.getElementById('aNieuws'); //set the pHolder to Nieuws (which is the activated div)
		pCount++; // up the count to 1, so that this bracket is never called again
 	}
	if(pHolder != pThis) { // this statement checks wether the clicked anchor's reference div is already active or not, if it's active there's no need for change.
		
		pElementId = pHolder.firstChild.innerHTML; //retrieves the reference from the current(active) div

		document.getElementById(pElementId).style.display = 'none'; //deactivates (hides) the current div
		
		pElementId = pThis.firstChild.innerHTML; //retrieves the reference from the clicked anchor (which references to the to be activated div)

		document.getElementById(pElementId).style.display = 'block'; // activates the div which the anchor refered to
		pHolder = pThis; //sets pHolder to the current (activated) div
	}
}


var thisHolder;
var count = 0
var folded = 1
function newsBoxes(boxHeader) {
	if(count == 0) {
		thisHolder = boxHeader
		count++	
	}
	if(folded == 0) {
		var allNewsItems = new Array()
		allNewsItems = getElementsByClass('boxHeader')
	
		for(uac = 0; uac < allNewsItems.length; uac++) {
			allNewsItems[uac].parentNode.style.height = '26px'
			allNewsItems[uac].firstChild.innerHTML = "C"
	}
	folded = 1
	}
	else if(thisHolder != boxHeader) {
		thisHolder.parentNode.style.height = '26px'
		thisHolder.parentNode.style.border = '0px'
		thisHolder.parentNode.style.backgroundColor = 'transparent'
		thisHolder.firstChild.innerHTML = "C"

	}
	
	
	if(boxHeader.firstChild.innerHTML == 'C') {
	 boxHeader.parentNode.style.height = 'auto'
	 boxHeader.parentNode.style.border = 'solid #070ea0 4px'
	 boxHeader.parentNode.style.backgroundColor = '#fef9f5'
	 boxHeader.firstChild.innerHTML = "O"
 	}
	else {
	 boxHeader.parentNode.style.height = '26px'
	 boxHeader.parentNode.style.border = '0px'
	 boxHeader.parentNode.style.backgroundColor = 'transparent'
	 boxHeader.firstChild.innerHTML = "C"
	}
	thisHolder = boxHeader
}


function unfoldAll() {
	var allNewsItems = new Array()
	allNewsItems = getElementsByClass('boxHeader')
	
	for(uac = 0; uac < allNewsItems.length; uac++) {
		allNewsItems[uac].parentNode.style.height = 'auto'
		allNewsItems[uac].firstChild.innerHTML = "O"
	}
	folded = 0
}

function foldAll() {
	var allNewsItems = new Array()
	allNewsItems = getElementsByClass('boxHeader')
	
	for(uac = 0; uac < allNewsItems.length; uac++) {
		allNewsItems[uac].parentNode.style.height = '26px'
		allNewsItems[uac].firstChild.innerHTML = "C"
	}
	folded = 1
}
	


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

		