﻿/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.gif","button2up.gif","button3up.gif","button4up.gif","button5up.gif","button6up.gif","button7up.gif","button8up.gif","button9up.gif","button10up.gif","button11up.gif","button12up.gif","button13up.gif","button14up.gif","button15up.gif","button16up.gif","button17up.gif","button18up.gif","button19up.gif","button20up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif","button8over.gif","button9over.gif","button10over.gif","button11over.gif","button12over.gif","button13over.gif","button14over.gif","button15over.gif","button16over.gif","button17over.gif","button18over.gif","button19over.gif","button20over.gif");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array();
subInfo[2] = new Array();
subInfo[3] = new Array();
subInfo[4] = new Array();
subInfo[5] = new Array();
subInfo[6] = new Array();
subInfo[7] = new Array();
subInfo[8] = new Array();
subInfo[9] = new Array();
subInfo[10] = new Array();
subInfo[11] = new Array();
subInfo[12] = new Array();
subInfo[13] = new Array();
subInfo[14] = new Array();
subInfo[15] = new Array();
subInfo[16] = new Array();
subInfo[17] = new Array();
subInfo[18] = new Array();
subInfo[19] = new Array();
subInfo[20] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[1][1] = new Array("Home","http://www.NuttyPuttyCave.com/index.html","");
subInfo[1][2] = new Array("Trip Planner","http://www.NuttyPuttyCave.com/trip_planner.html","");
subInfo[1][3] = new Array("BLOWHOLE","http://www.NuttyPuttyCave.com/trip_plannerBH.html","");
subInfo[1][4] = new Array("FAQs","http://www.NuttyPuttyCave.com/faq.html","");
subInfo[1][5] = new Array("Need a Guide","http://www.nuttyputtycave.com/matchup.html","");

subInfo[2][1] = new Array("Cave History","http://www.NuttyPuttyCave.com/history.html","");
subInfo[2][2] = new Array("Timeline","http://www.NuttyPuttyCave.com/history.html#Timeline","");
subInfo[2][3] = new Array("Geology","http://www.NuttyPuttyCave.com/geology.html","");
subInfo[2][4] = new Array("Access History","http://www.NuttyPuttyCave.com/access.html","");
subInfo[2][5] = new Array("Group Pics","http://www.NuttyPuttyCave.com/gallery.html","");

subInfo[3][1] = new Array("Management","http://www.NuttyPuttyCave.com/management.html","");
subInfo[3][2] = new Array("2009 Plan","http://www.NuttyPuttyCave.com/management2009.html","");
subInfo[3][3] = new Array("Team Duties","http://www.NuttyPuttyCave.com/management_responsibilities.html","");
subInfo[3][4] = new Array("Inspection Form","http://www.NuttyPuttyCave.com/inspection_report.html","");
subInfo[3][5] = new Array("Cave Rules","http://www.NuttyPuttyCave.com/rules.html","");
subInfo[3][6] = new Array("FAQs","http://www.NuttyPuttyCave.com/faq.html","");

subInfo[4][1] = new Array("Projects","http://www.NuttyPuttyCave.com/projects.html","");
subInfo[4][2] = new Array("Ethics","http://www.NuttyPuttyCave.com/ethics.html","");

subInfo[5][1] = new Array("Gated Caves","http://www.NuttyPuttyCave.com/gated.html","");
subInfo[5][2] = new Array("Access","http://www.NuttyPuttyCave.com/access.html","");

subInfo[6][1] = new Array("Reservations","http://www.NuttyPuttyCave.com/reservations.html","");
subInfo[6][2] = new Array("Trip Planner","http://www.NuttyPuttyCave.com/trip_planner.html","");
subInfo[6][3] = new Array("BLOWHOLE","http://www.NuttyPuttyCave.com/trip_plannerBH.html","");
subInfo[6][4] = new Array("Camping","http://www.NuttyPuttyCave.com/camping.html","");
subInfo[6][5] = new Array("Need a Guide","http://www.nuttyputtycave.com/matchup.html","");

subInfo[7][1] = new Array("NUTTY PUTTY","http://www.NuttyPuttyCave.com/forms.html","");
subInfo[7][2] = new Array("NP-Waiver","http://www.NuttyPuttyCave.com/waiver.html","");
subInfo[7][3] = new Array("NP-Under 18","http://www.NuttyPuttyCave.com/under_18_permission.html","");
subInfo[7][4] = new Array("NP-Vehicles","http://www.NuttyPuttyCave.com/vehicles.html","");
subInfo[7][5] = new Array("BLOWHOLE","http://www.NuttyPuttyCave.com/forms.html","");
subInfo[7][6] = new Array("BH-Waiver","http://www.NuttyPuttyCave.com/forms.html","");
subInfo[7][7] = new Array("BH-Under 18","http://www.NuttyPuttyCave.com/forms.html","");
subInfo[7][8] = new Array("BL-Vehicles","http://www.NuttyPuttyCave.com/forms.html","");

