addLoadEvent(collapseMenu);
addLoadEvent(prepareMenu);

function collapseMenu(node) {
 if (!document.getElementById) return false;
 if (!document.getElementById("menu")) return false;
 if (!node) node = document.getElementById("menu");

 if (node.childNodes.length > 0) {
  for (var i=0; i<node.childNodes.length; i++) {
   var child = node.childNodes[i];
   if (child.nodeName == "UL") {
    child.style.display = "none";
   }

   collapseMenu(child);
  }		
 }
}

function prepareMenu() {
 if (!document.getElementById || !document.getElementsByTagName) return false;
 if (!document.getElementById("menu")) return false;
 if (!menu.getElementsByTagName("a")) return false;

var links = document.getElementById("menu").getElementsByTagName("a");
 for (var i=0; i<links.length; i++) {	
  links[i].onclick = function() {
   toggleMenu(this.parentNode.getElementsByTagName("UL")[0], this.href);
   return false;
  }
 }
}

function toggleMenu(node, link) {
	if (!document.getElementById) return false;
	if (!link) return false;
	if (!node) location.href = link.href;

	// Collapse all nodes, and only show clicked node (when clicking top level of menu)
	if (node.parentNode.parentNode.id == "menu") {
		hideTopLevels();
	}

	if (node.style.display == "") {
	 Effect.BlindUp(node, {duration: 0.2});
	} else {
	 Effect.BlindDown(node, {duration: 0.2});
	}
}

function addLoadEvent(func) {
 var oldonload = window.onload;
 if (typeof window.onload != 'function') {
  window.onload = func;
 } else {
  window.onload = function() {
   oldonload();
   func();
  }
 }
}

function hideTopLevels() {
 if (!document.getElementById) return false;
 if (!(node = document.getElementById("menu"))) return false;

 if (node.childNodes.length > 0) {
  for (var i=0; i<node.childNodes.length; i++) {
   var child = node.childNodes[i];
   for(var j=0; j<child.childNodes.length; j++) {
    var grandchild = child.childNodes[j];
    if (grandchild.nodeName == "UL") {
     if (grandchild.style.display == '') {
      Effect.BlindUp(grandchild, {duration: 0.2});
     }
    }
   }
  }		
 }
}

// <![CDATA[
  Effect.SlideUpAndDown = function(element) {
  element = $(element);
  if(Element.visible(element)) new Effect.SlideUp(element);
  else new Effect.SlideDown(element);
}
// ]]>

function popUp(page,PWidth,PHeight,id) {
 	eval("winpop"+id+"=window.open('"+page+"','winpop1','toolbar=0,scrollbars=0,location=0,status=0,menubars=0,resizable=0,width="+PWidth	+",height="+PHeight+"')")
	 }
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}