/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "http://www.sdhsaa.com/includes/buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png","button8up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.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();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[1][1] = new Array("Fine Arts Handbook","http://www.sdhsaa.com/publications/handbook/finearts/Fine Arts Handbook.asp","");
subInfo[1][2] = new Array("Athletics Handbook","http://www.sdhsaa.com/publications/handbook/athletics/Athletic Handbook.asp","");
subInfo[1][3] = new Array("Constitution & By-Laws","http://www.sdhsaa.com/publications/handbook/athletics/3%20-%20Constitution%20&%20By-Laws.pdf","");
subInfo[1][4] = new Array("Newsletter","http://www.sdhsaa.com/publications/newsletter/newsletter.asp","");
subInfo[1][5] = new Array("Yearbook","http://www.sdhsaa.com/publications/yearbook/yearbook.asp","");
subInfo[1][6] = new Array("Annual Meeting Bulletin","https://www.sdhsaa.com/Publications/Annual Meeting Bulletin.pdf","");

subInfo[2][1] = new Array("General Fine Arts Info","http://www.sdhsaa.com/finearts/general/general info.asp","");
subInfo[2][2] = new Array("Journalism","http://www.sdhsaa.com/finearts/journalism/journalismmain.asp","");
subInfo[2][3] = new Array("Music","http://www.sdhsaa.com/finearts/music/musicmain.asp","");
subInfo[2][4] = new Array("Speech","http://www.sdhsaa.com/finearts/speech/speechmain.asp","");
subInfo[2][5] = new Array("Student Council","http://www.sdhsaa.com/finearts/student council/studentcouncilmain.asp","");

subInfo[3][1] = new Array("General Athletics Info","http://www.sdhsaa.com/athletics/general athletics info/general.asp","");
subInfo[3][2] = new Array("Coaches Education","http://www.sdhsaa.com/athletics/coaches education/Coaching%20Education.asp","");
subInfo[3][3] = new Array("Basketball","http://www.sdhsaa.com/athletics/basketball/basketballmain.asp","");
subInfo[3][4] = new Array("Sideline Cheer","http://www.sdhsaa.com/athletics/sideline cheer/cheermain.asp","");
subInfo[3][5] = new Array("Competitive Cheer","http://www.sdhsaa.com/athletics/cheer & dance/competitive cheer/compcheermain.asp","");
subInfo[3][6] = new Array("Competitive Dance","http://www.sdhsaa.com/athletics/cheer & dance/competitive dance/compdancemain.asp","");
subInfo[3][7] = new Array("Cross Country","http://www.sdhsaa.com/athletics/cross country/xcmain.asp","");
subInfo[3][8] = new Array("Football","http://www.sdhsaa.com/athletics/football/footballmain.asp","");
subInfo[3][9] = new Array("Golf","http://www.sdhsaa.com/athletics/golf/golfmain.asp","");
subInfo[3][10] = new Array("Gymnastics","http://www.sdhsaa.com/athletics/gymnastics/gymmain.asp","");
subInfo[3][11] = new Array("Tennis","http://www.sdhsaa.com/athletics/tennis/tennismain.asp","");
subInfo[3][12] = new Array("Track & Field","http://www.sdhsaa.com/athletics/track/trackmain.asp","");
subInfo[3][13] = new Array("Volleyball","http://www.sdhsaa.com/athletics/volleyball/volleyballmain.asp","");
subInfo[3][14] = new Array("Wrestling","http://www.sdhsaa.com/athletics/wrestling/wrestlingmain.asp","");
subInfo[3][15] = new Array("Orthopedics & Sports Medicine Articles","http://www.sanfordorthosports.org/info/index.php?id=49","");
subInfo[3][16] = new Array("Sanford POWER Athletic Enhancement","http://www.sanfordpowercenter.com","");
subInfo[3][17] = new Array("National Institute for Athletic Health & Performance","http://www.sanfordhealth.org/CentersofExcellence/Orthopedics/AthleticHealthPerformance/","");

subInfo[5][1] = new Array("General Info","http://www.sdhsaa.com/general/general.asp","");
subInfo[5][2] = new Array("Board Meetings","http://www.sdhsaa.com/calendar/board of directors/board main.asp","");
subInfo[5][3] = new Array("Games Wanted","http://www.sdhsaa.com/webforms/gameswanted/wanted.aspx?WA=GW","");
subInfo[5][4] = new Array("Officials Wanted","http://www.sdhsaa.com/webforms/gameswanted/wanted.aspx?WA=OW","");
subInfo[5][5] = new Array("Want to Buy/Sell","http://www.sdhsaa.com/webforms/gameswanted/wanted.aspx?WA=BS","");
subInfo[5][6] = new Array("National High School Activities Week","http://www.sdhsaa.com/publications/handbook/finearts/5-National%20Activities%20Week.pdf","");
subInfo[5][7] = new Array("Staff & Board","http://www.sdhsaa.com/general/staff.asp","");
subInfo[5][8] = new Array("Academic Achievement","http://www.sdhsaa.com/general/general.asp","");

subInfo[6][1] = new Array("Information","http://www.sdhsaa.com/officials/officials main.asp","");
subInfo[6][2] = new Array("Directory By Zip Code","http://www.sdhsaa.com/webforms/officials/officiallistByZip.aspx","");
subInfo[6][3] = new Array("Directory By Name","http://www.sdhsaa.com/webforms/officials/officialslists.aspx","");
subInfo[6][4] = new Array("Basketball", "http://www.sdhsaa.com/officials/Basketball/Basketball.asp","");
subInfo[6][5] = new Array("Competitive Cheer", "http://www.sdhsaa.com/officials/Cheerleading/Cheer.asp","");
subInfo[6][6] = new Array("Competitive Dance", "http://www.sdhsaa.com/officials/Dance/Dance.asp","");
subInfo[6][7] = new Array("Football", "http://www.sdhsaa.com/officials/Football/Football.asp","");
subInfo[6][8] = new Array("Gymnastics", "http://www.sdhsaa.com/officials/Gymnastics/Gymnastics.asp","");
subInfo[6][9] = new Array("Track & Field", "http://www.sdhsaa.com/officials/Track/Track.asp","");
subInfo[6][10] = new Array("Wrestling", "http://www.sdhsaa.com/officials/Wrestling/Wrestling.asp","");
subInfo[6][11] = new Array("Volleyball", "http://www.sdhsaa.com/officials/Volleyball/Volleyball.asp","");





//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 120;
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();

