/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "http://hms.sps.lane.edu/images/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.gif","button2up.gif","button3up.gif","button4up.gif","button5up.gif","button6up.gif","button7up.gif","button8up.gif","button9up.gif","button10up.gif","button11up.gif","button12up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif","button8over.gif","button9over.gif","button10over.gif","button11over.gif","button12over.gif");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array(); // home
subInfo[2] = new Array(); // happenings
subInfo[3] = new Array(); // curric
subInfo[4] = new Array(); // gen info
subInfo[5] = new Array(); // grades / class info
subInfo[6] = new Array(); // honors
subInfo[7] = new Array(); // maps
subInfo[8] = new Array(); // sch supplies
subInfo[9] = new Array(); // staff
subInfo[10] = new Array(); // student work
subInfo[11] = new Array(); // what we teach
subInfo[12] = new Array(); // tea links

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//   
subInfo[2][1] = new Array("Calendar of Events","http://hms.sps.lane.edu/calendar/webcal.html","_blank");
subInfo[2][2] = new Array("Daily Announcements","http://hms.sps.lane.edu/happenings/Announcements.htm","");
subInfo[2][3] = new Array("Newsletter","http://hms.sps.lane.edu/happenings/Newsletter.pdf","");
subInfo[2][4] = new Array("Sports Schedule","http://hms.sps.lane.edu/happenings/SportsSchedule.htm","");
subInfo[2][5] = new Array("Yearly Calendar","http://springfieldsd19.schoolwires.com/157710330132620197/site/default.asp","");

subInfo[3][1] = new Array("Student Account Activation","https://secure.sps.lane.edu/ad/AccountActivator/default.aspx?Type=Student","_blank");
subInfo[3][2] = new Array("OAKS Testing","http://hms.sps.lane.edu/curric/testing.html","");
subInfo[3][3] = new Array("Easy CBM Testing","http://sps.or.easycbm.com/","_blank");
subInfo[3][4] = new Array("OSLIS","http://www.oslis.k12.or.us","_blank");
subInfo[3][5] = new Array("Hamlin Library Catalog","http://dest1/cataloging/servlet/presentadvancedsearchredirectorform.do?l2m=Library Search&tm=Catalog&l2m=Library+Search","_blank");
subInfo[3][6] = new Array("Reading Counts List","http://hms.sps.lane.edu/curric/ReadingCounts-by_lexile.htm","_blank");
subInfo[3][7] = new Array("Find a book's Lexile","http://src.scholastic.com/ecatalog/default.asp?UID=B116672F73BD4A0E09590597433C39F8&subt=0&Test=NA","_blank");
subInfo[3][8] = new Array("Multiple Subjects","http://hms.sps.lane.edu/curric/multisubj.html","");
subInfo[3][9] = new Array("Language Arts/ Reading","http://hms.sps.lane.edu/curric/langarts.html","");
subInfo[3][10] = new Array("Math","http://hms.sps.lane.edu/curric/math.html","");
subInfo[3][11] = new Array("Science","http://hms.sps.lane.edu/curric/science.html","");
subInfo[3][12] = new Array("Social Studies","http://hms.sps.lane.edu/curric/socstud.html","");
subInfo[3][13] = new Array("Keyboarding Games","http://hms.sps.lane.edu/curric/keyboardinggames.html","");
//subInfo[2][13] = new Array("Hamlin Student Survey","http://www.surveymonkey.com/s.aspx?sm=_2bD_2f7NZy4rpUJjrNRn3rekg_3d_3d","_blank");


subInfo[4][1] = new Array("Forms","http://hms.sps.lane.edu/forms.html","");
subInfo[4][2] = new Array("Policies","http://hms.sps.lane.edu/policies.html","");
subInfo[4][3] = new Array("Time Schedule","http://hms.sps.lane.edu/times.html","");

subInfo[7][1] = new Array("Boundries","javascript:openBoundryPictWindow();","");
subInfo[7][2] = new Array("Building Map","http://hms.sps.lane.edu/building.html","");
subInfo[7][3] = new Array("Bus Routes","http://www.sps.lane.edu/1577101212142847530/blank/browse.asp?a=383&BMDRN=2000&BCOB=0&c=54582&1577101212142847530Nav=|&NodeID=549&1577Nav=|&NodeID=82","_blank");
subInfo[7][4] = new Array("Directions","http://hms.sps.lane.edu/directions.html","");

