/*** 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","button8up.png","button9up.png","button10up.png","button11up.png","button12up.png","button13up.png","button14up.png","button15up.png","button16up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png","button9over.png","button10over.png","button11over.png","button12over.png","button13over.png","button14over.png","button15over.png","button16over.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();
subInfo[15] = new Array();
subInfo[16] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//



subInfo[4][1] = new Array("The Bulletin/Steeple","http://www.firstlutheraneg.org/index_files/bulletin.htm  ","");
subInfo[4][2] = new Array("Lutheran Liturgy","http://www.firstlutheraneg.org/index_files/Liturgy.htm  ","");
subInfo[4][3] = new Array("Service Schedule","http://www.firstlutheraneg.org/index_files/Services.htm","");
subInfo[4][4] = new Array("Handicapped Accessible","http://www.firstlutheraneg.org/index_files/Handicap.htm","");
subInfo[4][5] = new Array("The Sacrament","http://www.firstlutheraneg.org/index_files/Sacrament.htm","");
subInfo[4][6] = new Array("Baptisms","http://www.firstlutheraneg.org/index_files/baptism.htm","");

subInfo[5][1] = new Array("Mens Bible Study","http://www.firstlutheraneg.org/index_files/MBS.htm","");
subInfo[5][2] = new Array("We Care","http://www.firstlutheraneg.org/index_files/wecare.htm","");
subInfo[5][3] = new Array("Lay Ministers","http://www.firstlutheraneg.org/index_files/layminister.htm  ","");
subInfo[5][4] = new Array("Sisters of the Spirit","http://www.firstlutheraneg.org/index_files/sos.htm","");
subInfo[5][5] = new Array("Life Support","http://www.firstlutheraneg.org/index_files/lifesupport.htm","");
subInfo[5][6] = new Array("Oceans of Grace","http://www.firstlutheraneg.org/index_files/oceansofgrace.htm","");
subInfo[5][7] = new Array("Alpha Program","http://www.firstlutheraneg.org/index_files/alphaprogram.htm","");
subInfo[5][8] = new Array("Faith in the Arts","http://www.firstlutheraneg.org/index_files/faithinthearts.htm","");

subInfo[6][1] = new Array("Confirmation Program","http://www.firstlutheraneg.org/index_files/confirmationprogram.htm  ","");
subInfo[6][2] = new Array("Youth Activities","http://www.firstlutheraneg.org/index_files/youthactivities.htm","");

subInfo[7][1] = new Array("Sunday School","http://www.firstlutheraneg.org/index_files/sundayschool.htm","");
subInfo[7][2] = new Array("Vacation Bible School","http://www.firstlutheraneg.org/index_files/vacationbibleschool.htm","");
subInfo[7][3] = new Array("First Confirmation Instruction","http://www.firstlutheraneg.org/index_files/firstconfirmation.htm   ","");
subInfo[7][4] = new Array("Childrens Sermon","http://www.firstlutheraneg.org/index_files/childrenssermon.htm","");
subInfo[7][5] = new Array("Just For Kids","http://www.firstlutheraneg.org/index_files/justforkids.htm","");

subInfo[8][1] = new Array("Music Ministries Main Page","http://www.firstlutheraneg.org/index_files/Music_Ministries.htm","");
subInfo[8][2] = new Array("Adult Choir","http://www.firstlutheraneg.org/index_files/adultchoir.htm","");
subInfo[8][3] = new Array("Youth Choir","http://www.firstlutheraneg.org/index_files/youthchoir.htm","");
subInfo[8][4] = new Array("Bell Choir","http://www.firstlutheraneg.org/index_files/bellchoir.htm","");
subInfo[8][5] = new Array("About Philip Martorella","http://www.firstlutheraneg.org/index_files/aboutphilipmartorella.htm","");
subInfo[8][6] = new Array("Concerts/Events","http://www.firstlutheraneg.org/index_files/Concerts.htm","");

subInfo[9][1] = new Array("Outreach Main Page","http://www.firstlutheraneg.org/index_files/Outreach.htm","");
subInfo[9][2] = new Array("Food Ministries/Food Bank","http://www.firstlutheraneg.org/index_files/foodbank.htm","");
subInfo[9][3] = new Array("Thrift Shop","http://www.firstlutheraneg.org/index_files/thriftshop.htm","");
subInfo[9][4] = new Array("Blankets & Tools program","http://www.firstlutheraneg.org/index_files/blankets.htm  ","");
subInfo[9][5] = new Array("Shawl Ministry","http://www.firstlutheraneg.org/index_files/shawlministry.htm","");
subInfo[9][6] = new Array("Calumet Camp","http://www.firstlutheraneg.org/index_files/calumet.htm  ","");
subInfo[9][7] = new Array("Lutheran World Relief","http://www.firstlutheraneg.org/index_files/lutheranworldrelief.htm","");
subInfo[9][8] = new Array("RI Family Shelter","http://www.firstlutheraneg.org/index_files/rifamilyshelter.htm  ","");
subInfo[9][9] = new Array("Healing Prayer services","http://www.firstlutheraneg.org/index_files/healingprayer.htm","");

subInfo[10][1] = new Array("Evangelical Lutheran Church in America","http://www.elca.org","");
subInfo[10][2] = new Array("Lutherans Online","http://www.lutheransonline.org","");
subInfo[10][3] = new Array("Lutheran Social Services of New England","http://www.lssne.org","");
subInfo[10][4] = new Array("NE SYNOD","http://www.nesynod.org","");
subInfo[10][5] = new Array("Lutheran Heritage","http://en.wikipedia.org/wiki/Lutheran_church","");
subInfo[10][6] = new Array("Thrivent Financial","http://www.thrivent.com","");


subInfo[12][1] = new Array("Good News","http://www.firstlutheraneg.org/index_files/Pastor_linda.htm","");
subInfo[12][2] = new Array("Sermons","http://www.firstlutheraneg.org/index_files/sermons.htm","");
subInfo[12][3] = new Array("About Pastor Linda","http://www.firstlutheraneg.org/index_files/aboutpastorlinda.htm","");

subInfo[13][1] = new Array("Our Church","http://www.firstlutheraneg.org/index_files/photogalleryourchurch.htm","");
subInfo[13][2] = new Array("Church Events","http://www.firstlutheraneg.org/index_files/photogallerychurchevents.htm","");
subInfo[13][3] = new Array("Youth Events","http://www.firstlutheraneg.org/index_files/photogalleryyouth.htm","");

subInfo[14][1] = new Array("Meet your Church Council","http://www.firstlutheraneg.org/index_files/Council.htm","");
subInfo[14][2] = new Array("Minutes and Meetings","http://www.firstlutheraneg.org/index_files/councilminutes.htm","");

subInfo[15][1] = new Array("Church Cookbook","http://www.firstlutheraneg.org/index_files/fundraisingcookbook.htm","");
subInfo[15][2] = new Array("Fund Raising Events","http://www.firstlutheraneg.org/index_files/fundraisingother.htm","");



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



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

