// JavaScript Document

/* Script to show and hide menu items, because CSS method doesn't work with IE6 */

function prepMenus() {
	e = document.getElementById('navigation');
	if ( !e ) { return; }
	var anc, ancs, dds, i, j, ul, uls
	uls = e.getElementsByTagName('ul');
	for ( i = 0; i < uls.length; i++ ) {
		ancs = uls[i].getElementsByTagName('a');
		for ( j = 0; j < ancs.length; j++ ) {
			ancs[j].onclick = function(val) {
				return function () {
					val.parentNode.parentNode.style.display = 'none';
					return true;
				}
			}(ancs[j]);
		}
	}
	dds = e.getElementsByTagName('dd');
	for ( i = 0; i < dds.length; i++ ) {
		if (dds[i].hasChildNodes() ) {
			try {
				uls = dds[i].getElementsByTagName('ul');
				if ( uls[0] ) {
					dds[i].onmouseover = function(val) {
						return function() {
							val.style.display = 'block';
						}
					}(uls[0]);
					dds[i].onmouseout = function(val) {
						return function() {
							val.style.display = 'none';
						}
					}(uls[0]);
				}
			} catch (err) {
				// OK to do nothing
			}
		}
	}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
	prepMenus();
});

