/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[1][1] = new Array("Franklin's History","schoolhistory.html","");
subInfo[1][2] = new Array("Online Forms and Links","information.html","");
subInfo[1][3] = new Array("9th Grade Center","fhs9thctr.html","");

subInfo[2][1] = new Array("Business","businessdepartment.html","");
subInfo[2][2] = new Array("Career and Technology","careerandtechnologydepartment.html","");
subInfo[2][3] = new Array("English","englishdepartment.html","");
subInfo[2][4] = new Array("Fine Arts","fineartsdepartment.html","");
subInfo[2][5] = new Array("Foreign Language","foreignlanguagedepartment.html","");
subInfo[2][6] = new Array("Mathematics","mathdepartment.html","");
subInfo[2][7] = new Array("Physical Education & Health","pedepartment.html","");
subInfo[2][8] = new Array("Science","sciencedepartment.html","");
subInfo[2][9] = new Array("Social Studies","socialstudiesdepartment.html","");
subInfo[2][10] = new Array("Special Programs","working.html","");

subInfo[3][1] = new Array("Athletic Schedules","http://www.episd.org/_departments/athletics/schedule.php","");
subInfo[3][2] = new Array("Athletic Trainers","athletics/trainers/AT Web Page.htm","");
subInfo[3][3] = new Array("Baseball","http://www.leaguelineup.com/welcome.asp?url=franklincougars","");
subInfo[3][4] = new Array("Basketball - Men","http://www.leaguelineup.com/welcome.asp?url=franklincougarbasketball","");
subInfo[3][5] = new Array("Basketball - Women","athletics/girlsbasketball/index.html","");
subInfo[3][6] = new Array("Cheerleading","athletics/cheerleading/cheerleading.html","");
subInfo[3][7] = new Array("Cross Country","athletics/crosscountry/index.html","");
subInfo[3][8] = new Array("Football","athletics/football/football.html","");
subInfo[3][9] = new Array("Golf","http://www.leaguelineup.com/miscinfo.asp?menuid=39&cmenuid=39&url=franklingolf&sid=327826647","");
subInfo[3][10] = new Array("Soccer - Men","athletics/boyssoccer/boyssoccerhome.htm","");
subInfo[3][11] = new Array("Soccer - Women","athletics/girlssoccer/index.html","");
subInfo[3][12] = new Array("Softball","athletics/softball/softball_home.htm","");
subInfo[3][13] = new Array("Swimming","athletics/Swimming/index.htm","");
subInfo[3][14] = new Array("Tennis - Men","athletics/tennis_boys/index.html","");
subInfo[3][15] = new Array("Tennis - Women","athletics/tennis_girls/index.html","");
subInfo[3][16] = new Array("Track & Field - Men","http://www.leaguelineup.com/welcome.asp?url=fhstrackandfield","");
subInfo[3][17] = new Array("Volleyball","athletics/Volleyball/FHSVolleyballHome.htm","");
subInfo[3][18] = new Array("Wrestling","http://www.franklinwrestling.net","");

