/*** 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");

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");

// 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();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//



subInfo[3][1] = new Array("VK3REB upgraded to a Tait","photos.htm","");
subInfo[3][2] = new Array("W.I.C.E.N Rally 2008","photos.htm#WICEN","");
subInfo[3][3] = new Array("May 2008 club meeting","photos.htm#EGARC","");
subInfo[3][4] = new Array("VK3HAU's APRS setup","photos.htm#VK3HAU","");

subInfo[4][1] = new Array("Tropospheric ducting forecasts","http://www.dxinfocentre.com/tropo_aus.html#hour6","_BLANK");
subInfo[4][2] = new Array("APRS Supplies","http://www.byonics.com/","_BLANK");
subInfo[4][3] = new Array("Q Codes","http://en.wikipedia.org/wiki/Q_code#Amateur_radio","_BLANK");
subInfo[4][4] = new Array("Band Plans","http://www.wia.org.au/members/bandplans/data/documents/Australian%20Band%20Plans%20080513.pdf","_BLANK");
subInfo[4][5] = new Array("Solar Cycle","http://www.swpc.noaa.gov/SolarCycle/","_BLANK");
subInfo[4][6] = new Array("QRZ.COM","http://www.qrz.com/callsign/VK3EGC","_BLANK");
subInfo[4][7] = new Array("Coxial cable attenuation chart","http://rfi.com.au/downloads/wireless/cables-connectors/coxial-cable-attenuation-chart.pdf","_BLANK");
subInfo[4][8] = new Array("Coxial cable Velocity chart","http://rfi.com.au/downloads/wireless/cables-connectors/50-0hm-braided-coaxial-cables.pdf","_BLANK");
subInfo[4][9] = new Array("Wireless institute of Australia","http://www.wia.org.au/","_BLANK");
subInfo[4][10] = new Array("VK3BEZ web site","http://www.vk3bez.org/","_BLANK");


subInfo[11][1] = new Array("EGARC Application Word Doc file","egarc application.wps","_BLANK");
subInfo[11][2] = new Array("EGARC Application PDF file","EGARC application.pdf","_BLANK");



subInfo[10][1] = new Array("President","mailto:president@vk3egc.org?subject=Query from website to the President of EGARC inc","");
subInfo[10][2] = new Array("Secretary","mailto:secretary@vk3egc.org?subject=Query from website to the Secretary of EGARC inc","");
subInfo[10][3] = new Array("Treasurer","mailto:treasurer@vk3egc.org?subject=Query from website to the Treasurer of EGARC inc","");
subInfo[10][4] = new Array("Assessors - Bob VK3ZAN","mailto:dotbob@netspace.net.au?subject=Query from website to Assessors","");
subInfo[10][5] = new Array("Assessors - Rex VK3ARG","mailto:rexgfoord@thefoords.net?subject=Query from website to Assessors","");
subInfo[10][6] = new Array("Learning Facilitator - Barney VK3XBW","mailto:barneywinton@netspace.net.au?subject=Query from website to Learning Facilitator","");
subInfo[10][7] = new Array("Publicity Officer - Michael VK3HAU","mailto:vk3hau@vk3egc.org?subject=Query from website to Publicity Officer","");
subInfo[10][8] = new Array("Web Master","mailto:webmaster@vk3egc.org?subject=Query from website to Web Master","");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = -5;
var ySubOffset = 20;



//*** 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();

