/****************************************************************************************
* By: Peter C. Y. Leung                                                                 *
* For: San Francisco State University, School of Engineering                            *
* Date: August 9, 2005                                                                  *
* Updated: August 24, 2006                                                               *
* Version: 0.91                                                                         *
* Site: http://engineering.sfsu.edu                                                     *
* Description: Javascript to create drop down menus                                     *
* Copyright 2004-2005 San Francisco State University, School of Engineering,            *
* San Francisco, California, U.S.A.                                                     *
****************************************************************************************/
var Menu_Tab_Index = 0;

function menuGroups(menus) {
	this.menus = arguments;
}

function menuItems(description, url, menu_groups) {
	this.description = description;
	this.url = url;
	if (menu_groups && menu_groups.menus)
		this.menus = menu_groups.menus;
}

function makeMenu(id, menu) {
	var i;
	id = "menu" + (id + 1);
	HTML_b = "<a href=\"" + sub_dir + menu.url + "\"";
	HTML_b += " onmouseover=\"overMenu('" + id + "'); return true;\"";
	HTML_b += " onmouseout=\"outMenu('" + id + "'); return true;\"";
	HTML_b += " onfocus=\"overMenu('" + id + "'); return true;\"";
	HTML_b += " onblur=\"outMenu('" + id + "'); return true;\"";
	HTML_b += " tabindex=\"" + (Menu_Tab_Index++) + "\">";
	HTML_b += menu.description + "</a>";
	HTML_a = "<ul>";
	for (i = 0; i < menu.menus.length; i++) {
		HTML_a += "<li><a href=\"" + sub_dir + menu.menus[i].url + "\"";
		HTML_a += " onmouseover=\"stayOpen('" + id + "'); return true;\"";
		HTML_a += " onmouseout=\"outMenu('" + id + "'); return true;\"";
		HTML_a += " onfocus=\"stayOpen('" + id + "'); return true;\"";
		HTML_a += " onblur=\"outMenu('" + id + "'); return true;\"";
		HTML_a += " tabindex=\"" + (Menu_Tab_Index++) + "\">";
		HTML_a += menu.menus[i].description + "</a></li>";
	}
	HTML_a += "</ul>";
	return("<div id=\"" +  id + "\">" + HTML_a + "</div>" + HTML_b);
}

function makeMenus(menus) {
	var i;
	Menu_Tab_Index = 10;
	HTML = "";
	for (i = 0; i < (menus.length - 1); i++) {
		HTML += makeMenu(i, menus[i]);
		HTML += " | ";
	}
	HTML += makeMenu(i, menus[i]);
	return (HTML);
}

function loadMenus(menus_id, menus_items) {
	if ((document.getElementById != null) && (document.getElementById(menus_id) != null))
		document.getElementById(menus_id).innerHTML = makeMenus(menus_items.menus);
}

var Current_Menu_Status = null;

var Menu_Timeout_ID = null;

function overMenu(id){
	if (Current_Menu_Status == document.getElementById(id)) {
		window.clearTimeout(Menu_Timeout_ID);
	} else {
		if(Current_Menu_Status != null) {
			window.clearTimeout(Menu_Timeout_ID);
			hideNow();
		}
		Current_Menu_Status = document.getElementById(id);
	}
	if ((Current_Menu_Status.style != null) && (Current_Menu_Status.style.visibility != null)) {
		Current_Menu_Status.style.visibility = 'visible';
	}
}

function stayOpen(id){
	if ((Current_Menu_Status == null) || 
		((Current_Menu_Status.style) && (Current_Menu_Status.style.visibility) && (Current_Menu_Status.style.visibility == 'hidden')))
		return;
	else overMenu(id);
}

function outMenu(id){
	Current_Menu_Status = document.getElementById(id);
	Menu_Timeout_ID = window.setTimeout(hideNow, 250);
}

function hideNow() {
	if ((Current_Menu_Status.style != null) && (Current_Menu_Status.style.visibility != null)) {
		Current_Menu_Status.style.visibility = 'hidden';
	}
}

/****************************************************************************************
Define all menu items here
- Use menuItems(description, URL, status, sub-menus) to create a menu item.
- Use menuGroups([menuItem[1] .... ]) to group menus.
****************************************************************************************/
Top_Menus = new menuGroups(
	new menuItems("Home", "index.html",
		new menuGroups(
			new menuItems("Mission &amp; Objectives", "mission_and_objectives.html"),
			new menuItems("Academics", "academics/index.html"),
			new menuItems("Centers of Excellence", "centers_of_excellence/index.html"),
			new menuItems("MEP", "mep/index.html"),
			new menuItems("FAQs", "faqs.html"),
			new menuItems("Contact Us", "contact_us.html")
		)
	),
	new menuItems("Prospective Students", "prospective_students/index.html",
		new menuGroups(
			new menuItems("Welcome Messages", "prospective_students/welcome_messages/index.html"),
			new menuItems("Program Overview", "prospective_students/program_overview/index.html"),
			new menuItems("University &amp; Location", "prospective_students/university_and_location/index.html"),
			new menuItems("Admissions", "prospective_students/admissions/index.html"),
			new menuItems("Support for Students", "prospective_students/support_for_students/index.html"),
			new menuItems("Buildings &amp; Facilities", "prospective_students/buildings_and_facilities/index.html")
		)
	),
	new menuItems("Current Students", "current_students/index.html",
		new menuGroups(
			new menuItems("Academic Resources", "current_students/academic_resources/index.html"),
			new menuItems("Financial &amp; Careers", "current_students/financial_and_careers/index.html"),
			new menuItems("<i>My</i> School Activities", "current_students/my_school_activities/index.html"),
			new menuItems("Graduation", "current_students/graduation/index.html"),
			new menuItems("Project Showcase", "current_students/project_showcase/index.html"),
			new menuItems("Achievements", "current_students/achievements/index.html"),
			new menuItems("<span class=\"e_forms\">e</span>Forms Download", "current_students/eforms_download/index.html")
		)
	),
	new menuItems("Alumni", "alumni/index.html",
		new menuGroups(
			new menuItems("Sign Up", "alumni/sign_up/index.html"),
			new menuItems("Surveys", "alumni/surveys/index.html"),
			new menuItems("Class Notes", "alumni/class_notes/index.html"),
			new menuItems("Support", "alumni/support/index.html")
		)
	),
	new menuItems("Faculty / Staff", "faculty_and_staff/index.html",
		new menuGroups(
			new menuItems("Profiles &amp; Office Hours", "faculty_and_staff/profiles_and_office_hours/index.html"),
			new menuItems("Research Areas", "faculty_and_staff/research_areas/index.html"),
			new menuItems("Positions", "faculty_and_staff/positions/index.html"),
			new menuItems("Achievements", "faculty_and_staff/achievements/index.html"),
			new menuItems("For Faculty Only", "faculty_and_staff/for_faculty_only/index.html")
		)
	),
	new menuItems("News", "news/index.html",
		new menuGroups(
			new menuItems("Newsletter", "news/newsletter/index.html"),
			new menuItems("Events", "news/events/index.html"),
			new menuItems("Face of the School", "news/face_of_the_school/index.html"),
			new menuItems("Seminars", "news/seminars.html")
		)
	)
);
/************************************ End of File **************************************/