var strCurrentMenu;

/** ALL EXTERNAL LINKS TO OPEN UP IN NEW WINDOW: **/
function processExternals(){
	strHost = document.location.hostname;
	clLnks = document.links;
	for (i=0;i<clLnks.length;i++) {
		if ((clLnks[i].href.search(strHost) == -1 && clLnks[i].href.search('mailto:') == -1) && clLnks[i].href.search('http://') != -1){
			clLnks[i].target = "_blank";
		}
	}
	//NOTE: clLnks[i].href.search('http://') != -1 is because Safari only returns script name and not host name, leading to all Links opening in a new window
}

/** TOGGLE SUBMENUS ON ROLLOVER: **/
function toggle(eSourceElt,bState){
	var strEltId = ((eSourceElt.id).indexOf("menu") != -1)?(eSourceElt.id).substring(5):((eSourceElt.id).split("_"))[1];
	/*hide previously open submenu:*/
	if(strCurrentMenu) {
		var objMenu = document.getElementById("subsection_" + strCurrentMenu);
		if (objMenu) objMenu.style.display = "none";		
	}
	//if(strCurrentMenu.toLowerCase() != getfromquerystring("pageid")) {}
	/*display submenu:*/
	if(document.getElementById("menu_" + strEltId)) {
		if (document.getElementById("subsection_" + strEltId)){
			document.getElementById("subsection_" + strEltId).style.top = document.getElementById("menu_" + strEltId).offsetTop - 1 + "px";
			document.getElementById("subsection_" + strEltId).style.display = "block";
		}
	}
	
	/*reset current menu var:*/
	//if (strCurrentMenuId != "") strEltId = "";	
	strCurrentMenu = strEltId;
}

function getfromquerystring(item) {
	//if (item != null) {
		tempString = location.search.substring(1);
		itemLength = item.length;
		start = tempString.indexOf(item);
		if (start != -1) {
			start += itemLength + 1;
			tempString = tempString.substring(start);
			end = tempString.indexOf("&");
			if (end != -1) tempString = tempString.substring(0,end);
		}
		else tempString = "";
		return tempString;
	//}
}
