function JSMenu(div, currentPage) {
	
	this.init = function() {
		me.drawMenu();
	};
	
	this.drawMenu = function() {
		if(!JSMenu.menuItems.length) {
			return false;
		}
		var menuItem, a;
		for(var i=0; i<JSMenu.menuItems.length; i++) {
			menuItem = JSMenu.menuItems[i];
			
			a = document.createElement("a");
			a.appendChild(document.createTextNode(menuItem['text']));
			if(menuItem["title"]) {
				a.title = menuItem["title"];
			}
			if(menuItem['url']) {
				a.href = menuItem['url'];
				
				if(me.currentPage == menuItem['url']) {
					a.className = "active";
				}
			} else {
				a.href = "javascript:void(0);";
			}
			if(menuItem['subMenu']) {
				a.menuItem = menuItem;
				a.onmouseover = function() {
					if(me.timer) clearTimeout(me.timer);
					me.hideSubMenu();
					var menuItem = this.menuItem;
					var currentLink = this;
					me.timer = window.setTimeout(function() {
						me.drawSubMenu(currentLink, menuItem['subMenu']);
					}, JSMenu.TIMEOUT);
				};

				for(var idx in menuItem['subMenu']) {
					if(me.currentPage == menuItem['subMenu'][idx]["url"]) {
						a.className = "active";
					}
				}
			} else {
				a.onmouseover = function() {
					if(me.timer) clearTimeout(me.timer);
					me.hideSubMenu();
				};
			}
			
			me.div.appendChild(a);
		}
	};
	
	this.drawSubMenu = function(parent, subMenu) {
		me.hideSubMenu();
		var parentCoords = findPos(parent);
		var menuNode = document.getElementById("menu");
		var upperParentCoords = findPos(menuNode);
		
		me.displayPanel = document.createElement("div");
		me.displayPanel.style.position = "absolute";
//		me.displayPanel.style.filter = "alpha(opacity=80)";
//		me.displayPanel.style.MozOpacity = ".8";
//		me.displayPanel.style.opacity = ".8";
		me.displayPanel.style.zIndex = "20";
		me.displayPanel.style.background = "transparent url(/lib/images/orange_bg.png)";

		document.body.appendChild(me.displayPanel);
		document.body.onclick = me.hideSubMenu;
		me.displayPanel.style.top = parseInt(upperParentCoords[1]+menuNode.offsetHeight,10)+"px";
		me.displayPanel.style.left = (parentCoords[0]-10)+"px";
		
		me.displayPanel.onmouseover = function() {
			if(me.timer) {
				clearTimeout(me.timer);
			}
		};
		
		me.displayPanel.onmouseout = function() {
			if(me.timer) {
				clearTimeout(me.timer);
			}
			me.timer = window.setTimeout(function() {
				me.hideSubMenu();
			}, JSMenu.TIMEOUT);
		};	
		
		var content = document.createElement("div");
//		content.style.background = "#fec05b url(/lib/images/top_shdw_orange.png) repeat-x 0 0";
		if(BROWSER != IE)
			content.style.background = "transparent url(/lib/images/sub_nav_with_shadow.png) repeat-x 0 0";
		content.style.zIndex = 5;
		content.style.padding = "10px";
		
		me.displayPanel.appendChild(content);
		for(var i=0; i<subMenu.length; i++) {
			a = document.createElement("a");
			a.href = subMenu[i]["url"];
			a.appendChild(document.createTextNode(subMenu[i]["text"]));
			a.href = subMenu[i]["url"];
			if(subMenu[i]["title"])
				a.title = subMenu[i]["title"];
			a.className = "sub_menu_item";
			content.appendChild(a);
		}
	};
	
	this.hideSubMenu = function() {
		if(me.displayPanel) {
			me.displayPanel.style.display = "none";
		}
	};
	
	var me = this;
	this.div = div;
	this.displayPanel = null;
	this.timer = null;
	this.currentPage = currentPage;
	this.init();
};

