


var raySectionData = {
		'experiences' : { 'id':'experiences', 'label':'Experiences', 'href':'experiences.php',
			'children': new Array(
			{ 'id':'retreats', 'label':"Camps and Retreats", 'href':'experiences.php?item=retreats' },
			{ 'id':'glean', 'label':"Glean", 'href':'experiences.php?item=glean' },
			{ 'id':'e3', 'label':"E3", 'href':'experiences.php?item=e3' }
			) },
		'resources' : { 'id':'resources', 'label':'Resources', 'href':'resources.php',
			'children': new Array(
			{ 'id':'follow', 'label':"Follow Me: A Journey<br>with Jesus", 'href':'resources.php?item=follow' },
			{ 'id':'move', 'label':"move: the mission prep workbook", 'href':'resources.php?item=move' },
			{ 'id':'merge', 'label':"merge: guided studies through the book of James", 'href':'resources.php?item=merge' },
			{ 'id':'story', 'label':"STORY: the mission prep workbook", 'href':'resources.php?item=story' }
			) },
		'services' : { 'id':'services', 'label':'Services', 'href':'services.php',
			'children': new Array(
			{ 'id':'consulting', 'label':"Youthmark Consulting", 'href':'services.php?item=consulting' },
			{ 'id':'coaching', 'label':"Youthmark Coaching", 'href':'services.php?item=coaching' },
			{ 'id':'speaking', 'label':"Youthmark Speaking", 'href':'services.php?item=speaking' }
			) },
		'missions' : { 'id':'missions', 'label':'Missions', 'href':'missions.php',
			'children': new Array(
			{ 'id':'preview_meals', 'label':"Preview Meals", 'href':'missions.php?item=preview_meals' },
			{ 'id':'overview', 'label':"Overview", 'href':'missions.php?item=overview' },
			{ 'id':'blogs', 'label':"Mission Team Blogs", 'href':'missions.php?item=blogs' }
			) },
		'contact' : { 'id':'contact', 'label':'Contact', 'href':'contact.php' }
	 };










/*
	
	Standard Navigation
	
*/
function getNextSection(strInCurrentSectionID)
{	
	booCurrentFound = false;
	strFirstKey = null;
	
	for (k in raySectionData)
	{	
		if (booCurrentFound)
		{	
			return raySectionData[k];
		}
		booCurrentFound = (raySectionData[k]['id']==strInCurrentSectionID);
		
		if (!strFirstKey) strFirstKey = k;
	}
	
	return raySectionData[strFirstKey];
}
function getNextSubPage(strInCurrentSectionID, strInCurrentPageID)
{	
	booCurrentFound = false;
	
	rayThisSection = raySectionData[strInCurrentSectionID];
	if (rayThisSection)
	{	
		if (rayThisSection.children)
		{	
			for (intChildIdx = 0; intChildIdx < rayThisSection.children.length; intChildIdx++)
			{	
				if (booCurrentFound)
				{	
					return rayThisSection.children[intChildIdx];
				}
				booCurrentFound = (rayThisSection.children[intChildIdx]['id']==strInCurrentPageID);
			}
		}
	}
	
	return false;
}
function getNextPage(strInCurrentSectionID, strInCurrentPageID)
{	
	rayNextPage = getNextSubPage(strInCurrentSectionID,strInCurrentPageID);
	if (rayNextPage)
	{	
		/*
			proceed to next sub-page.
		*/
		rayNextPage['is_subpage'] = true;
		return rayNextPage;
	}
	
	return getNextSection(strInCurrentSectionID);
}




function goToNextPage()
{
	/*
		Determine next link.
	*/
	rayNextPage = getNextPage(strSectionID, strSubPageID);
	if (rayNextPage['is_subpage'])
	{	
		goSubPage(rayNextPage['id']);
	}
	else
	{	
		document.location = rayNextPage['href'];
	}
}



