/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "Web Graphics/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("btnKFXMapsup.gif","btnKFXPhotoGalleryup.gif","btnKFXRegsup.gif" /*,"button2up.png"*/);

overSources = new Array("btnKFXMapsdn.gif","btnKFXPhotoGallerydn.gif","btnKFXRegsdn.gif" /*,"button2over.png"*/);



// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array();
subInfo[2] = new Array();
subInfo[3] = new Array();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
//subInfo[1][1] = new Array("Google Map","/maps/googlemap/googlemap.php","");
//subInfo[1][2] = new Array("Google Map Closed Route","/maps/googlemap/googlemap_routes.php","");
subInfo[1][1] = new Array("Dunes Map","DuneMap.php","");
subInfo[1][2] = new Array("Local Area Map","Maps/RexStAnth.htm","");
subInfo[1][3] = new Array("Egin Lakes Campsites","Egin Lakes/EginLakeCampground.pdf","");
subInfo[1][4] = new Array("The Cedars","/Cedars/Cedars_Closeup.htm","");
subInfo[1][5] = new Array("Chokecherry","/Chokecherry/Choke_Closeup.htm","");
subInfo[1][6] = new Array("Crapos","/Crapos/Crapos_Closeup.htm","");
subInfo[1][7] = new Array("Dead Horse Bowl","/Dead_Horse_Bowl/DeadHorse_Closeup.htm","");
subInfo[1][8] = new Array("East/West Stairways","/East Stairway/Stairway_Closeup.htm","");
subInfo[1][9] = new Array("Egin Lakes","/Egin Lakes/EginLakes_Closeup.htm","");
subInfo[1][10] = new Array("Middle Bowl","/Middle Bowl/Middle_Bowl_Closeup.htm","");
subInfo[1][11] = new Array("Millers Ponds/Trees","/Millers Ponds/Millers_Closeup.htm","");
subInfo[1][12] = new Array("Red Road","/Red Road Parking/RedRoad_Closeup.htm","");
subInfo[1][13] = new Array("West End","/West End Parking/WestEnd_Closeup.htm","");

subInfo[2][1] = new Array("Photo Gallery 09","Gallery09/Gallery09.php","");
subInfo[2][2] = new Array("Photo Gallery 08","Gallery08/Gallery08.php","");
subInfo[2][3] = new Array("Photo Gallery 07","Gallery07/Gallery07.php","");
subInfo[2][4] = new Array("Photo Gallery 06","Gallery06/Gallery06.php","");
subInfo[2][5] = new Array("Photo Gallery 05","Gallery/Gallery.php","");
subInfo[2][6] = new Array("Duner's Albums","coppermine/","_blank");

subInfo[3][1] = new Array("BLM Regulations","BLM Regs/BLM_Regs.php","_blank");
subInfo[3][2] = new Array("Winter Closure Map","BLM Regs/ClosureMap.pdf","_blank");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 5;
var ySubOffset = 70;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 300;
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('target="_blank">');
			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();

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}