/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_menu1 = "buttons/";
var buttonFolder_menu2 = "buttons/";
var buttonFolder_menu3 = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_menu1 = new Array("button1up_menu1.png","button2up_menu1.png","button3up_menu1.png","button4up_menu1.png","button5up_menu1.png");

overSources_menu1 = new Array("button1over_menu1.png","button2over_menu1.png","button3over_menu1.png","button4over_menu1.png","button5over_menu1.png");

upSources_menu2 = new Array("button1up_menu2.png","button2up_menu2.png","button3up_menu2.png","button4up_menu2.png","button5up_menu2.png","button6up_menu2.png","button7up_menu2.png");

overSources_menu2 = new Array("button1over_menu2.png","button2over_menu2.png","button3over_menu2.png","button4over_menu2.png","button5over_menu2.png","button6over_menu2.png","button7over_menu2.png");

upSources_menu3 = new Array("button1up_menu3.png","button2up_menu3.png","button3up_menu3.png","button4up_menu3.png","button5up_menu3.png","button6up_menu3.png","button7up_menu3.png");

overSources_menu3 = new Array("button1over_menu3.png","button2over_menu3.png","button3over_menu3.png","button4over_menu3.png","button5over_menu3.png","button6over_menu3.png","button7over_menu3.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_menu1 = new Array();
subInfo_menu1[1] = new Array();
subInfo_menu1[2] = new Array();
subInfo_menu1[3] = new Array();
subInfo_menu1[4] = new Array();
subInfo_menu1[5] = new Array();

subInfo_menu2 = new Array();
subInfo_menu2[1] = new Array();
subInfo_menu2[2] = new Array();
subInfo_menu2[3] = new Array();
subInfo_menu2[4] = new Array();
subInfo_menu2[5] = new Array();
subInfo_menu2[6] = new Array();
subInfo_menu2[7] = new Array();

subInfo_menu3 = new Array();
subInfo_menu3[1] = new Array();
subInfo_menu3[2] = new Array();
subInfo_menu3[3] = new Array();
subInfo_menu3[4] = new Array();
subInfo_menu3[5] = new Array();
subInfo_menu3[6] = new Array();
subInfo_menu3[7] = new Array();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo_menu1[4][1] = new Array("How to Join a Club","joinclub.html","");
subInfo_menu1[4][2] = new Array("Rules of the Game","gamerules.html","");
subInfo_menu1[4][3] = new Array("Anti-Doping Policy","antidoping.html","");
subInfo_menu1[4][4] = new Array("Child Protection","childprotect.html","");
subInfo_menu1[4][5] = new Array("Club Tournaments","clubtournaments.html","");

subInfo_menu1[5][1] = new Array("Irish Sports Council","http://www.irishsportscouncil.ie","");
subInfo_menu1[5][2] = new Array("WADA Web Site ","http://www.wada-ama.org/en/prohibitedlist.ch2","");
subInfo_menu1[5][3] = new Array("IBA Web Site","http://www.irishbowlingassociation.com","");
subInfo_menu1[5][4] = new Array("Private Greens Web Site","http://www.bryansbowls.me.uk/pgl09.htm","");
subInfo_menu1[5][5] = new Array("NIBA Web Site","http://www.nibabowls.co.uk","");
subInfo_menu1[5][6] = new Array("NIPBA Web Site","http://provincialbowls.co.uk","");
subInfo_menu1[5][7] = new Array("BIBC Web Site","http://www.britishislesbowls.com","");
subInfo_menu1[5][8] = new Array("Winter League","http://www.awblire.utvinternet.com/","");
subInfo_menu1[5][9] = new Array("Hidden Hearing","http://www.hiddenhearing.ie","");
subInfo_menu1[5][10] = new Array("Aer Lingus B.C.","http://www.aerlingusbowlsclub.com/","");
subInfo_menu1[5][11] = new Array("Blackrock B.C.","http://www.blackrockbtc.ie/","");
subInfo_menu1[5][12] = new Array("Bray B.C.","http://www.braybowlingclub.com/","");
subInfo_menu1[5][13] = new Array("Crumlin B.C.","http://www.crumlinbowls.ie/","");
subInfo_menu1[5][14] = new Array("C.Y.M. B.C.","http://www.terenuresportsclub.ie/","");
subInfo_menu1[5][15] = new Array("Dun Laoghaire B.C.","http://www.dunlaoghairebowls.com/","");
subInfo_menu1[5][16] = new Array("Greystones B.C.","http://www.greystoneslawnbowling.org/","");
subInfo_menu1[5][17] = new Array("Kenilworth B.C.","http://www.kenilworthbc.ie/","");
subInfo_menu1[5][18] = new Array("Railway Union B.C.","http://www.railwayunionbc.com/","");
subInfo_menu1[5][19] = new Array("Rosslare B.C.","http://www.rosslarebowls.com","");
subInfo_menu1[5][20] = new Array("Westmanstown B.C.","http://www.westmanstownbowls.com","");
subInfo_menu1[5][21] = new Array("The Webmaster","http://www.outofafrica.ie","");

subInfo_menu2[2][1] = new Array("History","mhistory.html","");
subInfo_menu2[2][2] = new Array("Officers and Committees","mofficerscommittees.html","");
subInfo_menu2[2][3] = new Array("Clubs and Secretaries","mclubsecretaries.html","");
subInfo_menu2[2][4] = new Array("Special Events","mspecialevents.html","");
subInfo_menu2[2][5] = new Array("News","mnews.html","");

subInfo_menu2[3][1] = new Array("League Fixtures","mleaguefixtures.html","");
subInfo_menu2[3][2] = new Array("League Tables","mleaguetables.html","");
subInfo_menu2[3][3] = new Array("League Results","mleagueresults.html","");

subInfo_menu2[4][1] = new Array("Cup Fixtures","mcupfixtures.html","");
subInfo_menu2[4][2] = new Array("Cup Results","mcupresults.html","");

subInfo_menu2[5][1] = new Array("Closing Dates","mchampdates.html","");
subInfo_menu2[5][2] = new Array("Chamionship Draws","mchampdraws.html","");
subInfo_menu2[5][3] = new Array("Semi-Final Results","mchampsemifinalresults.html","");
subInfo_menu2[5][4] = new Array("Final Results","mchampfinalresults.html","");

subInfo_menu2[6][1] = new Array("Officers","mibaofficers.html","");
subInfo_menu2[6][2] = new Array("Association Secretaries","mibasecretaries.html","");
subInfo_menu2[6][3] = new Array("IBA Cup Draws","mibacupfixtures.html","");
subInfo_menu2[6][4] = new Array("IBA Cup Results","mibacupresults.html","");
subInfo_menu2[6][5] = new Array("Championship Draws","mibachampdraws.html","");
subInfo_menu2[6][6] = new Array("Championship Results","mibachampresults.html","");
subInfo_menu2[6][7] = new Array("Inter-Association Teams","mibainterteams.html","");
subInfo_menu2[6][8] = new Array("Inter-Association Results","mibainterresults.html","");
subInfo_menu2[6][9] = new Array("2010 International Team","mibainterplayers.html","");


subInfo_menu2[7][1] = new Array("Championship Draws","mbibcchampdraws.html","");
subInfo_menu2[7][2] = new Array("Championship Results","mbibcchampresults.html","");
subInfo_menu2[7][3] = new Array("International Results","mbibcinternationalresults.html","");

subInfo_menu3[2][1] = new Array("History","whistory.html","");
subInfo_menu3[2][2] = new Array("Officers and Committees","wofficerscommittees.html","");
subInfo_menu3[2][3] = new Array("Clubs and Secretaries","wclubsecretaries.html","");
subInfo_menu3[2][4] = new Array("Special Events","wspecialevents.html","");
subInfo_menu3[2][5] = new Array("News","wnews.html","");

subInfo_menu3[3][1] = new Array("League Fixtures","wleaguefixtures.html","");
subInfo_menu3[3][2] = new Array("League Tables","wleaguetables.html","");
subInfo_menu3[3][3] = new Array("League Results","wleagueresults.html","");

subInfo_menu3[4][1] = new Array("Cup Fixtures","wcupfixtures.html","");
subInfo_menu3[4][2] = new Array("Cup Results","wcupresults.html","");

subInfo_menu3[5][1] = new Array("Closing Dates","wchampdates.html","");
subInfo_menu3[5][2] = new Array("Chamionship Draws","wchampdraws.html","");
subInfo_menu3[5][3] = new Array("Semi-Final Results","wchampsemifinalresults.html","");
subInfo_menu3[5][4] = new Array("Final Results","wchampfinalresults.html","");

subInfo_menu3[6][1] = new Array("Officers","wiwbaofficers.html","");
subInfo_menu3[6][2] = new Array("Association Secretaries","wiwbasecretaries.html","");
subInfo_menu3[6][3] = new Array("Cup Fixtures","wiwbacupfixtures.html","");
subInfo_menu3[6][4] = new Array("Cup Results","wiwbacupresults.html","");
subInfo_menu3[6][5] = new Array("Championship Draws","wiwbachampdraws.html","");
subInfo_menu3[6][6] = new Array("Championship Results","wiwbachampresults.html","");
subInfo_menu3[6][7] = new Array("Inter-Association Teams","wiwbainterteams.html","");
subInfo_menu3[6][8] = new Array("Inter-Association Results","wiwbainterresults.html","");
subInfo_menu3[6][9] = new Array("International Players","wiwbainterplayers.html","");

subInfo_menu3[7][1] = new Array("Championship Draws","wbibcchampdraws.html","");
subInfo_menu3[7][2] = new Array("Championship Results","wbibcchampresults.html","");
subInfo_menu3[7][3] = new Array("International Results","wbibcinternationalresults.html","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_menu1 = 5;
var ySubOffset_menu1 = 22;

var xSubOffset_menu2 = 5;
var ySubOffset_menu2 = 22;

var xSubOffset_menu3 = 5;
var ySubOffset_menu3 = 22;

//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_menu1 = false;
var delay_menu1 = 1000;
totalButtons_menu1 = upSources_menu1.length;

var overSub_menu2 = false;
var delay_menu2 = 1000;
totalButtons_menu2 = upSources_menu2.length;

var overSub_menu3 = false;
var delay_menu3 = 1000;
totalButtons_menu3 = upSources_menu3.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons_menu1; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_menu1[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_menu1">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_menu1" class="dropmenu_menu1" ');
		document.write('onMouseOver="overSub_menu1=true;');
		document.write('setOverImg_menu1(\'' + (x+1) + '\',\'_menu1\');"');
		document.write('onMouseOut="overSub_menu1=false;');
		document.write('setTimeout(\'hideSubMenu_menu1(\\\'submenu' + (x+1) + '_menu1\\\')\',delay_menu1);');
		document.write('setOutImg_menu1(\'' + (x+1) + '\',\'_menu1\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_menu1[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_menu1[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_menu1[x+1][k+1][2] + '">');
			document.write( subInfo_menu1[x+1][k+1][0] + '</a>');
			document.write('</li>');
		}
		document.write('</ul>');
	}
	document.write('</div>');
}

for ( x=0; x<totalButtons_menu2; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_menu2[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_menu2">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_menu2" class="dropmenu_menu2" ');
		document.write('onMouseOver="overSub_menu2=true;');
		document.write('setOverImg_menu2(\'' + (x+1) + '\',\'_menu2\');"');
		document.write('onMouseOut="overSub_menu2=false;');
		document.write('setTimeout(\'hideSubMenu_menu2(\\\'submenu' + (x+1) + '_menu2\\\')\',delay_menu2);');
		document.write('setOutImg_menu2(\'' + (x+1) + '\',\'_menu2\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_menu2[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_menu2[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_menu2[x+1][k+1][2] + '">');
			document.write( subInfo_menu2[x+1][k+1][0] + '</a>');
			document.write('</li>');
		}
		document.write('</ul>');
	}
	document.write('</div>');
}


for ( x=0; x<totalButtons_menu3; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_menu3[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_menu3">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_menu3" class="dropmenu_menu3" ');
		document.write('onMouseOver="overSub_menu3=true;');
		document.write('setOverImg_menu3(\'' + (x+1) + '\',\'_menu3\');"');
		document.write('onMouseOut="overSub_menu3=false;');
		document.write('setTimeout(\'hideSubMenu_menu3(\\\'submenu' + (x+1) + '_menu3\\\')\',delay_menu3);');
		document.write('setOutImg_menu3(\'' + (x+1) + '\',\'_menu3\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_menu3[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_menu3[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_menu3[x+1][k+1][2] + '">');
			document.write( subInfo_menu3[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_menu1() {
	for ( x=0; x<totalButtons_menu1; x++ ) {
		buttonUp_menu1 = new Image();
		buttonUp_menu1.src = buttonFolder_menu1 + upSources_menu1[x];
		buttonOver_menu1 = new Image();
		buttonOver_menu1.src = buttonFolder_menu1 + overSources_menu1[x];
	}
}

function preload_menu2() {
	for ( x=0; x<totalButtons_menu2; x++ ) {
		buttonUp_menu2 = new Image();
		buttonUp_menu2.src = buttonFolder_menu2 + upSources_menu2[x];
		buttonOver_menu2 = new Image();
		buttonOver_menu2.src = buttonFolder_menu2 + overSources_menu2[x];
	}
}
// PRELOAD MAIN MENU BUTTON IMAGES
function preload_menu3() {
	for ( x=0; x<totalButtons_menu3; x++ ) {
		buttonUp_menu3 = new Image();
		buttonUp_menu3.src = buttonFolder_menu3 + upSources_menu3[x];
		buttonOver_menu3 = new Image();
		buttonOver_menu3.src = buttonFolder_menu3 + overSources_menu3[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg_menu1(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_menu1 + overSources_menu1[But-1];
}

function setOverImg_menu2(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_menu2 + overSources_menu2[But-1];
}
function setOverImg_menu3(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_menu3 + overSources_menu3[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg_menu1(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_menu1 + upSources_menu1[But-1];
}

function setOutImg_menu2(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_menu2 + upSources_menu2[But-1];
}

function setOutImg_menu3(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_menu3 + upSources_menu3[But-1];
}


//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement_menu1(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}
function getElement_menu2(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

function getElement_menu3(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft_menu1(id) { 
	var el = getElement_menu1(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

function getRealLeft_menu2(id) { 
	var el = getElement_menu2(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

function getRealLeft_menu3(id) { 
	var el = getElement_menu3(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_menu1(id) {
	var el = getElement_menu1(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

function getRealTop_menu2(id) {
	var el = getElement_menu2(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

function getRealTop_menu3(id) {
	var el = getElement_menu3(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_menu1(objectID,x,y) {
	var el = getElement_menu1(objectID);
	el.style.left = x;
	el.style.top = y;
}

function moveObjectTo_menu2(objectID,x,y) {
	var el = getElement_menu2(objectID);
	el.style.left = x;
	el.style.top = y;
}

function moveObjectTo_menu3(objectID,x,y) {
	var el = getElement_menu3(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_menu1(subID, buttonID) {
	hideAllSubMenus_menu1();
	butX = getRealLeft_menu1(buttonID);
	butY = getRealTop_menu1(buttonID);
	moveObjectTo_menu1(subID,butX+xSubOffset_menu1, butY+ySubOffset_menu1);
}

function showSubMenu_menu2(subID, buttonID) {
	hideAllSubMenus_menu2();
	butX = getRealLeft_menu2(buttonID);
	butY = getRealTop_menu2(buttonID);
	moveObjectTo_menu2(subID,butX+xSubOffset_menu2, butY+ySubOffset_menu2);
}

function showSubMenu_menu3(subID, buttonID) {
	hideAllSubMenus_menu3();
	butX = getRealLeft_menu3(buttonID);
	butY = getRealTop_menu3(buttonID);
	moveObjectTo_menu3(subID,butX+xSubOffset_menu3, butY+ySubOffset_menu3);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_menu1() {
	for ( x=0; x<totalButtons_menu1; x++) {
		moveObjectTo_menu1("submenu" + (x+1) + "_menu1",-500, -500 );
	}
}

function hideAllSubMenus_menu2() {
	for ( x=0; x<totalButtons_menu2; x++) {
		moveObjectTo_menu2("submenu" + (x+1) + "_menu2",-500, -500 );
	}
}

function hideAllSubMenus_menu3() {
	for ( x=0; x<totalButtons_menu3; x++) {
		moveObjectTo_menu3("submenu" + (x+1) + "_menu3",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_menu1(subID) {
	if ( overSub_menu1 == false ) {
		moveObjectTo_menu1(subID,-500, -500);
	}
}

function hideSubMenu_menu2(subID) {
	if ( overSub_menu2 == false ) {
		moveObjectTo_menu2(subID,-500, -500);
	}
}

function hideSubMenu_menu3(subID) {
	if ( overSub_menu3 == false ) {
		moveObjectTo_menu3(subID,-500, -500);
	}
}


//preload_menu1();
//preload_menu2();
//preload_menu3();
