/* 

HORIZONTAL DROP DOWN MENUS

Written by Don Charlton
Wall-to-Wall Studios
May 30 2006


BROWSER					VERSIONS			NOTES
-------					--------			-----
Mac IE					--					No longer supporting browser
Mac Firefox				1.04
Mac Netscape			7.2
Mac Safari				2.03
PC IE					7.0					One extra pixel above nav divs
PC Netscape				7.2
PC Firefox				1.04


*/


var vSpaceBetween = 0;

/* ------------------------------------------------------------------------------------
GENERATES HOME PAGE TABLE FOR PRIMARY NAVIGATION AND DROP DOWN MENUS
------------------------------------------------------------------------------------ */

function fGenerateMainNavigation() {
		var counter=1;
		// If it's the home, plan to include the home link, else no by setting the starting point in the array.
		if ( !vHome ){
			vStartNum = 0;
			vNavWidth = 773;
		}else{
			vStartNum = 1;
			vNavWidth = 600;
		}
		// Write the navigation table
		document.write( '<table id="navTable" width="' + vNavWidth + '" cellpadding="0" cellspacing="0" border="0"><tr>' );
		// Loop through the sections and print to the page
		for ( i=vStartNum; i<vSectionArray.length; i++ ) {
			
			// Create the table data cell, and if this is the home page...
			if ( i == 0 ){
				document.write( '<td id="cell' + vSectionArray[i][2] + '" valign="top" width="174">' );
			} else {
				document.write( '<td id="cell' + vSectionArray[i][2] + '" valign="top">' );
			}
			// Create the main nav <div> wrapped in a link (turn on if this is the current section)
			if ( i == 0 ){
				document.write( '<a class="menulink" href="index.php"><div  onMouseOut="fPrimaryRollOver(\'out\',' + vSectionArray[i][2] + ');" onMouseOver="fPrimaryRollOver(\'over\',' + vSectionArray[i][2] + ');" class="menuDiv" id="nav' + i + '" style="text-align:left; padding-left: 15px; border: 0px;"><span onMouseOver="this.style.textDecoration=\'underline\'" onMouseOut="this.style.textDecoration=\'none\'">'  + vSectionArray[i][0] + '</span></div></a>' );
			} else if ( i != vCurrSection ){
				document.write( '<a class="menulink" href="'+vSectionArray[i][4]+'?pageID='+vSectionArray[i][1]+'"><div onMouseOut="fPrimaryRollOver(\'out\',' + vSectionArray[i][2] + ');" onMouseOver="fPrimaryRollOver(\'over\',' + vSectionArray[i][2] + ');" class="menuDiv" id="nav' + vSectionArray[i][2] + '""><span id="text' + vSectionArray[i][2] + '" onMouseOver="this.style.textDecoration=\'underline\'" onMouseOut="this.style.textDecoration=\'none\'">'  + vSectionArray[i][0] + '</span></div></a>' );
			} else {
				document.write( '<a class="menulink" href="'+vSectionArray[i][4]+'?pageID='+vSectionArray[i][1]+'"><div onMouseOut="fPrimaryRollOver(\'out\',' + vSectionArray[i][2] + ');" onMouseOver="fPrimaryRollOver(\'over\',' + vSectionArray[i][2] + ');" class="menuDivCurrent" id="nav' + vSectionArray[i][2] + '"">'  + vSectionArray[i][0] + '</div></a>' );
			}
			// Create the drop down menu if this is not the home page
				//if(vSubSectionArray[vSectionArray[i][2]].length > 0) {
					document.write( '<div onMouseOut="fPrimaryRollOver(\'out\',' + vSectionArray[i][2] + ');" onMouseOver="fPrimaryRollOver(\'over\',' + vSectionArray[i][2] + ');" id="menu' + vSectionArray[i][2] + '"' );
					
					//works on the DEV server - ON the llive serve has to read vSubSectionArray[vSectionArray[i][2]].length
					if ( i != 0 && vSubSectionArray[vSectionArray[i][2]]){
							document.write(' class="dropmenu">')
							// Insert drop down contents
							document.write( '<ul>' );
							for(y=0;y<=vSubSectionArray[vSectionArray[i][2]].length-1;y++) {
								document.write( 	'<li><a href="'+vSubSectionArray[vSectionArray[i][2]][y][4]+'?pageID='+vSubSectionArray[vSectionArray[i][2]][y][1]+'">'+vSubSectionArray[vSectionArray[i][2]][y][0]+'</a></li>' );
								//ADDED FOR CARNEDIE CAN BE REMOVED WITHOUT REPURCUSSION
								if(i==3 && y==vSubSectionArray[i].length-1) {
									document.write( 	'<li><a href="http://cmp.convio.net/site/PageServer?pagename=member_home" target="_blank">MyMuseums</a></li>' );
									document.write( 	'<li><a href="https://secure2.convio.net/cmp/site/ConsProfileUser?JServSessionIdr011=fvl1hp0vj3.app6b" target="_blank">Manage My Profile</a></li>' );
								}
								//========================================
							}
							document.write( '</ul>' );
							document.write( '</div>' );
							var vMenuToEvaluate = document.getElementById( "menu" + vSectionArray[i][2] );
							vMenuToEvaluate.style.position = "absolute";
					} else {
						document.write('>');
					}
				}
			// Close the table cell
			
			document.write( '</td>' );
			counter++;
		//}
		// Close table
		document.write( '</tr></table>' );
}


