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

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png","button9over.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();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[2][1] = new Array("About Us","about_us.htm","");
subInfo[2][2] = new Array("Who we help","who_we_help.htm","");
subInfo[2][3] = new Array("Our Founder","Annie_Mawson.htm","");
subInfo[2][4] = new Array("Contact Us","contact_us.htm","");
subInfo[2][5] = new Array("Music for Life","music_for_life.htm","");
subInfo[2][6] = new Array("Patrons","patrons.htm","");
subInfo[2][7] = new Array("Trustees","trustees.htm","");
subInfo[2][8] = new Array("Funders","funders.htm","");
subInfo[2][9] = new Array("Quotes about Sunbeams","quotes_1.htm","");
subInfo[2][10] = new Array("Sunbeams Photos","photos_1.htm","");
subInfo[2][11] = new Array("The Philip Glass Story","philip_glass.htm","");
subInfo[2][12] = new Array("Rory Stewart MP","rory_stewart.htm","");
subInfo[2][13] = new Array("Focus on Alison Horn","Sunbeams_Musician.htm","");
subInfo[2][14] = new Array("Focus on Sally Wilson","sally-wilson.htm","");
subInfo[2][15] = new Array("American Friends","american_friends.htm","");
subInfo[2][16] = new Array("Recruitment","recruitment.htm","");

subInfo[3][1] = new Array("Best Boss 2006","best_boss_2006.htm","");
subInfo[3][2] = new Array("Volunteer of the Year","volunteer_of_year.htm","");
subInfo[3][3] = new Array("BT Awards","bt_award.htm","");
subInfo[3][4] = new Array("Bravo! Awards","bravo_award.htm","");
subInfo[3][5] = new Array("Annie Mawson","annie_award.htm","");
subInfo[3][6] = new Array("Young Volunteer of the Year","young_volunteers.htm","");
subInfo[3][7] = new Array("National Lottery Awards 2006","lottery_awards.htm","");
subInfo[3][8] = new Array("Music For Life Awards Ceremony","music_for_life_awards.htm","");
subInfo[3][9] = new Array("Annie Receiving the Paul Harris Fellowship Award","annie_paul_harris_fellowship.htm","");

subInfo[4][1] = new Array("What's On","whats_on.htm","");
subInfo[4][2] = new Array("News Articles","news_articles.htm","");
subInfo[4][3] = new Array("Big Lottery Fund Grant","big_lottery_grant.htm","");
subInfo[4][4] = new Array("Big Lottery Fund Update","lottery-fund-update.htm","");
subInfo[4][5] = new Array("Sunbeams Music For Life Projects","music_for_life_projects.htm","");
subInfo[4][6] = new Array("Sunbeams Family Learning Music Project","family_learning_music.htm","");
subInfo[4][7] = new Array("Sunbeams Music For Health Projects","music_for_health_projects.htm","");
subInfo[4][8] = new Array("Sunbeams Charity Shop Opens","charity_shop.htm","");
subInfo[4][9] = new Array("Sunbeams Charity Shop Update","charity-shop-update.htm","");
subInfo[4][10] = new Array("Locrians at High Head Castle","locrian_high_head.htm","");
subInfo[4][11] = new Array("Annie Receiving the Paul Harris Fellowship Award","annie_paul_harris_fellowship.htm","");
subInfo[4][12] = new Array("Concert Troupe at St Martin-in-the-Fields","st_martin_in_the_field.htm","");
subInfo[4][13] = new Array("JT Atkinson Support Sunbeams","jtatkinson.htm","");
subInfo[4][14] = new Array("Fundraising Events","fundraising_events.htm","");
subInfo[4][15] = new Array("Children in Need 2011","cin-bbc-westgazette.htm","");
subInfo[4][16] = new Array("Music Festival 2011","music_festival_feb_2011.htm","");
subInfo[4][17] = new Array("Bag Packing at Sainsburys","sainsburys-bagpack.htm","");
subInfo[4][18] = new Array("Keswick to Barrow Walk","keswick-barrow-walk.htm","");
subInfo[4][19] = new Array("QEGS Sponsored Walk","qegs-sponsored-walk.htm","");

