addEvent(window, "load", activateNavigation);
// 2005-05-11 mwp removed from load. Html will be shown with all the questions closed
//addEvent(window, "load", closeAllQuestions);

function activateNavigation() {
	var ul = document.getElementById("mainnavigation");
	if(!ul) return;
	var lis = ul.getElementsByTagName("li");
	for (var i=0; i < lis.length; i++) {
		if (lis[i].parentNode == ul) {
			if (lis[i].className == "selected") lis[i].persistent = true;
			lis[i].submenu = lis[i].getElementsByTagName("ul")[0];
			lis[i].onmouseover = openMenu;
			lis[i].onmouseout = closeMenu;
			if (document.all) {
				lis[i].iframe = addIFRAME(lis[i], lis[i].submenu);
			}
		}
	}
}

function openMenu(e) {
	if (this.className == "selected" && !this.persistent) return;
	this.submenu.className = "visible";
	if (document.all) this.iframe.className = "visible";
	this.className = "selected";
	if (e) e.cancelBubble = true; else window.event.cancelBubble = true;
}
function closeMenu(e) {
	if (e) var dest = e.relatedTarget; else var dest = window.event.toElement;
	if (!isChild(this, dest)) {
		this.submenu.className = "";
		if (document.all) this.iframe.className = "";
		if (!this.persistent) this.className = "";
	}
	if (e) e.cancelBubble = true; else window.event.cancelBubble = true;
}
function isChild(ancestor, candidate) {
	while (candidate && candidate != ancestor.parentNode) {
		if (candidate == ancestor) return true;
		candidate = candidate.parentNode;
	}
	return false;
}
function addIFRAME(container, contents) {
	contents.className = "visible";
	var newNode = document.createElement("iframe");
	newNode.style.width = contents.offsetWidth+"px";
	newNode.style.height = contents.offsetHeight+"px";
	contents.className = "";
	return container.insertBefore(newNode, contents);
}
function addEvent(receiver, eventName, listener){ 
	if (receiver.addEventListener) {
		receiver.addEventListener(eventName, listener, true); 
	} else if (receiver.attachEvent) {
		receiver.attachEvent("on"+eventName, listener);
	}
}





/* FAQ PAGE */

var maxQuestions=64;

function closeAllQuestions(){
	for(var i=1; i<maxQuestions; i++) closeQuestion(i);
}
function clickQuestion(id){
	var e = document.getElementById("question"+id);
	if(e.className == "question_open")
		closeQuestion(id);
	else
		openQuestion(id);
}
function closeQuestion(id){
	var e = document.getElementById("question"+id);
	if(e) e.className="question_closed";
	e = document.getElementById("answer"+id);
	if(e) e.style.display="none";
}
function openQuestion(id){
	var e = document.getElementById("question"+id);
	if(e) e.className="question_open";
	e = document.getElementById("answer"+id);
	if(e) e.style.display="block";

	//for(var i=1; i<maxQuestions; i++){
		//if(i!=id)  closeQuestion(i);
	//}
}



