function initDate(){
	var monthNames = new Array("January","February","March","April", "May","June","July","August", "September","October","November","December");
	var now = new Date();
	var theYear = now.getYear()
	if (theYear < 2000)
    	theYear += 1900;
	if (document.getElementById("jsdate"))
		document.getElementById("jsdate").innerHTML = "Today's Date is " + monthNames[now.getMonth()] + " " + now.getDate() + ", " + theYear;
}

function initLogin(){
	addAnEvent(document.getElementById("username"),'focus',clearTextbox);
	addAnEvent(document.getElementById("password"),'focus',clearTextbox);
}

function clearTextbox(){
	if (this.value == "Password") return toPassword(this);
	this.value = "";
}

function toPassword(oInput) {
	var newEl = document.createElement('input');
	newEl.setAttribute('type', 'password');
        newEl.setAttribute('name', 'password');
	oInput.parentNode.replaceChild(newEl,oInput);
	toPassword.el = newEl;
	setTimeout('toPassword.el.focus()',100);
	return true;
}

function initNav(){
	if (document.getElementById("nav")){
		var nav = document.getElementById("nav");
		var navul = nav.getElementsByTagName("ul");
		
		for (var u = 0; u<navul.length; u++){
			var navname = navul[u].id.slice(3);
			
			
			var navas = navul[u].getElementsByTagName("a");
			for (var a = 0; a<navas.length; a++){
				var currenthref=String(navas[a].href);
				currenthref=currenthref.split("?");
				
				var currentloc=String(document.location);
				currentloc=currentloc.split("?");
				if (unescape(currenthref[0])==unescape(currentloc[0]) || navas[a].className == "there"){
				navas[a].style.background = "#fff url(http://www.mrinetwork.com/img/nav-" + navname + ".gif) -164px -" + (a)*21 + "px no-repeat";
				} else {
				navas[a].style.background = "#fff url(http://www.mrinetwork.com/img/nav-" + navname + ".gif) 0 -" + (a)*21 + "px no-repeat";
				addAnEvent(navas.item(a),'mouseover',navHover);
				addAnEvent(navas.item(a),'mouseout',navHoverout);
				}
			}
		}
	}
	initDate(); initLogin(); checkFocus();
}

function navHover(){
	if (this.style.backgroundPosition){
	var pos = this.style.backgroundPosition.split(" ");
	var y = pos[1];
	this.style.backgroundPosition = "-164px " + y;
	} else
	this.style.backgroundPositionX = "-164px";
}

function navHoverout(){
	if (this.style.backgroundPosition){
	var pos = this.style.backgroundPosition.split(" ");
	var y = pos[1];
	this.style.backgroundPosition = "0 " + y;
	} else
	this.style.backgroundPositionX = "0";
}

function addAnEvent( target, eventName, functionName){
        eval('target.on'+eventName+'=functionName');
}

function checkFocus(){
	if(!document.getElementById("rightcontent") && (!document.getElementById("bodyrv")) && (!document.getElementById("bodybp"))){
		var h1 = document.getElementsByTagName("h1");
		h1[0].style.marginRight = "-40px";
		document.getElementById("body").style.padding = "7px 40px 17px 19px"
	}
}

window.onload = initNav;
