var menuTimer=null;
var activeMenu=new Array();
var zDex=101;
var holder;
var perfArray=new Array();
var pbjrArray=new Array();
var evntArray=new Array();
var aboutArray=new Array();
var archiveArray=new Array();
holder=new Array("Current Production","production/index.asp"); perfArray.push(holder);
holder=new Array("Ticket Information", "production/tickets.asp"); perfArray.push(holder);
holder=new Array("Cast and Crew", "production/castCrew.asp"); perfArray.push(holder);
holder=new Array("Auditions", "production/auditions.asp"); perfArray.push(holder);
perfArray=$A(perfArray)
holder=new Array("Current Production", "pbjr/index.asp"); pbjrArray.push(holder);
holder=new Array("Ticket Information", "pbjr/tickets.asp"); pbjrArray.push(holder);
holder=new Array("Cast and Crew", "pbjr/castCrew.asp"); pbjrArray.push(holder);
holder=new Array("Summer Applications", "pbjr/applications.asp"); pbjrArray.push(holder);
pbjrArray=$A(pbjrArray)
holder=new Array("Upcoming Events", "events/index.asp"); evntArray.push(holder);
holder=new Array("Event Galleries", "events/galleries.asp"); evntArray.push(holder);
evntArray=$A(evntArray)
holder=new Array("Mission Statement", "about/missionStatement.asp"); aboutArray.push(holder);
holder=new Array("Sponsors & Patrons", "about/patrons.asp"); aboutArray.push(holder);
holder=new Array("Board of Directors", "about/bod.asp"); aboutArray.push(holder);
holder=new Array("Contact Information", "about/contact.asp"); aboutArray.push(holder);
aboutArray=$A(aboutArray)
holder=new Array("Production Archive", "archive/index.asp"); archiveArray.push(holder);
holder=new Array("Production Galleries", "archive/galleries.asp"); archiveArray.push(holder);
archiveArray=$A(archiveArray)

function buildMenus(mArray, mID, anchObj){
try{
	var menu=document.createElement("DIV");
	menu.className="menuDiv";
	menu.style.display="none";
	menu.id=mID;
	menu.style.zIndex=String(zDex);
	zDex++;
	menu.anchorObj=anchObj;
	$('menuHolder').insert(menu);
	var baseLI=document.createElement("li");
	baseLI.className="menuList";
	var baseUL=document.createElement("ul");
	baseUL.style.listStyle="none";
	baseUL.style.marginLeft="0px";
	baseUL.style.paddingLeft="0px";
	menu.appendChild(baseUL);
	mArray.each(function(i){
		var mItem=baseLI.cloneNode(true);
		baseUL.appendChild(mItem);
//		var mLink=buildLink(i[0],i[1]);
//		mItem.appendChild(mLink);
		mItem.innerHTML='<a href="' + (pgSrc + i[1]) + '" class="menuLink">' + i[0] + '</a>';
		mItem.onmouseover=function(){this.className="menuListHighlight";}
		mItem.onmouseout=function(){this.className="menuList";}
		mItem.onclick=function(){hideMenu();window.location=pgSrc + i[1];}
	});
	menu.onmouseover=function(){clearTimeout(menuTimer); menuTimer=null;}
	menu.onmouseout=function(){setMenuHide();}
	positionMenus(mID);
}catch(e){alert(e.message);}
}

function buildLink(txt,dest){
	var lnk=document.createElement("A");
	lnk.href=pgSrc + dest;
	lnk.innerHTML=txt.toUpperCase();
	lnk.addClassName("menuLink");
	return lnk;
}

function positionMenus(mID){
	var menu=$(mID);
	var anch=$(menu.anchorObj);
	menu.setStyle({
		left: (anch.getWidth() + anch.cumulativeOffset().left + 3) + "px",
		top: (anch.cumulativeOffset().top + 6) + "px"
	});
}

function showMenu(menu){
	hideMenu();
	$(menu + 'Menu').show();
	if(activeMenu.length==0){
		activeMenu.push($(menu + 'Menu'));
	}else{
		hideMenu();
		activeMenu.push($(menu + 'Menu'));
	}
}

function setMenuHide(){
	menuTimer=setTimeout(hideMenu,100);
}

function hideMenu(){
	if(activeMenu.length>0){
		var oldMenu=activeMenu.pop();
		oldMenu.hide();
		clearTimeout(menuTimer);
		menuTimer=null;
	}
}