window.onload = function()
{

	highlightGlobalNav('midnav');
	highlightGlobalNav('topnav'); 
	highlightLocalNav('topnav'); 
	highlightLocalNav('sidenav');

	initializeMenu("menu-living", "menu-living-starter");
	initializeMenu("menu-working", "menu-working-starter");
	initializeMenu("menu-visiting", "menu-visiting-starter");
	initializeMenu("menu-business", "menu-business-starter");
	initializeMenu("menu-government", "menu-government-starter");
	initializeMenu("menu-emergencies", "menu-emergencies-starter");

}


function highlightGlobalNav(navdiv)
{
	var thissection = window.location.toString().split('/')[3];
	var navul = document.getElementById(navdiv);
	if (navul) {
		var navanchors = navul.getElementsByTagName('a');
		if (navanchors) {
			for(var i = 0; i <= navanchors.length-1; i++) {
				if (navanchors[i].href.toString().split('/')[3] == thissection) {
					navanchors[i].className = 'here';
				} else {
					navanchors[i].className = 'nothere';
				}
			}
		}
	}
}


function highlightLocalNav(navdiv)
{
	var thispath = window.location.toString().split('#')[0].split('?')[0];
	var thispath = window.location.toString()
	
	var navwrap = document.getElementById(navdiv);
	
	if (navwrap) {
		var navanchors = navwrap.getElementsByTagName('a');

		if (navanchors) {
			for(var i = 0; i <= navanchors.length-1; i++) {
				if (navanchors[i].href == thispath) {
					navanchors[i].className = 'here';
				} else {
					navanchors[i].className = 'nothere';
				}
			}
		}
	}
}


function clearfield (val, element) {
   if (element.value == val) element.value = "";
}








/*
dropdown menu
*/


var currentMenu = null;
var mytimer = null;
var timerOn = false;
var opera = window.opera ? true : false;

if (!document.getElementById) document.getElementById = function() { return null; }

function initializeMenu(menuId, starterId) 
{
	var menu =    document.getElementById(menuId);
	var starter = document.getElementById(starterId);

	if (menu == null || starter == null) return;
	
	currentMenu = menu;


	starter.onmouseover = function() {
		if (currentMenu) {
			currentMenu.style.visibility = "hidden";
			currentMenu = null;
			this.showMenu();
			stopTime();
		}
	}

	menu.onmouseover = function() {
		if (currentMenu) {
			currentMenu.style.visibility = "hidden";
			currentMenu = null;
			this.showMenu();
		}
	}	


	menu.onmouseout = function(event) { this.hideMenu(); }
	starter.onmouseout = function() {   menu.hideMenu(); }


	starter.onfocus	 = function() { this.onmouseover(); }
	starter.onblur	 = function() { this.onmouseout(); }


	starter.showMenu = function() {
		//menu.style.left = this.offsetLeft + "px"; // this is pre-established in the css now
		if (!opera) { menu.style.top = this.offsetTop + this.offsetHeight + "px"; }
		else {        menu.style.top = this.offsetHeight + "px"; }
		menu.style.visibility = "visible";
		currentMenu = menu;
	}
	
	menu.showMenu = function() {
		menu.style.visibility = "visible";
		currentMenu = menu;
		stopTime();
	}


	menu.hideMenu = function()  {
		if (!timerOn) {
			mytimer = setTimeout("killMenu('" + menuId + "');", 0);
			timerOn = true;
		}
	}
}


function killMenu(amenu) 
{
	var menu = document.getElementById(amenu);
	menu.style.visibility = "hidden";
	stopTime();
}


function stopTime() 
{
	if (mytimer) {
		 clearTimeout(mytimer);
		 mytimer = null;
		 timerOn = false;
	}
} 


/*
	pop open the popups
*/
function popup(theURL,theName,theParam) {
	window.open(theURL,theName,theParam);
}

function diabletxt_changelbls(){
document.getElementById('email_addr1').readOnly = true;
document.getElementById('ek_confirmpwd_label').innerHTML = '<span id="ek_cnfpass_mark" style="color:red">*</span>Confirm Password:';
document.getElementById('ek_email_label').innerHTML = '<span id="ek_email_mark" style="color:red">*</span>email Address:';
}

function changelbls(confirmpwd,email_addr_lbl){
document.getElementById('ek_confirmpwd_label').innerHTML = '<span id="ek_cnfpass_mark" style="color:red">*</span>Confirm Password:';
document.getElementById('ek_email_label').innerHTML = '<span id="ek_email_mark" style="color:red">*</span>email Address:';
}

