function init() {
  //aline main frames
  var menuBarTop = document.getElementById("menuBar").offsetHeight;  var menuBarLeft = document.getElementById("menuBar").offsetLeft;  //var menuBarTop = 200;
  var tmp = document.getElementById("menuBar");
  tmp.style.left = (screen.width - 800)/2;
  for (i=0;i<10;i++) {
  	  
    var temp = document.getElementById("subMenu"+i+"0");
    if (temp != null) {
    	
      temp.style.top = menuBarTop - 2 + "px";
      
      var tmp2 = (screen.width - 800)/2 + 26 ;      temp.style.left = document.getElementById("menuBar"+i).offsetLeft + tmp2 + "px";
    }
    // order second level
    for (j=1;j<10;j++) {
      var temp2 = document.getElementById("subMenu"+i+""+j);
      if (temp2 != null) {
        temp2.style.top = (document.getElementById("sm"+i+j).offsetTop + menuBarTop) - 2 + "px";
        temp2.style.left = (document.getElementById("subMenu"+i+"0").offsetLeft + document.getElementById("subMenu"+i+"0").offsetWidth-2) + "px";        
      }
    }
  }
}

// Should the mouse go off the document window hide all menus
function offPage(event){
	var offScreen;
	offScreen = (event.pageY < 5) ? 1 : 0;
	
	if (offScreen) hideOthers(10,10);
}

function hideOthers(one, two){
	// Hide all of the sub-menus except the one that should be showing and its super-menus.
	for(one_count = 0; one_count< 10; one_count++)
	{
	 if ( one == one_count )
		{
		if (two == 0) {
                  for (two_count = 0; two_count < 10; two_count++)  {
                    var currentElement = document.getElementById("subMenu"+one_count+two_count);
                    if (currentElement != null) {
                      currentElement.style.visibility = "hidden";
                    }
		  }
		}
                
	 }
	 if ( one != one_count ) {
		for (two_count = 0; two_count < 10; two_count++) {
                  if(document.getElementById("subMenu"+one_count+two_count)!=null) {
			document.getElementById("subMenu"+one_count+two_count).style.visibility = "hidden";
                  }
		}
	 }
	}

	// Hide any special menus down here.
	//var currentElement = document.getElementById("clearAll");
	//if(currentElement != null) currentElement.style.visibility = "hidden";
}

// Hide all the menus
function hide(id){
	// Very poorly done, however works...need to glamorize this later
	var currentElement = document.getElementById("clearAll");
	if(currentElement != null) currentElement.style.visibility = "hidden";
}

// Shows the submenu for the menu item
function showSubMenu(one, two) {
	hideOthers(one, two);

	// Make the background layer visible for catching the mouse as it leaves the menu
	var currentElement = document.getElementById("clearAll");
	currentElement.style.visibility = "visible";
	// Show the correct sub-menu
	if(document.getElementById("subMenu"+one+two) != null) {
		var currentElement = document.getElementById("subMenu"+one+two);
		currentElement.style.visibility = "visible";
	}
}
// -->