subInfo[8][1] = new Array("6th Grade","http://hms.sps.lane.edu/supply6.html","");
subInfo[8][2] = new Array("7th Grade","http://hms.sps.lane.edu/supply7.html","");
subInfo[8][3] = new Array("8th Grade","http://hms.sps.lane.edu/supply8.html","");

subInfo[10][1] = new Array("Art Work","http://people.sps.lane.edu/lisa.fisher/site/Ms._Fishers_Art_Room.html","_blank");
subInfo[10][2] = new Array("Art Work on TV","http://kezi.com/page/146659","_blank");
subInfo[10][3] = new Array("Presentations","http://hms.sps.lane.edu/presentations.html","");
subInfo[10][4] = new Array("Videos & Animations","http://hms.sps.lane.edu/videos.html","");
subInfo[10][5] = new Array("Robotics Class","http://hms.sps.lane.edu/roboticsclass.html","");

subInfo[11][1] = new Array("6th Grade","http://hms.sps.lane.edu/whatweteach6.html","");
subInfo[11][2] = new Array("7th Grade","http://hms.sps.lane.edu/whatweteach7.html","");
subInfo[11][3] = new Array("8th Grade","http://hms.sps.lane.edu/whatweteach8.html","");

subInfo[12][1] = new Array("Collaboration Wiki","https://sites.google.com/a/sps.lane.edu/wiki/","_blank");
subInfo[12][2] = new Array("Computer Lab Schedule","http://intranet.sps.lane.edu/HMS/Lab%20Calendar.htm","_blank");
subInfo[12][3] = new Array("Forms for teachers","http://hms.sps.lane.edu/forms-teacher.html","");
subInfo[12][4] = new Array("Staff Calendar","http://hms.sps.lane.edu/happenings/Password.htm","_blank");
subInfo[12][5] = new Array("Help Desk","https://helpdesk.springfield.k12.or.us/helpdesk/WebObjects/Helpdesk","_blank");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 150;
var ySubOffset = 7;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 800;
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);
	}
}


function openBoundryPictWindow() {
popupWin1 = window.open('', 'open_window', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,dependent,width=670,height=480,left=35,top=20');
popupWin1.document.write("<TITLE>Hamlin Middle School Boundries</TITLE><CENTER><IMG SRC='http://hms.sps.lane.edu/images/boundry.jpg' BORDER=0><FORM><INPUT TYPE='BUTTON' VALUE='Close Window'"+ " onClick='self.close()'></FORM></CENTER>")
popupWin1.document.close()
}

function openArticle1Window() {
popupWin1 = window.open('', 'open_window', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,dependent,width=422,height=695,left=25,top=10');
popupWin1.document.write("<head><TITLE>Springfield News Article #1</TITLE></head><CENTER><IMG SRC='http://hms.sps.lane.edu/images/article1.gif' BORDER=0><FORM><INPUT TYPE='BUTTON' VALUE='Close Window'"+ " onClick='self.close()'></FORM></CENTER>")
popupWin1.document.close()
}

function openArticle2Window() {
popupWin1 = window.open('', 'open_window', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,dependent,width=355,height=625,left=35,top=20');
popupWin1.document.write("<head><TITLE>Springfield News Article #2</TITLE></head><CENTER><IMG SRC='http://hms.sps.lane.edu/images/article2.gif' BORDER=0><FORM><INPUT TYPE='BUTTON' VALUE='Close Window'"+ " onClick='self.close()'></FORM></CENTER>")
popupWin1.document.close()
}

function openDedicationWindow() {
popupWin1 = window.open('', 'open_window', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars,resizable,dependent,width=690,height=750,left=35,top=20');
popupWin1.document.write("<head><TITLE>Dedication Ceremony Program</TITLE></head><CENTER><IMG SRC='http://hms.sps.lane.edu/images/HMSDedication.jpg' BORDER=0><FORM><INPUT TYPE='BUTTON' VALUE='Close Window'"+ " onClick='self.close()'></FORM></CENTER>")
popupWin1.document.close()
}

//preload();