function renderNavPanel(strInSectionID, strInSubPageID, strInLabel)
{	
	if (!strInLabel)
	{	rayNextPage = getNextPage(strInSectionID, strInSubPageID);
		if (rayNextPage['id']=='contact')
		{	strInLabel = "Contact Us"; }
		else
		{	strInLabel = "Next"; }
	}
	
	
	strNavPanelOut = "<table id='tblNav' border=0 cellspacing=0 cellpadding=0>"+
		"<tr><td valign='top' style='width:20px;'>"+
				"<img src='images/LP_corner_TL.gif' width=10 height=10 border=0><"+"/td>"+
			"<td rowspan=2 class='NavItem' onclick='goToNextPage()'"+
				" onmouseover=\"this.style.cursor='pointer';"+
				" this.style.background='#faec89 url(images/LP_hover40_bg.gif) no-repeat top right';\""+
				" onmouseout=\"this.style.cursor='default';"+
					"this.style.background='transparent';\">"+
				
				strInLabel+
				
			"<"+"/td>"+
			"<td valign='top' align='right' style='width:10px;'>"+
				"<img src='images/LP_corner_TR.gif' width=10 height=10 border=0><"+"/td>"+
		"<"+"/tr>"+
		"<tr><td valign='bottom' style='width:20px;'>"+
				"<img src='images/LP_corner_BL.gif' width=10 height=10 border=0><"+"/td>"+
			"<td valign='bottom' align='right' style='width:10px;'>"+
				"<img src='images/LP_corner_BR.gif' width=10 height=10 border=0><"+"/td>"+
		"<"+"/tr><"+"/table>";
	
	return strNavPanelOut;
}

function refreshNavPanel()
{	
	objNavHolder = document.getElementById('divNavHolder');
	objNavHolder.innerHTML = renderNavPanel(strSectionID, strSubPageID);
}











/*
	Menu-bar functions...
*/

function renderMenuBar(strInSelectedItemID, strInAlignment)
{	
	if (!strInAlignment) strInAlignment = 'right';
	strMenuBarOut = "<table cellspacing=0 cellpadding=0 border=0"+
		" style='height:41px;border-"+strInAlignment+":1px solid black;'><tr>";
	for (strThisSectID in raySectionData)
	{	
		rayThisSection = raySectionData[strThisSectID];
		strThisSectLabel = rayThisSection['label'];
		strThisSectHref = rayThisSection['href'];
		
		if (strThisSectID==strInSelectedItemID)
		{	
			strMenuBarOut += "<td class='selected_menu_item'>"+
				strThisSectLabel+"<"+"/td>";
		}
		else
		{	
			strMenuBarOut += "<td id='tdMenuItem_"+strThisSectID+"' class='menu_item'"+
				" onmouseover=\"enterMbarItem(this,'"+strThisSectID+"')\""+
				" onmouseout=\"exitMbarItem(this)\""+
				" onclick=\"go('"+strThisSectHref+"')\">"+
				strThisSectLabel+"<"+"/td>";
		}
	}
	strMenuBarOut += "</"+"tr></"+"table>";
	return strMenuBarOut;
}



function enterMbarItem(objInItem, strInMenuID)
{	
	if (browser_ie)
	{	
		objInItem.style.background = 'url(images/mbar_item_hover_bg.gif) repeat-x top';
		objInItem.style.cursor = 'pointer';
	}
	
	
	
	/*
		If has menu, display drop-down.
	*/
	if (strInMenuID)
	{	
		/*	cancel drop-down hide timer. */
		clearDropDownTimer();
		
		
		/*
			Populate drop-down
		*/
		objDivDropDown = document.getElementById('divDropDown');
		objDivDropDown.style.visibility='hidden';
		strDropDownContent = renderDropDown(strInMenuID);
		
		if (strDropDownContent)
		{	/*
				if drop-down has content:
				update, position and display.
			*/
			objDivDropDown.innerHTML = strDropDownContent;
			
			/*
				Position drop-down
			*/
			rayItemPos = getObjPos(objInItem);
			intItemLeft = rayItemPos['left'];
			intItemTop = rayItemPos['top'];
			objDivDropDown.style.left = intItemLeft+'px';
			objDivDropDown.style.top = (intItemTop+43+
				(browser_safari ? -9 : 0)+
				(browser_ie ? 1 : 0) )+'px';
			
			/*
				Show drop-down
			*/
			showDropDown();
		}
	}
}

