///////////////////////////////////
//    Dynamic Folding Menus      //
///////////////////////////////////
///////////////////////////////////
// Written by: C. David Dent <mrdave21764@gmail.com>
// 			   http://wildandbad.com
// (c) 2005 C. David Dent
// Used under the GPL Open Source Licence.
///////////////////////////////////
var menus = Array();
menus[1] = Array(); // Transportation Optons
//menus[1]["Transportation Options"] = "/ridesmart/transportation/index.html";
//menus[1] = "/ridesmart/transportation/index.html";
menus[1]["The Bus"] = "/ridesmart/transportation/bus.html";
menus[1]["Rail"] = "/ridesmart/transportation/rail.html";
menus[1]["Carpooling"] = "/ridesmart/transportation/carpool.html";
menus[1]["Vanpooling"] = "/ridesmart/transportation/vanpool.html";
menus[1]["Walking/Biking"] = "/ridesmart/transportation/walkbike.html";
menus[1]["Telecommuting"] = "/ridesmart/transportation/telecommute.html";
menus[3] = Array(); // Commuter Services
menus[3]["Park and Ride"] = "/ridesmart/commuter/parkandride.html";
menus[3]["Ride Matching"] = "/ridesmart/commuter/ridematch.html";
menus[3]["Trip Planner"] = "/ridesmart/commuter/trip.html";
menus[3]["Guaranteed Ride Home"] = "/ridesmart/commuter/grh.html";
menus[3]["Purchase Transit Passes"] = "/ridesmart/commuter/purchase.html";
menus[3]["Metrochek"] = "/ridesmart/commuter/incentive.html";
menus[5] = Array(); // Employer Services
menus[5]["Employer Guide to Transportation"] = "/ridesmart/employer/index.html";
menus[5]["Employer Programs"] = "/ridesmart/employer/programs.html";
menus[5]["Participating Employers"] = "/ridesmart/employer/participating.html";
menus[7] = Array(); // News and Events
menus[7]["Current News"] = "/ridesmart/news/index.html";
menus[7]["Air Quality Action Days"] = "/ridesmart/news/aquid.html";
menus[7]["Archive"] = "/ridesmart/news/archive.html";
//menus[7]["Register for eNews"] = "/ridesmart/news/enews.html";
menus[9] = "/ridesmart/links.html"; //Transportation Links
// menus[9] = Array(); // Menu does not expand
menus[11] = "/ridesmart/faq.html"; // FAQ
// menus[11] = Array(); // Menu does not expand
menus[13] = Array(); // Contact
menus[13]["Contact Us"] = "/ridesmart/contact/index.html";
menus[13]["Trail Maps"] = "/ridesmart/contact/trailmap.html";
menus[15] = "/ridesmart/index.html";

// Documentation

/* Menus can be "nested" to expand on a click by adding indexed elements.  The order
   for the statements is as follows:
     menus[n] = Array();  // Note that the n is always an odd number.
	 menus[n]['Link Text'] = "url.to.page"; // This can either be a relative or an absolute link.
 * If the menu does not expand then the statements would appear as follows:
     menus[n] = "/path/to/page.html"; // Note that this can be an internal, external, absolute or relative link.

 * In the HEAD of the HTML you can include a script to customize sections.  If a 
	lockOpen value of an expanding section is included, then it will be shown expanded 
	once the page is loaded
	<script>
	// Defaults
	// var lockOpen = 0; // Index Page (Nothing Open)
	// var lockColor = '#ffffff'

 	var lockOpen = 1 // Transportation Options
 	var lockColor = '#E4A50F'; 

	// var lockOpen = 3 // Commuter Services
	// var lockColor ='#BD3108';
	</script>

 * The Menu HTML in the BODY of the page appears as follows:
	<body onLoad = "initMenu('menuTable', lockColor); expandMenu(lockColor, 'menuTable', lockOpen)">
 		<table id="menuTable" border="0" cellpadding="0" cellspacing="0" width="169"> 
          <tr> 
            <td> <a href="#" onClick="expandMenu('#E4A50F', 'menuTable', 1)">Menu Item 1</a></td> 
          </tr> 
          <tr> 
            <td height=1 bgcolor=#FFFFFF><img src="/images/spacer.gif" border=0 height=1 width=1></td> 
          </tr> 
          <tr> 
            <td><a href="#" onClick="expandMenu('#bd3108', 'menuTable', 3)">Menu Item 2</a></td> 
          </tr> 
          <tr> 
            <td height=1 bgcolor=#FFFFFF><img src="/images/spacer.gif" border=0 height=1 width=1></td> 
          </tr>
		  <!-- ... -->
		</table>
	 </body>
	 
 * These Styles are part of the specific design:
	.menuLink { background-color:#47484C;  border-left: 9px solid #FFFFFF; border-top: 0px; border-bottom: 0px; border-right: 0px; padding-left: 24px; padding-bottom: 8px;}
	.menuLink a {font-size: 12px; color:#FFFFFF; line-height: 125%; text-decoration: none}
	.menuLink a:hover {text-decoration: underline}
	
*/ 
/***********************************************************************/
/********  THERE IS NO NEED TO MODIFY ANYTHING BELOW THIS LINE  ********/
/***********************************************************************/

function initMenu (elemID, elemColor) {
	  openItem = document.getElementById(elemID);
	  for(i=1; i < openItem.rows.length; i += 2) {
         openItem.rows[i].cells[0].innerHTML = '';
	  }
}

function expandMenu(elemColor, elemID, rowNum) {
  openItem = document.getElementById(elemID);
  // close all open panels
  toggle = false;
  if (rowNum/2 == Math.floor(rowNum/2)) toggle = true;
  for(i=1; i < openItem.rows.length; i += 2){
   if(i==rowNum && openItem.rows[i].cells[0].innerHTML != '') toggle = true;
   openItem.rows[i].cells[0].innerHTML = '';
  } 
  if (toggle) return;
  if(typeof menus[rowNum] == 'object') {
	 newMenu = '<div class=menuLink style="border-color: ' + elemColor + ';">'
	 for(linkName in menus[rowNum]){
   		linkURL = menus[rowNum][linkName]
   		newMenu = newMenu + '<a href="' + linkURL + '">' + linkName + '</a><br>';
 	}
 	newMenu = newMenu + '</div><img src="/images/spacer.gif" border=0 height=1 width=1>';
 	openItem.rows[rowNum].cells[0].innerHTML =newMenu;
  } else {
	location.href = menus[rowNum] ;
  }
}