subInfo[5][1] = new Array("Sunbeams Centre","sunbeams_centre.htm","");
subInfo[5][2] = new Array("Sunbeams Centre UPDATE","centre_fund_update.htm","");
subInfo[5][3] = new Array("Sunbeams Centre Plans","sunbeams_centre_plans.htm","");
subInfo[5][4] = new Array("Who has helped so far","whos_helped_so_far.htm","");
subInfo[5][5] = new Array("Donate A Brick","donate_a_brick.htm","");

subInfo[6][1] = new Array("Make a donation","make_donation.htm","");
subInfo[6][2] = new Array("Fundraise for us","make_donation.htm#raise_funds","");
subInfo[6][3] = new Array("Make a will/Leave a legacy","make_donation.htm#make_will","");

subInfo[7][1] = new Array("Sunbeams Appears on BBC TV!!!","children_in_need.htm","");
subInfo[7][2] = new Array("Sunbeams Interview on Radio Cumbria","sunbeams-radio-cumbria.htm","");
subInfo[7][3] = new Array("Cumbrian Newspapers","cumbrian_newspapers.htm","");
subInfo[7][4] = new Array("Annie at Yanwath Care Home's 20th Anniversary","annie_yanwath_20th.htm","");
subInfo[7][5] = new Array("Carlisle Golf Club Fundraiser","carlisle_golf_club.htm","");
subInfo[7][6] = new Array("MP's Charity of the Month","charity_of_month_april_2011.htm","");
subInfo[7][7] = new Array("Blues Lotto Supports Sunbeams","blues-lotto-support.htm","");
subInfo[7][8] = new Array("Picasso Sale Press Release","picasso-sale-press.htm","");

subInfo[8][1] = new Array("Three Men in a Boat","Three_Men_in_a_Boat.htm","");
subInfo[8][2] = new Array("Making Music","making_music.htm","");
subInfo[8][3] = new Array("Cumberland News Charitable Trust donation","cumberland_news.htm","");
subInfo[8][4] = new Array("Concerts - Locrian","Concerts_Locrian.htm","");
subInfo[8][5] = new Array("Concerts - O Duo","Concerts_ODuo.htm","");
subInfo[8][6] = new Array("Gerald's Song","oduo_and_gerald.htm","");
subInfo[8][7] = new Array("Jamie Reed's sponsored run","jamie_reed_sponsorship.htm","");
subInfo[8][8] = new Array("Linda Treks Inca Trail","Linda_Treks_Inca_For_Sunbeams.htm","");
subInfo[8][9] = new Array("Freda","freda.htm","")
subInfo[8][10] = new Array("The Eleanor Rigby document","eleanor_rigby.htm","")
subInfo[8][11] = new Array("Sunbeams Dinner and Auction","sunbeams_auction.htm","");
subInfo[8][12] = new Array("Locrians 'Classics by Candlelight'","locrian_leeming_house.htm","");
subInfo[8][13] = new Array("Concert Troupe at St Martin-in-the-Fields","st_martin_in_the_field.htm","");
subInfo[8][14] = new Array("Sunbeams Music Festival 2010","music_festival_2010.htm","");
subInfo[8][15] = new Array("Guy Johnston - Musical Feast","sept_music_feast.htm","");
subInfo[8][16] = new Array("World Book Night","world_book_night.htm","");
subInfo[8][17] = new Array("Rob Heron and the Tea Pad Orchestra","rob-heron-tea-pad.htm","");
subInfo[8][18] = new Array("Singers Patrick Relph & Jessica Hurst","fundraising_events.htm","");


subInfo[10][1] = new Array("Concert Troupe","concert_troupe.htm","")

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



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 100;
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();


