// --------------------------------------------
// JavaScript functions used by toprow.asp file
// Created:  4/3/2007 by Patricia Lentz, intern
// Last update: 
// 2009.03.25 Rolland Huie - adjusted menu options
// 4/24/2007, Patricia Lentz  
// --------------------------------------------

/* Arrays to store the menu items
	Set up for pull-down menus:  [Menu button] ["yes"] [Horizontal padding in pixels] [anchor id name] [div id name] [1st submenu link, 1st submenu name] [2nd submenu link, 2nd submenu name] ...  
	Set up for plain menus:      [Menu button] [link] [Horizontal padding in pixels (not used, but handy in case you convert it to a pull-down menu)]
*/ 
var menuArray = new Array ( 
		new Array ("Home", "http://www.cincyupdate.com/calendar/calendar.asp", 5 ),
		new Array ("About", "yes", 80, "ButtonAbout", "PopUpMenu1", 
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=HISTORY", "About" ), 
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=FOUNDER", "Founders" ), 
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=FAQ", "FAQ" ) ),  
		new Array ("Event Ambassadors", "yes", 215, "ButtonEA", "PopUpMenu2",
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=EA", "Event Ambassadors" ),
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=BEA", "Membership" ) ),
		new Array	("Sponsors/Partners", "yes", 460, "ButtonSponsor", "PopUpMenu3", 
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=PARTNER", "Partners" ),
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=SPONSOR", "Sponsors" ),
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=BPARTNER", "Be a Partner" ),
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=DONATION", "Make a Donation" ) ),
		new Array ("Cincinnati", "yes", 680, "ButtonCincy", "PopUpMenu4",
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=DYK", "Did You Know" ),
					new Array ( "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=BESTS", "Cincinnati Bests" ) ),
		new Array ("Post an Event", "http://www.cincyupdate.com/calendar/calendar.asp?DoAction=Calendar&CHANGE=EVENT_ADD", 0)
										);

// Here's the main function to get the whole table row created
function CreateMainMenuBar()
{
	document.write( '<tr>' + "\n" );

	// Process each of the menu buttons
	for (i=0; i<menuArray.length; i++)
	{
			document.write( '<td class="quicktoplinks">' + "\n" );

			if (menuArray[i][1] == "yes")		// menu button has a submenu associated with it
			{
					putSubMenu(menuArray[i]);
			}
			else					// menu button does NOT have a submenu
			{
					putPlainButton(menuArray[i]);
			}

			document.write( '</td>' + "\n" );
			document.write( '<td>|</td>' + "\n" );  // pipe symbol goes in between each menu button
	}

	document.write( '</tr>' + "\n" );
}

// We'll need an anchor tag and a division tag before the submenu set is written 
function putSubMenu(WhichMenu)
{
	// First, we need to write the anchor tag
	document.write( '<a id="' + WhichMenu[3] +
									'" class="quicktoplinks" onmouseover="GetMenu(\'' +
													WhichMenu[3] + '\',\'' + WhichMenu[4] + '\',\'' + 
													WhichMenu[2] + '\');"' +
										'onmouseout="SayGoodBye(this);" href=" " ' +
										'onclick="void(0);">' +
										WhichMenu[0] +
										'</a>' + "\n" );

	// Now we write the division tag
	document.write( '<div id="' + WhichMenu[4] +
									'" onmouseout="GoAway(\'' + WhichMenu[4] +
									'\');" onmouseover="PopMeUp(\'' + WhichMenu[4] +
									'\',\'' + WhichMenu[3] + '\',\'' + WhichMenu[2] +
									'\');">' + "\n" );

	// Determine how many items are in that submenu
	// This assumes that the arrays are stored starting in element #5 ([x][5])
	var NumItems = ( WhichMenu.length - 5 ); 

	// Process each item in that submenu
	for (j=0; j<NumItems; j++)
	{
			putSubMenuItem(WhichMenu, j + 5);
	}

	document.write( '</div>' + "\n" );	
}

// Write just the submenu item anchor tag 
function putSubMenuItem(WhichMenu, WhichSub)
{
	document.write( '<a class="MenuItem" onmouseover="PopMeUp(\'' +
					WhichMenu[4] + '\',\'' + WhichMenu[3] + 
					'\',\'' + WhichMenu[2] + '\');" href=\"' + 
					WhichMenu[WhichSub][0] +
					'\">' + WhichMenu[WhichSub][1] + '</a><br />' + "\n" );
}

// Write the anchor tag for menu buttons that don't have a submenu
function putPlainButton(WhichMenu)
{
	document.write( '<a class="quicktoplinks" href=\"' +
									WhichMenu[1] + '\">' + WhichMenu[0] +
									'</a>' + "\n" );
}

// Make the button active
function GetMenu(WhichButton, WhichMenu, HPadding)
{
	var button = document.getElementById(WhichButton);
	button.style.Color = '#333333';
	button.style.backgroundColor = '#ccff99';
	PopMeUp(WhichMenu, WhichButton, HPadding);
}

// Make the button look the way it was
function SayGoodBye(button)
{
	button.style.backgroundColor='#333333';
}

// Make the pull-down menu visible to the user
function PopMeUp(WhichMenu, WhichButton, HPadding)
{
	var menu = document.getElementById(WhichMenu);
	var button = document.getElementById(WhichButton);
	var hPadding = HPadding;		// horizontal padding
	var vPadding = 160;			// vertical padding

	menu.style.position = 'absolute';
	menu.style.top = (vPadding + button.offsetTop + button.offsetHeight)+ 'px';
	menu.style.left = (hPadding) + 'px';
//	menu.style.left = (button.offsetLeft + hPadding) + 'px';
	menu.style.display = 'block';
}

// After a short time delay, make the pull-down menu disappear
function GoAway(WhichMenu)
{
	var menu = document.getElementById(WhichMenu);
	menu.style.display = "none";
	setTimeout(menu, 1000);
}