/* ------------------------------------------------------------------------------------
ROLLOVER FUNCTIONS FOR MAIN NAVIGATION
------------------------------------------------------------------------------------ */
function fPrimaryRollOver(pStatus, pDivToAffect) {
		// If this is the home, only change colors on rollovers.
		if ( pDivToAffect == 0 ){
			if ( pStatus == "over" ){
				// fRollOverStyles(pDivToAffect);
			} else {
				// fRollOutStyles(pDivToAffect);
			}
		} else {
			// Store the current div in a variable
			var vMenuToEvaluate = $(document.getElementById( "menu" + pDivToAffect ));
			var vMenuLink = $(document.getElementById( "nav" + pDivToAffect )).children("a").eq(0);
			
			var vMenuToEvaluateDisplay = vMenuToEvaluate.css("display");
			// alert(vMenuToEvaluateDisplay);
			
			if(vMenuToEvaluateDisplay == "none") {
				vMenuToEvaluate.show();
				vMenuLink.parent().addClass("enabled");
			}
			else {
				vMenuToEvaluate.hide();
				vMenuLink.parent().removeClass("enabled");
			}
			
			// If this is hidden show menu and change styles.
			// if ( vMenuToEvaluate.style.visibility == "visible" ) {
				// fRollOutStyles(pDivToAffect);
				// vMenuToEvaluate.style.visibility = "hidden";
			// } else {
			// If this is visible hide menu and change styles.
				// fRollOverStyles(pDivToAffect);
				// vMenuToEvaluate.style.visibility = "visible";
			// }
		}
		
}


/* ------------------------------------------------------------------------------------
CHANGES STYLES ON ROLLOVER OF MAIN NAV
------------------------------------------------------------------------------------ */
function fRollOverStyles( pDivToChangeStyles ) {
		// Get the nav section
		var vCellToEvaluate = document.getElementById( "nav" + pDivToChangeStyles );
		// Manipulate styles as needed
		vCellToEvaluate.style.color = "#ABB2B6";
}


/* ------------------------------------------------------------------------------------
CHANGES STYLES ON ROLLOUT OF MAIN NAV
------------------------------------------------------------------------------------ */
function fRollOutStyles( pDivToChangeStyles ) {
		// Get the nav section
		var vCellToEvaluate = document.getElementById( "nav" + pDivToChangeStyles );
		// Manipulate styles as needed
		if( pDivToChangeStyles == vCurrSection ){
			vCellToEvaluate.style.background = "none";
			vCellToEvaluate.style.color = "#ABB2B6";
		} else {
			vCellToEvaluate.style.background = "none";
			vCellToEvaluate.style.color = "#FFFFFF";
		}
}


