var arrMenuIds = new Array(
	"services-menu",
	"programs-menu",
	"about-menu"
);
var objMenuMappings = new Object();

/**
 * The objMenuMappings Object was modified on 12/4/07 to store arrays of strings instead of only strings.
 * The result is that multiple menus can be expanded by mapping more than one menu to a url.
 **/

/* services menu */
objMenuMappings[""] = [ "services-menu", "programs-menu" ];
objMenuMappings["index.php"] = [ "services-menu", "programs-menu" ];
objMenuMappings["spanish-classes.php"] = [ "services-menu" ];
objMenuMappings["translation.php"] = [ "services-menu" ]; 
objMenuMappings["clases-de-ingles.php"] = [ "services-menu" ];
objMenuMappings["personal-development.php"] = [ "services-menu" ];
objMenuMappings["cultural-presentations.php"] = [ "services-menu" ];
objMenuMappings["leadership-development.php"] = [ "services-menu" ];
objMenuMappings["technical-assistance-for-latino-cbos.php"] = [ "services-menu" ];
objMenuMappings["study-spanish-abroad.php"] = ["services-menu" ];
objMenuMappings["coming-out.php"] = [ "services-menu" ];
objMenuMappings["invisibility.php"] = [ "services-menu" ];

/* projects menu */
objMenuMappings["english-spanish-intercambio.php"] = [ "programs-menu" ];
objMenuMappings["hiv-aids-health-educator-program.php"] = [ "programs-menu" ];
objMenuMappings["general-health-educators.php"] = [ "programs-menu" ];
objMenuMappings["latino-young-adult-leadership-council.php"] = [ "programs-menu" ];

/* about menu */
objMenuMappings["map.php"] = [ "about-menu" ];
objMenuMappings["calendar-of-events.php"] = [ "about-menu" ];
objMenuMappings["board-of-directors.php"] = [ "about-menu" ];
objMenuMappings["staff.php"] = [ "about-menu" ];

/* other */
objMenuMappings["support-educate-ya.php"] = [ "services-menu" ];


/********************************************************************************/

//alert("test: " + objMenuMappings[""].length);
//alert("test: " + objMenuMappings["index.php"]);
function init(){
	if(window.top.frames.length > 0){
		window.top.location.href = window.location.href;
	}

	/* google analytics tracking */
	_uacct = "UA-1715326-1";
	urchinTracker();
}


function writeEmailAddressLink(strLabel){
	// use http://www.wbwip.com/wbw/emailencoder.html to encode
	var strMailTo = "&#109;&#097;&#105;&#108;&#116;&#111;:";
	var strEmailAddress = "&#105;&#110;&#102;&#111;&#064;&#101;&#100;&#117;&#099;&#097;&#116;&#101;&#121;&#097;&#046;&#111;&#114;&#103;";
	if(strLabel == null || strLabel == "" || typeof(strLabel) == "undefined"){
		strLabel = strEmailAddress;
	}
	document.write("<a href=\"" + strMailTo + strEmailAddress + "\">" + strLabel + "</a>");
}


function setActiveMenuSection(){
	var strUrl = document.location.href;
	var intIdx = strUrl.lastIndexOf("/");
	if(intIdx > -1){
		strUrl = strUrl.substring(intIdx + 1);
	}

	//Added the for loop to accomodate multiple url mappings to expand multiple menus by default on 12/4/07
	var strMenuId = objMenuMappings[strUrl];
	for(i in objMenuMappings[strUrl]) {
		var strMenuId = objMenuMappings[strUrl][i];
		show(strMenuId);
	} 

	/*var strOtherId;
	if(strMenuId != undefined){
		for(var i=0; i<arrMenuIds.length; i++){
			strOtherId = arrMenuIds[i];
			if(strOtherId.toString() != strMenuId.toString()){
				hide(strOtherId);
			}
		}
	}*/
}

function toggleMenu(strMenuId){
	toggleVisibility(strMenuId);

	var strOtherId;
	for(var i=0; i<arrMenuIds.length; i++){
		strOtherId = arrMenuIds[i];
		if(strOtherId != strMenuId){
			hide(strOtherId);
		}
	}
}

function toggleVisibility(strElementId){
	var objElement = getElement(strElementId);

	if(objElement != null){
		if(objElement.style.display == 'none'){
			showElement(objElement);
		}
		else{
			hideElement(objElement);
		}
	}
}

function show(strElementId){
	var objElement = getElement(strElementId);
	if(objElement != null){
		showElement(objElement);
	}
}

function hide(strElementId){
	var objElement = getElement(strElementId);
	if(objElement != null){
		hideElement(objElement);
	}
}


function getElement(strElementId){
	var objElement = null;
	if(document.getElementById){
		objElement = document.getElementById(strElementId);
	}
	else if(document.layers){
		objElement = document[strElementId];
	}
	else if(document.all) {
		objElement = document.all[strElementId];
	}

	return objElement;
}


function showElement(objElement){
	if(objElement.style){
		objElement.style.display = 'block';
	}
}

function hideElement(objElement){
	if(objElement.style){
		objElement.style.display = 'none';
	}
}
