var isNav = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);

//TAG_ID_OF_IMG, HIGH_LIGHT_IMG, NORMAL_IMG
var menuData = [
	['nav_index', 'images/btn_home.jpg', 'images/btn_home2.jpg'],
	['nav_about', 'images/btn_about.jpg', 'images/btn_about2.jpg'],
	['nav_organization', 'images/btn_organization.jpg', 'images/btn_organization2.jpg'],
	['nav_getinvolved', 'images/btn_getinvolved.jpg', 'images/btn_getinvolved2.jpg'],
	['nav_contactus', 'images/btn_contactus.jpg', 'images/btn_contactus2.jpg'],
	['nav_meetings', 'images/btn_meetings.jpg', 'images/btn_meetings2.jpg'],
	['nav_projects', 'images/btn_projects.jpg', 'images/btn_projects2.jpg'],
	['nav_publications', 'images/btn_publications.jpg', 'images/btn_publications2.jpg'],
	['nav_pressroom', 'images/btn_pressroom.jpg', 'images/btn_pressroom2.jpg']
]


function findElem(ename) {
	for(var i = 0; i < menuData.length; i++) {
		rarry = menuData[i];
		if(ename == rarry[0]) {
			return rarry;
		}
	}
}

function getTargetElem(e) {
	if(isNav) {
		return e.target;
	}
		
	if(isIE) {
		e = window.event;
		return e.srcElement;
	}
}

function mouseOverHandler(e) {
	targetElem = getTargetElem(e);
	foundArry = findElem(targetElem.id);
	targetElem.src = foundArry[1];
	
}

function mouseOutHandler(e) {
	targetElement = getTargetElem(e);
	if(window.name == targetElem.id) return;
	foundArry = findElem(targetElem.id);
        targetElem.src = foundArry[2];
}

function clickHandler(e) {
	targetElement = getTargetElem(e);
	window.name = targetElement.id;
}

function loadMenu() {
	for(var i = 0; i < menuData.length; i++) {
		elemId = menuData[i][0];
		elem = document.getElementById(elemId);
		elem.onmouseover = mouseOverHandler;
		elem.onmouseout = mouseOutHandler;
		elem.onclick = clickHandler;
	}
	if(window.name == null || window.name.length == 0) window.name='CSLF Stakeholder Index';
}
