
var buttonFolder = "http://www.entrytime.com/media/images/buttons/";


upSources = new Array("button1up.jpg","button2up.jpg","button3up.jpg","button4up.jpg","button5up.jpg","button6up.jpg");

overSources = new Array("button1over.jpg","button2over.jpg","button3over.jpg","button4over.jpg","button5over.jpg","button6over.jpg");


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[1][1] = new Array("Full Event Calendar","http://www.entrytime.com/index.asp?goto=af&afid=22&pt=events&typeid=3","");
subInfo[1][2] = new Array("Event Results","http://www.entrytime.co.za/index.asp?goto=af&afid=22&pt=results","");
subInfo[1][3] = new Array("MTB Home","http://www.entrytime.com/index.asp?goTo=affiliate&affiliateId=21&pageType=home","");
subInfo[1][4] = new Array("Entrytime Home","http://www.entrytime.com/index.asp?goTo=affiliate&affiliateId=4&pageType=home","");
subInfo[1][5] = new Array("ASA Rules","http://www.entrytime.com/index.asp?goto=fetch&afid=22&pt=article&itemid=2065&typeid=6","");


subInfo[3][1] = new Array("Race News","http://www.entrytime.com/index.asp?goto=af&afid=22&pt=racereports","");
subInfo[3][2] = new Array("Latest News","http://www.entrytime.com/index.asp?goto=af&afid=22&pt=articles","");

subInfo[4][1] = new Array("SAMPA Registration","http://www.entrytime.com/index.asp?goto=fetch&afid=4&pt=article&itemid=1399&typeid=6","");
subInfo[4][2] = new Array("Cycling Licence Application Form","http://www.entrytime.com/extras/CyclingLicenceApplicationForm2006V02.doc","");

var xSubOffset = 117;
var ySubOffset = 5;




var overSub = false;
var delay = 1000;
totalButtons = upSources.length;


for ( x=0; x<totalButtons; x++) {
	
	if ( subInfo[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '">');
	
	} 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>');
}







function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}


function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}


function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}




function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}


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;
	} 
} 


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;
	}
}


function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
}


function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}


function hideAllSubMenus() {
	for ( x=0; x<totalButtons; x++) {
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}


function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
	}
}



//preload();

