
// Here is where the submenu labels and links go
var linksWel = [
	['About Us', 'about.html'],
	['How To Join','join.html'],
	['History', 'history.html']];

var linksRes = [
	['Funding Requests', 'funding.html']];

var linksBlog = [
	['Make an announcement','http://www.blogger.com/start']];
	
// an array of all the menus on the page
// you have to declare all the menus by hand I'm afraid
var menus = [ 	new MenuClass('Welcome', 'index.html', 'menuWel', linksWel), 
				new MenuClass('Resources', 'resources.html', 'menuRes', linksRes)];	

// the menu class definition
function MenuClass(name, target, menuID, menuEntries) {
	this.name = name;
	this.target = target;
	this.menuID = menuID;
	this.menuEntries = menuEntries;
	this.Draw = Draw;
	this.Show = Show;
	this.Hide = Hide;
	
	function Draw() {
	
		// Draw the main title part
		var menuCode = '<A href="' + target + '" class="topmenu" onMouseOver="showMenu(\'' + menuID + '\')">' + name + '</A>';
		
		document.write(menuCode);
		
		// Draw the invisible div menu parts
		var menuCode = '<div id="' + menuID + '" class="menu"><table onMouseOver="changeObjectVisibility(\'' + menuID + '\', \'visible\')" onMouseOut="hideAllMenus()"><tr>';
		
		for (i = 0; i < menuEntries.length; i++){
			menuCode += '<td><A href="' + menuEntries[i][1] + '" class="menu_item">' + menuEntries[i][0] + '</A></td>';
		}
		
		menuCode += '</tr></table></div>';
	
		//alert(menuCode);
		document.write(menuCode);
	
		this.Hide();
	}
	
	function Hide() {
		changeObjectVisibility(menuID, 'hidden');
		//alert("menu received Hide() command");
	}
	
	function Show () {
		changeObjectVisibility(menuID, 'visible');
	}
	
}

function hideAllMenus() {
	for (i = 0; i < menus.length; i++) {
		//alert("hiding a menu now");
		(menus[i]).Hide();
	}
}

function showMenu(menuID) {
	hideAllMenus();
	changeObjectVisibility(menuID, 'visible');
}

// JavaScript magic
function changeObjectVisibility(objectId, newVisibility) {
    var styleObject = getStyleObject(objectId, document);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	return false;
    }
} 
function getStyleObject(objectId) {
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		return getObjNN4(document,objectId);
	} else {
		return false;
	}
} 
function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
// end JavaScript magic