function exitMbarItem(objInItem)
{	
	if (browser_ie)
	{	
		objInItem.style.background = 'url(images/mbar_item_bg.gif) repeat-x top';
		objInItem.style.cursor = 'default';
	}
	
	requestDropDownHide();
}













































/*
	
	Drop-down functions...
	
*/

function renderDropDown(strInMenuID)
{	
	strRenderOut = false;
	
	rayMenuItems = raySectionData[strInMenuID]['children'];
	if (rayMenuItems)
	{	
		strRenderOut = "<table id='tblDropDown' border=0 cellspacing=0 cellpadding=0>";
		
		for (i=0; i < rayMenuItems.length; i++)
		{	
			strRenderOut += "<tr><td"+
				(i==0 ? " class='first_item'":"")+
				" onmouseover='enterDDItem(this)'"+
				" onmouseout='exitDDItem(this)'"+
				" onclick=\"go('"+rayMenuItems[i]['href']+"');\">"+
					rayMenuItems[i]['label']+
				"<"+"/td><"+"/tr>";
		}
		
		strRenderOut += "<"+"/table>";
	}
	
	return strRenderOut;
}

function enterDDItem(objInDDItem)
{	
	if (browser_ie)
	{
		objInDDItem.style.backgroundColor = '#f5da13';
		objInDDItem.style.cursor = 'pointer';
	}
	
	/*	cancel drop-down hide timer. */
	clearDropDownTimer();
}

function exitDDItem(objInDDItem)
{	
	if (browser_ie)
	{
		objInDDItem.style.backgroundColor = '#e9e4c4';
		objInDDItem.style.cursor = 'default';
	}
	
	/*	start drop-down hide timer. */
	requestDropDownHide();
}



var objDropDownTimer = null;
var intDropDownWait = 1000;

function startDropDownTimer(strInTimerCode)
{	
	clearDropDownTimer();
	objDropDownTimer = setTimeout(strInTimerCode, intDropDownWait);
}
function clearDropDownTimer()
{	
	clearTimeout(objDropDownTimer);
}

function showDropDown()
{	
	objDivDropDown = document.getElementById('divDropDown');
	objDivDropDown.style.visibility = 'visible';
}

function hideDropDown()
{	
	objDivDropDown = document.getElementById('divDropDown');
	objDivDropDown.style.visibility = 'hidden';
}
function requestDropDownHide()
{
	startDropDownTimer("hideDropDown()",intDropDownWait);
}

































































/*
	
	Left panel functions...
	
*/
var intLPHoverMaxLeft = -50;
var intLPHoverMinLeft = -280;
var intLPTimerWait = 25;
var intLPMoveAmount = 10;
var objLPDeselectTimer = null;
var objLPSelectTimer = null;
var strLPSelectedItemID = null;
var booAllowLPSelection = true;



