/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.gif","button2up.gif","button3up.gif","button4up.gif","button5up.gif","button6up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif");

// 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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[2][1] = new Array("about us homepage","http://www.vincent-house.org/philosophy.html","");
subInfo[2][2] = new Array("business unit","http://www.vincent-house.org/business.html","");
subInfo[2][3] = new Array("food services unit","http://www.vincent-house.org/food.html","");
subInfo[2][4] = new Array("member services unit","http://www.vincent-house.org/memberservices.html","");
subInfo[2][5] = new Array("van gogh's unit","http://www.vincent-house.org/vgpunit.html","");
subInfo[2][6] = new Array("ICCD Certification","http://www.vincent-house.org/iccdcert.html","");
subInfo[2][7] = new Array("rehabilitation staff","http://www.vincent-house.org/contacts.html","");
subInfo[2][8] = new Array("Careers at Vincent House","http://www.vincent-house.org/careers.html","");
subInfo[2][9] = new Array("discovery tours","http://www.vincent-house.org/showcase.html","");

subInfo[3][1] = new Array("membership homepage","http://www.vincent-house.org/meetus.html","");
subInfo[3][2] = new Array("on becoming a member","http://www.vincent-house.org/membership.html","");
subInfo[3][3] = new Array("rights of membership","http://www.vincent-house.org/rights.html","");
subInfo[3][4] = new Array("member employment","http://www.vincent-house.org/employment.html","");
subInfo[3][5] = new Array("photographs","http://www.vincent-house.org/photos.html","");
subInfo[3][6] = new Array("video","http://www.vincent-house.org/video.html","");
subInfo[3][7] = new Array("testimonials","http://www.vincent-house.org/testimonials.html","");
subInfo[3][8] = new Array("young adults","http://www.vincent-house.org/youngadults.html","");

subInfo[4][1] = new Array("news homepage","http://www.vincent-house.org/news.html","");
subInfo[4][2] = new Array("special events","http://www.vincent-house.org/specialevents.html","");
subInfo[4][3] = new Array("recent events","http://www.vincent-house.org/recentevents.html","");
subInfo[4][4] = new Array("calendar","http://www.vincent-house.org/calendar.html","");
subInfo[4][5] = new Array("member events","http://www.vincent-house.org/events.html","");
subInfo[4][6] = new Array("our monthly newsletter","http://www.vincent-house.org/gazette.html","");

subInfo[5][1] = new Array("links homepage","http://www.vincent-house.org/links.html","");
subInfo[5][2] = new Array("clubhouse community","http://www.vincent-house.org/chlinks.html","");
subInfo[5][3] = new Array("our business partners","http://www.vincent-house.org/employers.html","");
subInfo[5][4] = new Array("hurricane preparedness","http://www.vincent-house.org/hurricaneprep.html","");
subInfo[5][5] = new Array("mental health resources","http://www.vincent-house.org/mhresources.html","");

subInfo[6][1] = new Array("donate homepage","http://www.vincent-house.org/donations.html","");
subInfo[6][2] = new Array("gifting options","http://www.vincent-house.org/gifts.html","");
subInfo[6][3] = new Array("wish list","http://www.vincent-house.org/wish.html","");
subInfo[6][4] = new Array("volunteer opportunities","http://www.vincent-house.org/volunteer.html","");
subInfo[6][5] = new Array("how can I help?","http://www.vincent-house.org/help.html","");
subInfo[6][6] = new Array("how can I contribute?","http://www.vincent-house.org/contribute.html","");
subInfo[6][7] = new Array("special thank you's","http://www.vincent-house.org/specialthanks.html","");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 0;
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;
	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();

