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

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("about_0.gif","quote_0.gif","music_0.gif","plan_0.gif","timeline_0.gif","book_0.gif","links_0.gif","contact_0.gif","button9up.png","button10up.png","button11up.png","button12up.png","button13up.png","button14up.png");

overSources = new Array("about_1.gif","quote_1.gif","music_1.gif","plan_1.gif","timeline_1.gif","book_1.gif","links_1.gif","contact_1.gif","button9over.png","button10over.png","button11over.png","button12over.png","button13over.png","button14over.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();
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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[1][1] = new Array("Welcome","http://www.djsamhouse.com","_self");
subInfo[1][2] = new Array("DJ Sam House","http://www.djsamhouse.com/djsam.html","_self");
subInfo[1][3] = new Array("References","http://www.djsamhouse.com/references.html","_self");
subInfo[1][4] = new Array("Performers","http://www.djsamhouse.com/performers.html","_self");
subInfo[1][5] = new Array("Equipment","http://www.djsamhouse.com/equip.html","_self");
subInfo[1][6] = new Array("Lighting","http://www.djsamhouse.com/lights.html","_self");
subInfo[1][7] = new Array("Rentals","http://www.djsamhouse.com/rental.html","_self");
subInfo[1][8] = new Array("Blog","http://los-angeles-dj.com","_blank");

subInfo[2][1] = new Array("Get Quote","http://www.djsamhouse.djintelligence.com/quote","_self");

subInfo[3][1] = new Array("Song Database","http://www.djsamhouse.djintelligence.com/music/","_self");
subInfo[3][2] = new Array("Top 200 songs","http://www.djsamhouse.djintelligence.com/music/requested.asp","_blank");
subInfo[3][3] = new Array("Wedding Songs","http://www.djsamhouse.com/wedding_songs.html","_blank");

subInfo[4][1] = new Array("Party","http://www.djsamhouse.djintelligence.com/planning/planning.asp?ID=Party","_self");
subInfo[4][2] = new Array("School","http://www.djsamhouse.djintelligence.com/planning/planning.asp?ID=School","_self");
subInfo[4][3] = new Array("Sweet 16","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=Quinces+%2F+Sweet+16s","_self");
subInfo[4][4] = new Array("Corporate","http://www.djsamhouse.djintelligence.com/planning/planning.asp?ID=Corporate","_self");
subInfo[4][5] = new Array("Bar Mitzvah","http://www.djsamhouse.com/mitzvahs.html","_self");
subInfo[4][6] = new Array("Wedding","http://www.djsamhouse.com/weddings.html","_self");

subInfo[5][1] = new Array("Party","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=Party","_self");
subInfo[5][2] = new Array("School","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=School","_self");
subInfo[5][3] = new Array("Sweet 16","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=Quinces+%2F+Sweet+16s","_self");
subInfo[5][4] = new Array("Corporate","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=Corporate","_self");
subInfo[5][5] = new Array("Bar Mitzvah","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=Bar%2FBat+Mitzvah","_self");
subInfo[5][6] = new Array("Wedding","http://www.djsamhouse.djintelligence.com/timeline/timeline.asp?ID=Wedding","_self");

subInfo[6][1] = new Array("Make Payment","http://www.djsamhouse.djintelligence.com/payment","_self");

subInfo[7][1] = new Array("Party Supplies","http://djsamhouse.makesparties.com/Home.aspx","_blank");
subInfo[7][2] = new Array("DJ Sam Mixes","http://www.mixcrate.com/djsamhouse#uploads","_blank");
subInfo[7][3] = new Array("Bridal Makeup","http://www.laweddingmakeup.com","_blank");
subInfo[7][4] = new Array("Gear Shop","http://www.djsamhouse.com/gear","_blank");
subInfo[7][5] = new Array("Survey","http://www.djsamhouse.com/survey.html","_blank");
subInfo[7][6] = new Array("Blog","http://los-angeles-dj.com","_blank");


subInfo[8][1] = new Array("Refer a Friend","http://www.djsamhouse.djintelligence.com/referral","_blank");
subInfo[8][2] = new Array("Contact Form","http://www.djsamhouse.djintelligence.com/contact","_blank");
subInfo[8][3] = new Array("Employment","http://www.djsamhouse.com/apply.html","_blank");
subInfo[8][4] = new Array("Email","mailto:sam@djsamhouse.com","");


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



//*** 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();