subInfo[8][1] = new Array("NP-Access Permit","http://www.NuttyPuttyCave.com/permit.html","");
subInfo[8][2] = new Array("Access","http://www.NuttyPuttyCave.com/access.html","");
subInfo[8][3] = new Array("FAQs","http://www.NuttyPuttyCave.com/faq.html","");
subInfo[8][4] = new Array("Camping","http://www.NuttyPuttyCave.com/camping.html","");
subInfo[8][5] = new Array("BLOWHOLE-Permit","http://www.NuttyPuttyCave.com/permit_blowhole.html","");

subInfo[9][1] = new Array("Payment","http://www.NuttyPuttyCave.com/payment.html","");

subInfo[10][1] = new Array("Trip Reports","http://www.NuttyPuttyCave.com/trip_reports.html","");
subInfo[10][2] = new Array("Group Pics","http://www.NuttyPuttyCave.com/gallery.html","");

subInfo[11][1] = new Array("Directions","http://www.NuttyPuttyCave.com/directions.html","");
subInfo[11][2] = new Array("Access","http://www.NuttyPuttyCave.com/access.html","");

subInfo[12][1] = new Array("Cave Maps","http://www.NuttyPuttyCave.com/maps.html","");

subInfo[13][1] = new Array("Trainings","http://www.NuttyPuttyCave.com/trainings.html","");

subInfo[14][1] = new Array("Equipment","http://www.NuttyPuttyCave.com/equipment.html","");

subInfo[15][1] = new Array("Youth Groups","http://www.NuttyPuttyCave.com/youth.html","");
subInfo[15][2] = new Array("BSA","http://www.NuttyPuttyCave.com/affiliations.html","");
subInfo[15][3] = new Array("BSA Policy","http://www.NuttyPuttyCave.com/YBSACavingPolicy.html","");
subInfo[15][4] = new Array("Camping","http://www.NuttyPuttyCave.com/camping.html","");

subInfo[16][1] = new Array("Cave News","http://www.NuttyPuttyCave.com/news.html","");
subInfo[16][2] = new Array("Timeline","http://www.NuttyPuttyCave.com/history.html#Timeline","");
subInfo[16][3] = new Array("History","http://www.NuttyPuttyCave.com/history.html","");
subInfo[16][4] = new Array("Newsletter","http://www.NuttyPuttyCave.com/np_newsletter.html","");
subInfo[16][5] = new Array("--6/16/2009","http://www.nuttyputtycave.com/Newsletter/June162009.html","");

subInfo[17][1] = new Array("Art & Photos","http://www.NuttyPuttyCave.com/photos.html","");
subInfo[17][2] = new Array("--Acklin","http://www.NuttyPuttyCave.com/art_acklin.html","");
subInfo[17][3] = new Array("---Andy Acklin","http://www.NuttyPuttyCave.com/Y_CA_Andy.html","");
subInfo[17][4] = new Array("--Powers","http://www.NuttyPuttyCave.com/art_powers.html","");
subInfo[17][5] = new Array("Group Gallery","http://www.NuttyPuttyCave.com/gallery.html","");

subInfo[18][1] = new Array("Caving Links","http://www.NuttyPuttyCave.com/links.html","");

subInfo[19][1] = new Array("Timpanogos Grotto","http://www.NuttyPuttyCave.com/join.html","");

subInfo[20][1] = new Array("Contact Us","http://www.NuttyPuttyCave.com/contact.html","");
subInfo[20][2] = new Array("Need a Guide","http://www.nuttyputtycave.com/matchup.html","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 135;
var ySubOffset = 0;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
		document.write('onMouseOver="overSub=true;');
		document.write('setOverImg(\'' + (x+1) + '\',\'\');"');
		document.write('onMouseOut="overSub=false;');
		document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);');
		document.write('setOutImg(\'' + (x+1) + '\',\'\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo[x+1][k+1][2] + '">');
			document.write( subInfo[x+1][k+1][0] + '</a>');
			document.write('</li>');
		}
		document.write('</ul>');
	}
	document.write('</div>');
}





//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft(id) { 
	var el = getElement(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = getElement(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus() {
	for ( x=0; x<totalButtons; x++) {
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
	}
}



//preload();