subInfo[4][1] = new Array("Academic Decathalon","working.html","");
subInfo[4][2] = new Array("Air Force ROTC","afjrotchistory.html","");
subInfo[4][3] = new Array("Ars Poetica","clubs/arspoetica/index.html","");
subInfo[4][4] = new Array("Band","http://www.fhsstarband.com","");
subInfo[4][5] = new Array("BPA","clubs/bpa/index.html","");
subInfo[4][6] = new Array("The Chronicle","http://www.fhschronicle.com","");
subInfo[4][7] = new Array("CDL - Franklin","clubs/CDL/CDL-HOME.htm","");
subInfo[4][8] = new Array("Dance-Fusion","clubs/dancefusion/index.html","");
subInfo[4][9] = new Array("Environmental Issues Club","clubs/environmenta_issues/index.html","");
subInfo[4][10] = new Array("FBLA","clubs/FBLA/fblaintro.html","");
subInfo[4][11] = new Array("Fish the Planet","clubs/fishtheplanet/fishtheplanet_home.htm","");
subInfo[4][12] = new Array("French Honor Society","clubs/frenchhs/index.html","");
subInfo[4][13] = new Array("German Club","clubs/germanclub/index.html","");
subInfo[4][14] = new Array("Key Club","clubs/keyclub/index.htm","");
subInfo[4][15] = new Array("Franklin Guitar","http://franklinguitar.com/index.php?option=com_frontpage&Itemid=1","");
subInfo[4][16] = new Array("Movie Club","clubs/movieclub/index.html","");
subInfo[4][17] = new Array("National Honor Society","clubs/national_honor_society/index.html","");
subInfo[4][18] = new Array("Science Club","clubs/scienceclub/scienceclub.htm","");
subInfo[4][19] = new Array("Spanish Honor Society","clubs/spanishhs/spanishhonorsociety.htm","");
subInfo[4][20] = new Array("Speech and Debate","clubs/speech_and_debate/index.htm","");
subInfo[4][21] = new Array("Student Council","clubs/stuco/home.html","");
subInfo[4][22] = new Array("Web Design Club","clubs/webclub/index.html","");

subInfo[5][1] = new Array("Franklin PTSA / Texas PTA","http://www.franklinptsa.txpta.org","");
subInfo[5][2] = new Array("Current PTSA Newsletter","documents/2009.04_Franklin_Newsletter.pdf","");
subInfo[5][3] = new Array("Be Parents - Not Friends","documents/PTSA Be Parents Not Friends.pdf","");
subInfo[5][4] = new Array("Breaking News","fhsptsanews.html","");
subInfo[5][5] = new Array("Contact Us","working.html","");
subInfo[5][6] = new Array("Cougar Closet","working.html","");
subInfo[5][7] = new Array("Cougar Newsletters Archive","working.html","");
subInfo[5][8] = new Array("Important Dates","documents/PTSA 2008-2009 Important Dates.pdf","");
subInfo[5][9] = new Array("2008-2009 Membership Application","documents/PTSA 2008-2009 Membership Application.pdf","");
subInfo[5][10] = new Array("2008-2009 Pansey Order Form","documents/PTSA 2008-2009 Pansy Flier.pdf","");
subInfo[5][11] = new Array("2008-2009 Reflections Contest","documents/PTSA 2008-2009 Reflections Application and Rules.pdf","");
subInfo[5][12] = new Array("2008-2009 Yard Sign Order Form","documents/PTSA Yard Sale Flier.pdf","");

subInfo[6][1] = new Array("Administrators","administrators.html","");
subInfo[6][2] = new Array("At-Risk Counseling Services","atriskcenter.html","");
subInfo[6][3] = new Array("Attendance Office","attendance.html","");
subInfo[6][4] = new Array("Book Room","bookroom.html","");
subInfo[6][5] = new Array("Business Office","businessagent.html","");
subInfo[6][6] = new Array("Cafteria Menu","http://www.episd.org/_departments/food_services/","");
subInfo[6][7] = new Array("Counselors","counselors.html","");
subInfo[6][8] = new Array("Instructional Support","working.html","");
subInfo[6][9] = new Array("Library-Franklin","http://webclass.org/library/","");
subInfo[6][10] = new Array("Library-9th Grade CTR","library9.html","");
subInfo[6][11] = new Array("Nurse","nurse.html","");
subInfo[6][12] = new Array("Police Services","working.html","");
subInfo[6][13] = new Array("Registrar","registrar.html","");
subInfo[6][14] = new Array("Special Education Services","working.html","");
subInfo[6][15] = new Array("Student Activities Office","studentactivities.html","");
subInfo[6][16] = new Array("Technology [Cougarnet]","working.html","");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 4;
var ySubOffset = 22;



//*** 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 + 'px';
	el.style.top = y + 'px';
}

// 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();

