/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_MainMenu = "images/buttons/main_page/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_MainMenu = new Array("button1up_MainMenu.png","button2up_MainMenu.png","button3up_MainMenu.png","button4up_MainMenu.png","button5up_MainMenu.png","button6up_MainMenu.png","button7up_MainMenu.png","button8up_MainMenu.png","button9up_MainMenu.png","button10up_MainMenu.png","button11up_MainMenu.png");

overSources_MainMenu = new Array("button1over_MainMenu.png","button2over_MainMenu.png","button3over_MainMenu.png","button4over_MainMenu.png","button5over_MainMenu.png","button6over_MainMenu.png","button7over_MainMenu.png","button8over_MainMenu.png","button9over_MainMenu.png","button10over_MainMenu.png","button11over_MainMenu.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_MainMenu = new Array();
subInfo_MainMenu[1] = new Array();
subInfo_MainMenu[2] = new Array();
subInfo_MainMenu[3] = new Array();
subInfo_MainMenu[4] = new Array();
subInfo_MainMenu[5] = new Array();
subInfo_MainMenu[6] = new Array();
subInfo_MainMenu[7] = new Array();
subInfo_MainMenu[8] = new Array();
subInfo_MainMenu[9] = new Array();
subInfo_MainMenu[10] = new Array();
subInfo_MainMenu[11] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo_MainMenu[1][1] = new Array("Main Family Page","http://www.familia-sanchez.net","");
subInfo_MainMenu[1][2] = new Array("My Brother Manny","http://www.familia-sanchez.net/Emmanuel","");
subInfo_MainMenu[1][3] = new Array("My Brother Dr. Sanchez","http://www.dr-sanchez.net","");




subInfo_MainMenu[5][1] = new Array(" Picture of the Day","http://antwrp.gsfc.nasa.gov/apod/astropix.html","");
subInfo_MainMenu[5][2] = new Array("JPL","http://www.jpl.nasa.gov/","");
subInfo_MainMenu[5][3] = new Array("NASA","http://www.nasa.gov/","");
subInfo_MainMenu[5][4] = new Array("Mars Exploration","http://marsrovers.nasa.gov/home/index.html","");








//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_MainMenu = 129;
var ySubOffset_MainMenu = 0;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_MainMenu = false;
var delay_MainMenu = 1000;
totalButtons_MainMenu = upSources_MainMenu.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons_MainMenu; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_MainMenu[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_MainMenu">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_MainMenu" class="dropmenu_MainMenu" ');
		document.write('onMouseOver="overSub_MainMenu=true;');
		document.write('setOverImg_MainMenu(\'' + (x+1) + '\',\'_MainMenu\');"');
		document.write('onMouseOut="overSub_MainMenu=false;');
		document.write('setTimeout(\'hideSubMenu_MainMenu(\\\'submenu' + (x+1) + '_MainMenu\\\')\',delay_MainMenu);');
		document.write('setOutImg_MainMenu(\'' + (x+1) + '\',\'_MainMenu\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_MainMenu[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_MainMenu[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_MainMenu[x+1][k+1][2] + '">');
			document.write( subInfo_MainMenu[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_MainMenu() {
	for ( x=0; x<totalButtons_MainMenu; x++ ) {
		buttonUp_MainMenu = new Image();
		buttonUp_MainMenu.src = buttonFolder_MainMenu + upSources_MainMenu[x];
		buttonOver_MainMenu = new Image();
		buttonOver_MainMenu.src = buttonFolder_MainMenu + overSources_MainMenu[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg_MainMenu(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_MainMenu + overSources_MainMenu[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg_MainMenu(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_MainMenu + upSources_MainMenu[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement_MainMenu(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft_MainMenu(id) { 
	var el = getElement_MainMenu(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_MainMenu(id) {
	var el = getElement_MainMenu(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_MainMenu(objectID,x,y) {
	var el = getElement_MainMenu(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_MainMenu(subID, buttonID) {
	hideAllSubMenus_MainMenu();
	butX = getRealLeft_MainMenu(buttonID);
	butY = getRealTop_MainMenu(buttonID);
	moveObjectTo_MainMenu(subID,butX+xSubOffset_MainMenu, butY+ySubOffset_MainMenu);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_MainMenu() {
	for ( x=0; x<totalButtons_MainMenu; x++) {
		moveObjectTo_MainMenu("submenu" + (x+1) + "_MainMenu",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_MainMenu(subID) {
	if ( overSub_MainMenu == false ) {
		moveObjectTo_MainMenu(subID,-500, -500);
	}
}



//preload_MainMenu();

