var defaultUsername = '';
var defaultPassword = '';

function initPage()
{	
	initNav();	
	initInputs();	
}

function initNav()
{
	var nav = document.getElementById("nav");	
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");
		var activeNode = -1;
		for (var i = 0; i < nodes.length; i++)
		{			
			if (nodes[i].className == "active" && nodes[i].id)
			{
				activeNode = i;
			}
		}
		
			
		for (var i = 0; i < nodes.length; i++)
		{
			if (nodes[i].parentNode.id == "nav")
			{
				if (activeNode> -1 && activeNode != i && nodes[i].id)
				{
					nodes[i].onmouseover = function () 
					{						
						if (this.className.indexOf("hover") == -1)
						{
							this.className = " hover";
							nodes[activeNode].className = "";
						}
					}
					nodes[i].onmouseout = function ()
					{						
						this.className = this.className.replace("hover", "");						
						nodes[activeNode].className = "active";
					}
				}
				else
				{
					nodes[i].onmouseover = function () 
					{
						if (this.className.indexOf("hover") == -1)
						{
							this.className += " hover";							
						}
					}
					nodes[i].onmouseout = function ()
					{						
						this.className = this.className.replace("hover", "");
					}					
				}
			}
		}
	}	
}

function initInputs()
{
	var login = document.getElementById("login");	
	defaultUsername = login.value;
	
	var login_focus_event = function ()
	{
		if (defaultUsername == this.value ) 
			this.value = "";
	};
	
	var login_blur_event = function ()
	{
		if (this.value == "")
			this.value = defaultUsername;
	}
	
	if (login)
	{
		login.onfocus = login_focus_event;
		login.onblur = login_blur_event;
	}
	
	var pass = document.getElementById("password");	
	var pass_changed = false;
	
	var pass_focus = function()
	{
		var passwd = document.getElementById("password");

		passwd.focus();
	}
	
	defaultPassword = pass.value;
	
	var pass_event = function ()
	{		
		if (!pass_changed){
						
			pass_changed = true;			
			if (!isIE())
			{				
				pass.type = "password";
				pass.focus();
			}
			else
			{
				var np=pass.cloneNode(true);
				np.type = 'password';
				pass.parentNode.replaceChild(np,pass);
				setTimeout(pass_focus, 0);			
			}
			document.getElementById("password").value = "";
		}
	};

	if (pass)
	{
		pass.onfocus = pass_event;
	}
	
	var archive = document.getElementById('archive_month');
	if (archive) {
	 archive.onchange = function () {
	     document.location = archive.value;
    }
  }
	
}

/*if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initPage);*/
if (window.addEventListener){
 window.addEventListener("load", initPage, false);
}
else if (window.attachEvent){
 window.attachEvent("onload", initPage);
}
	
function initLeader()
{
	var nav = document.getElementById("leadership-photos");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");			
		var activeNode = -1;
		for (var i = 0; i < nodes.length; i++)
		{			
			if (nodes[i].className == "active")
			{
				activeNode = i;
			}
		}	
	
		
		for (var i = 0; i < nodes.length; i++)
		{		

			if (nodes[i].parentNode.id == "leadership-photos")
			{
				if (activeNode> -1 && activeNode != i)
				{
					nodes[i].onmouseover = function () 
					{						
						if (this.className.indexOf("hover") == -1)
						{
							this.className = " hover";
							nodes[activeNode].className = "";
						}
					}
					nodes[i].onmouseout = function ()
					{						
						this.className = this.className.replace("hover", "");						
						nodes[activeNode].className = "active";
					}
				}
				else
				{
					nodes[i].onmouseover = function () 
					{
						if (this.className.indexOf("hover") == -1)
						{
							this.className += " hover";							
						}
					}
					nodes[i].onmouseout = function ()
					{						
						this.className = this.className.replace("hover", "");
					}					
				}
			}
		}
	}
}

/*if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initLeader);
*/	

if (window.addEventListener){
 window.addEventListener("load", initLeader, false);
}
else if (window.attachEvent){
 window.attachEvent("onload", initLeader);
}

 function isIE() {
		return typeof(document.all) != "undefined" && typeof(window.opera) == "undefined";
}