function renderLeftPanel(strInSelectedItemID)
{	
	strLPSelectedItemID = strInSelectedItemID;
	rayThisSection = raySectionData[strSectionID];
	
	strLeftPanelOut = "<table id='tblLeftPanel' border=0 cellspacing=0 cellpadding=0>"+
		"<tr><td style='width:10px;height:10px;'>"+
				"<img src='images/LP_corner_TL.gif' width=10 height=10 border=0><"+"/td>"+
			"<td style='width:220px;'><"+"/td>"+
			"<td align='right' style='width:10px;height:10px;'>"+
				"<img src='images/LP_corner_TR.gif' width=10 height=10 border=0><"+"/td>"+
		"<"+"/tr><tr><td colspan=3 id='tdLeftPanelTitle'>"+
				rayThisSection['label']+
			"<"+"/td><"+"/tr>";
	
	raySectionItems = rayThisSection['children'];
	if (raySectionItems)
	{	
		for (i=0; i < raySectionItems.length; i++)
		{	
			rayThisItem = raySectionItems[i];
			strLeftPanelOut += "<tr><td colspan=3 id='tdLP_"+rayThisItem['id']+
				"' class='LeftPanel"+(strInSelectedItemID==rayThisItem['id']?'Selected':'')+"Item'"+
				" onmouseover=\"enterLPItem(this)\""+
				" onmouseout=\"exitLPItem(this)\""+
				" onclick=\"goSubPage('"+rayThisItem['id']+"')\">"+
				rayThisItem['label']+
				"<"+"/td><"+"/tr>";
			
		}
	}
	
	strLeftPanelOut += "<tr><td colspan=3 style='height:60px;'>&nbsp;<"+"/td><"+"/tr>"+
			"<tr><td style='width:10px;height:10px;'>"+
			"<img src='images/LP_corner_BL.gif' width=10 height=10 border=0><"+"/td>"+
			"<td style='width:220px;'><"+"/td>"+
			"<td align='right' style='width:10px;height:10px;'>"+
				"<img src='images/LP_corner_BR.gif' width=10 height=10 border=0><"+"/td>"+
		"<"+"/tr><"+"/table>";
	
	return strLeftPanelOut;
}



function enterLPItem(objInItem)
{	
	booContinue = (typeof(objInItem.in_motion) == 'undefined');
	booContinue = booContinue || (!objInItem.in_motion);
	booContinue = booContinue && (objInItem.className != 'LeftPanelSelectedItem');
	
	if (booContinue)
	{	
		if (browser_ie)
		{	objInItem.style.cursor='pointer'; }
		
		objInItem.style.backgroundImage='url(images/LP_hover60_bg.gif)';
		objInItem.style.backgroundRepeat = 'no-repeat';
		objInItem.style.backgroundPosition = (intLPHoverMaxLeft)+'px 0px';
	}
}

function exitLPItem(objInItem)
{	
	booContinue = (typeof(objInItem.in_motion) == 'undefined');
	booContinue = booContinue || (!objInItem.in_motion);
	booContinue = booContinue && (objInItem.className != 'LeftPanelSelectedItem');
	
	if (booContinue)
	{	
		if (browser_ie)
		{	objInItem.style.cursor='default'; }
		
		objInItem.style.backgroundPosition = intLPHoverMinLeft+'px 0px';
	}
}



/*
	Left panel animation functions...
*/
function deselectLPItem(strInDeselectItemID)
{	
	clearTimeout(objLPDeselectTimer);
	if (strInDeselectItemID)
	{
		/* get current bg position */
		objMenuItemTD = document.getElementById("tdLP_"+strInDeselectItemID);
		objMenuItemTD.in_motion = true;
		strBgPosition = objMenuItemTD.style.backgroundPosition;
		
		intCurrentLeft = intLPHoverMaxLeft;
		if (strBgPosition)
		{	rayBgPosition = strBgPosition.split(' ');
			strBgLeft = rayBgPosition[0];
			if (strBgLeft) intCurrentLeft = new Number(strBgLeft.replace(/px/,''));
		}
		
		/*	calculate new positon. */
		intCurrentLeft -= intLPMoveAmount;
		if (intCurrentLeft < intLPHoverMinLeft) intCurrentLeft = intLPHoverMinLeft;
		
		/*	update position. */
		objMenuItemTD.style.backgroundPosition = intCurrentLeft+'px 0px';
		
		/*	continue loop if not finished. */
		if (intCurrentLeft > intLPHoverMinLeft)
		{	
			objLPDeselectTimer = setTimeout("deselectLPItem('"+strInDeselectItemID+"')",intLPTimerWait);
		}
		else
		{	
			/*
				deselection complete.
			*/
			objMenuItemTD.className = 'LeftPanelItem';
			objMenuItemTD.in_motion = false;
		}
	}
}


