/*
	navigation logic
*/

var menuInterval;	//	interval for menu interativity detection
var currentMenu = null;
function init() {
	initNavigation();
}

function initNavigation() {
  var n = document.getElementById("navigation").getElementsByTagName("a");
  for(var i=0;i<n.length;i++) {
  	n[i].onmouseover = function() {
  		clearTimeout(menuInterval);
  		var m = this.id.split("_")[1];
  		var d = document.getElementById("menu"+m);
  		d.className="menuOn";
  		if(currentMenu && (currentMenu != d)) {
  			currentMenu.className="menuOff";
  		}
  		currentMenu = d;
  	}
	if(n[i].id) {
		n[i].onmouseout = function() {
			menuInterval = setTimeout("closeCurrentMenu()",200);
		}
		document.getElementById("menu"+i).onmouseover = function() {
			clearTimeout(menuInterval);
		}
		document.getElementById("menu"+i).onmouseout = function() {
			menuInterval = setTimeout("closeCurrentMenu()",200);
		}
	}
  }
}

function closeCurrentMenu() {
  if(currentMenu) {
  	currentMenu.className="menuOff";
  }
  currentMenu = null;
  clearTimeout(menuInterval);
}

/*
	kick the whole thing off
*/
onload = init;
			