JSMenu.TIMEOUT = 500;

JSMenu.menuItems = new Array(
	{ "text":"home", "url":"/" },
	{ "text":"about", "url":"/about_vedanta_academy.html", "subMenu":
		[
		 { "text":"about vedanta", "title":"History, Vedanta Environment", "url":"/about_vedanta_academy.html" },
		 { "text":"mission statement / promise", "title":"Mission Statement / Promise", "url":"/about_mission_statement.html" },
		 { "text":"testimonials", "title":"What people are saying about us", "url":"/about_testimonials.html" },
		 { "text":"staff", "title":"Staff", "url":"/about_staff.html" },
		 { "text":"facilities", "title":"Facilities", "url":"/about_facilities.html" },
		 { "text":"dress code", "title":"What to wear and what not to wear", "url":"/about_dress_code.html" },
		 { "text":"society", "title":"Society and Governance", "url":"/about_society.html" },
		 { "text":"accreditation", "title":"Accreditation", "url":"/about_accreditation.html" },
		 { "text":"community partners", "title":"Partners in our community", "url":"/about_community_partners.html" }
		]
	},
	{ "text":"school", "url":"/high_school.html", "subMenu": 
		[
			{ "text":"high school", "title":"Grades K to 6", "url":"/high_school.html" }, 
			{ "text":"middle school", "title":"Grades 7 to 9", "url":"/middle_school.html" }, 
			{ "text":"elementary school", "title":"Grades 10 to 12", "url":"/elementary_school.html" } 
		]
	},
	{ "text":"learning cycle", "title":"Concentrated Learning, Conflict Resolution, Building Connections", "url":"/learning_cycle.html" },
	{ "text":"programs", "url":"/specialty_programs.html", "subMenu":
		[
		 { "text":"specialty programs", "url":"/specialty_programs.html" },
		 { "text":"enrichment programs", "url":"/enrichment_programs.html" },
		 { "text":"s.t.r.i.v.e.", "url":"/strive.html" },
		 { "text":"outdoor ed", "title":"Outdoor Education", "url":"/outdoor_education.html" },
		 { "text":"Our MacBook &trade; Program", "text":"laptop program", "url":"/laptop_program.html" },
		 { "text":"international", "title":"International Students", "url":"/international_program.html" },
		 { "text":"student exchange", "url":"/student_exchange.html" }
		]
	},
	{ "text":"gallery", "url":"/gallery.html", "subMenu":
		[
		 {"text":"photos", "url":"/gallery.html" },
		 {"text":"yearbook", "url":"/yearbook.html", "title":"See our current yearbook" }
		]
	},
	{ "text":"in the spotlight","title":"Students and Teachers who are going above and beyond!", "url":"/in_the_spotlight.html" },
	{ "text":"v-news", "url":"/v-news.html", "subMenu":
		[
		 { "text":"v-news", "url":"/v-news.html", "title":"Noteworthy Items" },
		 { "text":"events calendar", "url":"/events_calendar.html", "title":"Check out what's going on at Vedanta" },
		 { "text":"newsletters", "url":"/newsletters.html" }
		]
	},
	{ "text":"admissions", "url":"/admissions_procedure.html", "subMenu": 
		[
		 { "text":"procedure", "url":"/admissions_procedure.html", "title":"Admissions Procedures for Vedanta" },
		 { "text":"apply now", "url":"/apply_online.html", "title":"Apply Online" },
		 { "text":"parent/student handbook", "url":"/parent_student_handbook.html", "title":"Everything you need to know about life at Vedanta" }
		]
	},
	{ "text":"contact/more info", "url":"/contact.html", "subMenu": 
		[
		 { "text":"contact form", "url":"/contact.html", "title":"Contact Us" },
		 { "text":"helpful links", "url":"/helpful_links.html", "title":"Websites of interest on a variety of categories" },
		 { "text":"scholarships, awards, bursaries", "url":"/scholarships.html" },
		 { "text":"careers", "url":"/careers.html" }
		]
	 }
);