function selectLPItem(strInSelectItemID)
{	
	clearTimeout(objLPSelectTimer);
	if (strInSelectItemID)
	{
		/* get current bg position */
		objMenuItemTD = document.getElementById("tdLP_"+strInSelectItemID);
		objMenuItemTD.in_motion = true;
		strBgPosition = objMenuItemTD.style.backgroundPosition;
		
		intCurrentLeft = intLPHoverMinLeft;
		if (strBgPosition)
		{	rayBgPosition = strBgPosition.split(' ');
			strBgLeft = rayBgPosition[0];
			if (strBgLeft) intCurrentLeft = new Number(strBgLeft.replace(/px/,''));
		}
		
		/*	calculate new positon. */
		intCurrentLeft += intLPMoveAmount;
		if (intCurrentLeft > intLPHoverMaxLeft) intCurrentLeft = intLPHoverMaxLeft;
		
		/*	update position. */
		objMenuItemTD.style.backgroundImage='url(images/LP_selected60_bg.gif)';
		objMenuItemTD.style.backgroundRepeat = 'no-repeat';
		objMenuItemTD.style.backgroundPosition = intCurrentLeft+'px 0px';
		
		/* debug  alert("selectLPItem("+strInItemID+") "+objMenuItemTD.style.backgroundPosition);*/
		
		/*	continue loop if not finished. */
		if (intCurrentLeft < intLPHoverMaxLeft)
		{	
			objLPSelectTimer = setTimeout("selectLPItem('"+strInSelectItemID+"')",intLPTimerWait);
		}
		else
		{	
			/*
				deselection complete.
			*/
			objMenuItemTD.className = 'LeftPanelSelectedItem';
			objMenuItemTD.in_motion = false;
			strLPSelectedItemID = strInSelectItemID;
			booAllowLPSelection = true;
		}
	}
}

function goSubPage(strInPageID)
{	
	strSubPageID = strInPageID;
	reqestSelectLPItem(strInPageID);
	refreshNavPanel();
}

function reqestSelectLPItem(strInItemID)
{	
	if ((strLPSelectedItemID != strInItemID) && booAllowLPSelection)
	{
		booAllowLPSelection = false;
		
		/*
			Begin left-panel update.
		*/
		if (strLPSelectedItemID) deselectLPItem(strLPSelectedItemID);
		exitLPItem(document.getElementById('tdLP_'+strInItemID));
		selectLPItem(strInItemID);
		
		/*
			Begin right-panel update.
		*/
		requestSubPage(strInItemID);
	}
}
































































/*
	
	Right panel functions...
	
*/
var strCurrentSubPageID = null;

function renderRightPanel(strInSubPageID)
{	
	/*
		remove and return content from specified sub-page's storage div.
	*/
	objDivStorage = document.getElementById('divSubPage_'+strInSubPageID);
	if (objDivStorage)
	{	
		strCurrentSubPageID = strInSubPageID;
		strTemp = objDivStorage.innerHTML;
		objDivStorage = "";
		return strTemp;
	}
	else
	{	return "ERROR: sub-page '"+strInSubPageID+"' not found."; }
}

function updateRightPanel(strInSubPageID)
{	
	objDivRightPanel = document.getElementById('divSubPageContent');
	
	/*
		Restore current sub-page content to storage div.
	*/
	if (strCurrentSubPageID)
	{	
		objDivStorage = document.getElementById('divSubPage_'+strCurrentSubPageID);
		strTemp = objDivRightPanel.innerHTML;
		objDivRightPanel.innerHTML = "";
		objDivStorage.innerHTML = strTemp;
	}
	
	
	/*
		Populate right panel with passed sub-page's content.
	*/
	objDivRightPanel.innerHTML = renderRightPanel(strInSubPageID);
}




function requestSubPage(strInSubPageID)
{	
	createSequence("requestSubPage");
	addToSequence("requestSubPage", "hideRightPanel(\"resumeSequence('requestSubPage')\")");
	addToSequence("requestSubPage", "updateRightPanel('"+strInSubPageID+"');"+
		"resumeSequence('requestSubPage');");
	addToSequence("requestSubPage", "showRightPanel(\"resumeSequence('requestSubPage')\")");
	
	resumeSequence("requestSubPage");
}




