/**
This group of variables and functions is for showing the subsections
within a page.  Those are defined by page content set in

  div id="label"

tags, labels are ssA, ssB, ssC, etc. as in the style sheet.  Showing
a section is done by

   <a href="#" onmouseover="show('label'); return false;" onmouseout="showNormal(); return false;" onclick="setNormal('label', this); return false;">label</a>
*/


  var subsectShown = "ssA";
  var subsectNormal = "ssA";
  var subsectNormalAnchor;
  
  function subsectShow(id){
    document.getElementById(subsectShown).style.visibility="hidden";
    document.getElementById(id).style.visibility="visible";
    subsectShown = id;
  }







/**
This group of functions is for the link menu bar along the top of the page.
The menu bar HTML has the following structure:
	<div id="menubar">
		<li><a href="#" onmouseover="menuShow('m1')" onmouseout="menuScheduleHide()">Name</a>
			<div id="m1" onmouseover="menuCancelHide()" onmouseout="menuScheduleHide()">
				<a href="URL">name</a>
				...
			</div>
		</li>
	...

The style sheet handles the changes in appearance for moving over a bar.  The script 
below makes the sub-menu DIV appear when the bar is selected.
*/

var mbActive = null;
var mbTimer;

function menuShow(id) {
  menuCancelHide();
  menuHide();
  mbActive = document.getElementById(id);
  mbActive.style.visibility="visible";
}

function menuHide() {
  if (mbActive != null) mbActive.style.visibility="hidden";
  mbActive = null;
}

function menuScheduleHide() {
  mbTimer = window.setTimeout(menuHide, 500);
}
function menuCancelHide() {
  if (mbTimer != null) {
    window.clearTimeout(mbTimer);
  }
  mbTimer = null;
}

document.onclick=menuHide;






/** For generating the image menu bar and pulldown menu bar in each subpage. */

function writeMenuBars(sub) {
	var prepend = "";
	if (sub == 1) prepend = "../";
	if (sub == 2) prepend = "../../";
	document.writeln('<div id="menubar">');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('worship.html">Worship</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('music.html">Music</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('outreach.html">Outreach</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('adults.html">Adults</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('youth.html">Youth</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('children.html">Kid Stuff</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('social.html">Social Activities</a>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('index.html" onmouseover="menuShow(\'mb1\')" onmouseout="menuScheduleHide()">Home</a>');
	document.writeln('    <div id="mb1" onmouseover="menuCancelHide()" onmouseout="menuScheduleHide()">');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('index.html">Home Page</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('guests.html">Welcome, Guests</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('team/team.html">Meet the Team</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('schedule.html">Schedule</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('directions.html">Directions</a>');
	document.writeln('    </div>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('news/news.html" onmouseover="menuShow(\'mb2\')" onmouseout="menuScheduleHide()">News & Calendar</a>');
	document.writeln('    <div id="mb2" onmouseover="menuCancelHide()" onmouseout="menuScheduleHide()">');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('news/news.html">Weekly News</a>');
	document.write  ('      <a href="http://www.MyChurchEvents.com/calendar/calendar.aspx?ci=L6J4N8J4I3F0O9N8H2" target="_blank">Calendar</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('news/tidings.html">E-Tidings Newsletter</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('news/parentlink.html">ParentLink Newsletter</a>');
	document.writeln('    </div>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('outreach.html" onmouseover="menuShow(\'mb3\')" onmouseout="menuScheduleHide()">Teams</a>');
	document.writeln('    <div id="mb3" onmouseover="menuCancelHide()" onmouseout="menuScheduleHide()">');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('missions/missions.html">Missions Team</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('ministries/stewardship.html">Stewardship Team</a>');
	document.write  ('      <a href="http://churchandsocietyteam.pbworks.com" target="_blank">Church and Society Team</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('news/history.html">Church History Team</a>');
	document.writeln('    </div>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('ministries/index.html" onmouseover="menuShow(\'mb4\')" onmouseout="menuScheduleHide()">Ministries</a>');
	document.writeln('    <div id="mb4" onmouseover="menuCancelHide()" onmouseout="menuScheduleHide()">');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('ministries/jobsclub.html">Jobs Club</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('ministries/parish_nurses.html">Parish Nurses</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('ministries/hearing.html">Hearing Committee</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('seasonal/plantsale.html">Plant Sale</a>');
	document.writeln('    </div>');
	document.writeln('  </li>');

	document.writeln('  <li><a href="'); document.write(prepend); document.writeln('studies/index.html" onmouseover="menuShow(\'mb5\')" onmouseout="menuScheduleHide()">Study</a>');
	document.writeln('    <div id="mb5" onmouseover="menuCancelHide()" onmouseout="menuScheduleHide()">');
	document.write  ('      <a href="http://www.willsfamily.org/kairos/index.html" target="_blank">Kairos Class</a>');
	document.write  ('      <a href="'); document.write(prepend); document.writeln('opencircle/index.html" target="_blank">Open Circle Class</a>');
	document.writeln('    </div>');
	document.writeln('  </li>');

	document.writeln('</div><div style="clear:both"></div>');
}


/** For generating all boilerplate page content. */
function writeCUMCBoilerplate(sub) {
	writeMenuBars(sub);
	document.writeln('<div id="bottomsection">');
	document.writeln('<a target="_blank" href="http://maps.google.com/maps?f=q&source=s_q&hl=en&q=20+N+Center+St,+Naperville,+IL+60540">20 N. Center Street, Naperville, IL</a>');
	document.writeln('&nbsp;&nbsp;&bull;&nbsp;&nbsp;630&bull;355&bull;1483&nbsp;&nbsp;&bull;&nbsp;&nbsp;');
	document.writeln('<a href="mailto:info@communityunitedmethodist.org">info@communityunitedmethodist.org</a></div>');
}
