/***********************************************
* Drop Down Menu Code
***********************************************/

//Contents for menu 

var content="ContentPane";

var GoodNewsMenu=new Array()
var sermons="GoodNewsArticles\\Sermons.html";
GoodNewsMenu[0]='<a href="javascript:addHistoryEvent(sermons,content)">Sermons</a>'
var newsLetter = "GoodNewsArticles\\newsletter.html";
GoodNewsMenu[1]='<a href="javascript:addHistoryEvent(newsLetter,content)">Newsletter</a>'

// The next line below has a parameter (&begin_date=) that must be changed monthly for the church calendar
GoodNewsMenu[2]='<a href="http://www.mychurchevents.com/calendar/calendar.aspx?list_by=calendar_month&begin_date=07/1/2010&ci=L6J4K5H2L6L6G1G1&igd=">Calendar</a>'

var staff="GoodNewsArticles\\staff.html";
GoodNewsMenu[3]='<a href="javascript:addHistoryEvent(staff,content)">Staff</a>'


var ConnectingMenu=new Array()
var about = "ConnectingArticles\\WhoWeAre.html";
ConnectingMenu[0]='<a href="javascript:addHistoryEvent(about,content)">Who We Are</a>'
ConnectingMenu[1]='<a href="http://www.mapquest.com/maps/map.adp?formtype=address&addtohistory=&address=3109 Rivermont Ave&city=Lynchburg&state=VA&zipcode=24503-1357&country=US&geodiff=1">Directions</a>'
var involvement = "ConnectingArticles\\GettingInvolved.html";
ConnectingMenu[2]='<a href="javascript:addHistoryEvent(involvement,content)">Getting Involved</a>'
var giving = "ConnectingArticles\\Giving.html";
ConnectingMenu[3]='<a href="javascript:addHistoryEvent(giving,content)">Giving</a>'

var ReachingOutMenu=new Array()
var action = "ReachingOutArticles\\SocialAction.html";
ReachingOutMenu[0]='<a href="javascript:addHistoryEvent(action,content)">Social Action</a>'
var outreach = "ReachingOutArticles/WorldOutreach.html";
ReachingOutMenu[1]='<a href="javascript:addHistoryEvent(outreach,content)">Reaching Out</a>'
var earth = "ReachingOutArticles/Earthkeepers.html";
ReachingOutMenu[2]='<a href="javascript:addHistoryEvent(earth,content)">Earthkeepers</a>'
var mission = "ReachingOutArticles/Mexico Mission Trip.html";
ReachingOutMenu[3]='<a href="javascript:addHistoryEvent(mission,content)">Missions</a>'

var FaithFormationMenu=new Array()
var education = "FaithFormationArticles/Education.html";
FaithFormationMenu[0]='<a href="javascript:addHistoryEvent(education,content)">Education</a>'
var worship = "FaithFormationArticles/Worship.html";
FaithFormationMenu[1]='<a href="javascript:addHistoryEvent(worship,content)">Worship</a>'
var spirituality = "FaithFormationArticles/Spirituality.html";
FaithFormationMenu[2]='<a href="javascript:addHistoryEvent(spirituality,content)">Spirituality</a>'
var health = "FaithFormationArticles/HealthAndWellness.html";
FaithFormationMenu[3]='<a href="javascript:addHistoryEvent(health,content)">Health and Wellness</a>'

var menuwidth='150px' //default menu width
var menubgcolor='#DDDCEE'  //menu bgcolor
var disappeardelay=50  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editing needed


var ie4=document.all
var ns6=document.getElementById&&!document.all


if (ie4||ns6)
{
//	document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
	document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';font-family: Trebuchet MS, Arial, Verdana; font-size:14px;'+';background:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')	
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
	if (ie4||ns6)
		dropmenuobj.style.left = dropmenuobj.style.top="-500px"

//alert("enter showhide");	

	if (menuwidth!=""){
	
//alert("menuwidth not 0");
	
		dropmenuobj.widthobj=dropmenuobj.style;
		dropmenuobj.widthobj.width=menuwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	{
		obj.visibility=visible
//alert("object visible");
	}	
	else if (e.type=="click")
	{
		obj.visibility=hidden
//alert("object not visible");
	}	
//alert("exit showhide - style = "+dropmenuobj.widthobj+"   widthobj = "+dropmenuobj.widthobj.width);	
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
		var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18

		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;

		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight;

			if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
				edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge;
		}
	}

//alert("exit clearbrowseredge: windowedge = "+windowedge+"     edgeoffset = "+edgeoffset);		
	
	return edgeoffset;
}

function populatemenu(what){
	if (ie4||ns6) {
	dropmenuobj.innerHTML=what.join("")
	}
}


function dropdownmenu(obj, e, menucontents, menuwidth){

	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()

	clearhidemenu();
	
//	dropmenuobj = document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	dropmenuobj = document.getElementById("dropmenudiv");

//alert("enter dropdownmenu - dropmenuobj = "+dropmenuobj);	
	
	populatemenu(menucontents)

//alert("after populate menu");
	
	if (ie4||ns6){
	
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		
//alert("after showhide()");
		
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")


		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
//alert("before - left = "+dropmenuobj.style.left);		
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
//alert("after - top = "+dropmenuobj.style.top);
		
		}		

	return clickreturnvalue()
}

function clickreturnvalue(){
	if (ie4||ns6)return false; 
	else return true; 
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function hidemenu(e){

if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"

}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