/*
	Fade in/out functions...
*/
var objRPHideTimer = null;
var objRPShowTimer = null;
var intRPFadeAmount = 10;
var intRPFadeWait = 25;

function hideRightPanel(strInFinishCode)
{	
	objDivRightPanel = document.getElementById('divSubPageContent');
	
	if (!objDivRightPanel.current_opacity) objDivRightPanel.current_opacity=100;
	
	objDivRightPanel.current_opacity -= intRPFadeAmount;
	if (objDivRightPanel.current_opacity < 0)
	{	objDivRightPanel.current_opacity = 0; }
	setOpacity(objDivRightPanel, objDivRightPanel.current_opacity);
	
	if (objDivRightPanel.current_opacity > 0)
	{	
		/*
			Loop until zero opacity.
		*/
		objRPHideTimer = setTimeout("hideRightPanel(\""+strInFinishCode+"\")", intRPFadeWait);
	}
	else
	if (strInFinishCode)
	{		
		objRPHideTimer = setTimeout(strInFinishCode, intRPFadeWait);
	}
}

function showRightPanel(strInFinishCode)
{	
	objDivRightPanel = document.getElementById('divSubPageContent');
	
	if (!objDivRightPanel.current_opacity) objDivRightPanel.current_opacity=0;
	
	objDivRightPanel.current_opacity += intRPFadeAmount;
	if (objDivRightPanel.current_opacity > 100)
	{	objDivRightPanel.current_opacity = 100; }
	setOpacity(objDivRightPanel, objDivRightPanel.current_opacity);
	
	if (objDivRightPanel.current_opacity < 100)
	{	
		/*
			Loop until full opacity.
		*/
		objRPShowTimer = setTimeout("showRightPanel(\""+strInFinishCode+"\")", intRPFadeWait);
	}
	else
	if (strInFinishCode)
	{		
		objRPShowTimer = setTimeout(strInFinishCode, intRPFadeWait);
		if (browser_ie)
		{	objDivRightPanel.style.zoom = '0'; }
	}
}































































/*
	
	general purpose functions...
	
*/
function renderRoundPanel(strInPanelContent, strInPathMod, strInPanelColor)
{	
	if (!strInPathMod) strInPathMod='';
	if (!strInPanelColor) strInPanelColor = '#faec89';
	strCurvesImgUrl = strInPathMod+"images/curves_large."+(browser_ie6?'gif':'png');
	
	return "<table class='tblRoundPanel' border=0 cellspacing=0 cellpadding=0 "+
		"style='background:"+strInPanelColor+";'>"+
		"<tr><td style='width:10px;vertical-align:top;'><div "+
			"style='position:relative; overflow:hidden;"+
			"width:10px;height:10px; background-repeat: no-repeat;"+
			"background-image:url("+strCurvesImgUrl+");"+
			"background-position: -10px -50px;'></div></td>"+
		"<td rowspan=2 class='content'>"+
			strInPanelContent+
		"</td>"+
		"<td style='width:10px;vertical-align:top;'><div "+
			"style='position:relative; overflow:hidden;"+
			"width:10px;height:10px;"+
			"background-image:url("+strCurvesImgUrl+");"+
			"background-position: -20px -50px;'></div></td>"+
		"</tr><tr><td style='width:10px;vertical-align:bottom;'><div "+
			"style='position:relative; overflow:hidden;"+
			"width:10px;height:10px; background-repeat: no-repeat;"+
			"background-image:url("+strCurvesImgUrl+");"+
			"background-position: -10px -60px;'></div></td>"+
		"<td style='width:10px;vertical-align:bottom;'><div "+
			"style='position:relative;overflow:hidden;"+
			"width:10px;height:10px; background-repeat: no-repeat;"+
			"background-image:url("+strCurvesImgUrl+");"+
			"background-position: -20px -60px;'></div></td>"+
		"</tr></table>";
}