// Copyright 2003 Grace Fellowship of Puget Sound//==========================MENU SETUP=========================	//MENU OBJECT DEFINITION	function menu(id,sib,child,root){		this.id=id.replace(/[A-Z][a-z0-9-_]*$/,"")		this.element=document.getElementById(id)		this.parent=this.element.getAttribute("parent")		this.sib=this.element.getAttribute("sib")		this.child=this.element.getAttribute("child")		this.root=this.element.getAttribute("root")	}				//=======================UTILITY FUNCTIONS======================//BROWSER-INDEPENDENT METHOD OF GETTING ELEMENTS	function test(){		alert("test")	}		function getMenu(id){		if(!id) return false		return new menu(id)	}		function checkMenu(id,start){		var menu, result		for(menu=start;menu!="";menu=menu.sib){			if(menu.id==id) return menu			if((menu.child!="")&&(result=checkMenu(id,menu.child))) return result		}		return false	}	//BRING UP DIRECTORY WINDOW FOR SPECIFIC FAMILY	function dirLookup(name){		name=name.replace(/ /g, "+")		var w=window.open("../directory/congregationdir.php?lookup="+name,'dir','resizable=yes,scrollbars=yes')		w.focus()		return false	}//=====================MISC STUFF=======================	//BROWSER SNIFFING		msie=navigator.userAgent.indexOf("MSIE")!=-1	mac=navigator.userAgent.indexOf("Mac")!=-1	msie_mac=(msie&&mac)	//=======================MENU EVENT HANDLERS=====================	var yOffset	var mainMenuBkgColor="#363636"	var mainMenuHiliteBkgColor="#dadada"	var mainMenuTextColor="#ffffff"	var mainMenuHiliteTextColor="#000000"	var subMenuBkgColor="#363636"	var subMenuHiliteBkgColor="#dadada"	var subMenuTextColor="#ffffff"	var subMenuHiliteTextColor="#000000"		var status		var lastRoot=null	var subList=new Array(10)	for(var i=0;i<10;i++) subList[i]=null	var subIndex=0	//JUMP TO LOCATION SPECIFIED IN MENU	function menuGoTo(loc,newWindow){		if(newWindow){			var w=window.open(loc,"_blank","resizable=yes,scrollbars=yes,height="+window.innerHeight+",width="+window.innerWidth)			w.focus();			return;		}		window.location=loc;	}//MANAGE THE MENU STRUCTURE ON MOUSEOVER	function inMenu(elmnt){		var m=getMenu(elmnt.id)							//find the menu in the menu list		//		status.innerHTML=subList[subIndex]+"["+subIndex+"]"	//TAKE CARE OF PENDING MENU CLEARING EVENTS			if(delayTime){									//if there has been a mouseOut command			if(m.root==lastRoot){						//and we are in the same menu we were previously				clearTimeout(delayTime)					//cancel the menu clear timeout				delayTime=false							//and indicate that we are not waiting for a menu clear			}			else{				clearMenu()								//this is a new menu, so we need to clear the old one			}		}		lastRoot=m.root									//remember which main menu item we are servicing		if(elmnt.id.search(/Sub$/)!=-1) return			//don't need to do more if it is a submenu			//HIGHLIGHT THE ACTIVE MENU ITEM		var inMain=(m.root==m.id)			if(inMain){									//check to see if this is a main menu item			elmnt.style.backgroundColor=mainMenuHiliteBkgColor	//hilite the main menu item			elmnt.style.color=mainMenuHiliteTextColor		//hilite text		}		else{			var item=document.getElementById(m.id+"Item")	//find the item			item.style.backgroundColor=subMenuHiliteBkgColor	//hilite the submenu item			item.style.color=subMenuHiliteTextColor			//hilite text		}	//ELIMINATE OLD SUBMENU IF THERE IS ONE			var sub		if(!inMain){			sub=document.getElementById(m.parent)			//find the submenu that contains the item//				status.innerHTML+=sub.id+":"+subIndex			if(sub!=subList[subIndex]){						//if this is not the main menu item and belongs to a new submenu				subList[subIndex].style.display="none"		//get rid of the old submenu				subList[subIndex]=null				subIndex--			}		}	//SET UP THE NEW SUBMENU IF THERE IS ONE		if(m.child=="")return;							//don't need to process further if there is no submuen		sub=document.getElementById(m.id+"Sub")		//find the new submenu		if(sub==subList[subIndex]) return;				//don't need to process this submenu if it is already being displayed		sub.style.display="block"							//display submenu	//ADJUST SUBMENU SIZE AND POSITION		if(!inMain) parentSub=document.getElementById(m.parent)		sub.style.left=(inMain? elmnt.offsetParent.offsetLeft:parentSub.offsetLeft+parentSub.offsetWidth)+"px"		var t=(elmnt.offsetTop+(inMain? elmnt.offsetHeight:parentSub.offsetTop)) 	//calculate top to be even with parent item		if(msie_mac) t-=4			var h=sub.offsetHeight		var wh		var wt		if(window.innerHeight){							//find top and height of screen (browser-dependent)			wh=window.innerHeight					//mozilla-style			wt=window.pageYOffset		}		else{											//MSIE-style			if(document.documentElement.clientHeight)	//IE 6 standards compliant mode				wh=document.documentElement.clientHeight			else				wh=document.body.clientHeight						wt=document.body.scrollTop		}		if((diff=(t+h+yOffset)-(wt+wh))>0){				//is bottom of submenu below the bottom of screen?			sub.style.top=(t-diff)+"px"					//if so, adjust up		}		else{			sub.style.top=t+"px";						//otherwise set even with top of parent item		}		var i		var w=sub.offsetWidth		var d=sub.getElementsByTagName("DIV")		if(d.length>0 && !d[0].style.width){			for(i=0;i<d.length;i++) d[i].style.width=w+"px"		}		if(subList[subIndex]) subIndex++		subList[subIndex]=sub	}		delayTime=false//RESPOND TO MOUSEOUT		function  outMenu(elmnt){								//delay clearing the menu to avoid screen glitches		if(delayTime)clearTimeout(delayTime)			//if a delay timeout is already set, clear it		delayTime=setTimeout("clearMenu()",100)			//restart the delay timer to 0.5 seconds		var item=document.getElementById(elmnt.id.replace(/[A-Z][a-z]*$/,"Item"))		item.style.backgroundColor=(item.parent=="")? mainMenuBkgColor:subMenuBkgColor		item.style.color=(item.parent=="")? mainMenuTextColor:subMenuTextColor	}	//CLEAR MENU HILITING	function clearMenu(){		var item=document.getElementById("startItem")		var sub,m		while(item){				//walk through menu list			item.style.backgroundColor=mainMenuBkgColor	//reset background color			item.style.color=mainMenuTextColor 			//reset text color			item=document.getElementById(item.getAttribute("sib")+"Item")		}		for(i=0;i<10;i++){			if(!subList[i]) continue			subList[i].style.display="none"					//hide submenus			subList[i]=null		}		subIndex=0		if(delayTime) clearTimeout(delayTime)			//reset 		delayTime=false		lastRoot=null		return 	}		//SET OPACITY FOR VARIOUS BROWSERS	function setOpacity(obj,opc){		obj.style.opacity=opc;										//CSS3 standard		obj.style.MozOpacity=opc;									//Older Mozilla		obj.style.filter="alpha(opacity="+(opc*100)+")";			//MSIE	}