window.addEvent('domready', function() {
	
	// Only execute if a form is present on the current page with the Doc2Form class
	if ($$('.Doc2Form')) {
		// Iterate through all of the list items with the 'required' class and append 
		// an asteriks to their labels to imply to the user that these fields are required
		for (iCnt = 0; iCnt < $$('.required label strong').length; iCnt++) {
			$$('.required label strong')[iCnt].innerHTML = $$('.required label strong')[iCnt].innerHTML + '*';
		}
	}

});

window.onload = hoverMenu;

function hoverMenu() {
	var IE6 = false;
	var navi = navigator.appVersion;
	if(navi.indexOf("MSIE")>-1){
		var navAr = navi.split(";");
		if(parseFloat(navAr[1].split(" ")[2])>5.5){IE6=true;}
	}
	var menu = document.getElementById('mainnav');
	var li = menu.getElementsByTagName('li');
	for (i=0;i<li.length;i++) {
		li[i].onmouseover = expandMenu;
		li[i].onmouseout = collapseMenu;
	}
	
	function expandMenu() {
		if (IE6 && !current(this, true)) {
			this.className += ' sfhover';
		}
		if (!current(this) && getElementsByClass('current', menu)[0]) {
			var mainCurrent = getElementsByClass('current', menu)[0].childNodes[0];
			mainCurrent.style.color = '#3A7ABA';
			mainCurrent.style.backgroundColor = '#FFF';
			toggleTree(mainCurrent, 'hidden');
		}
	}
	
	function collapseMenu() {
		if (IE6 && !current(this, true)) {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}

		if (!current(this) && getElementsByClass('current', menu)[0]) {
			var mainCurrent = getElementsByClass('current', menu)[0].childNodes[0];
			mainCurrent.style.color = '#FFF';
			mainCurrent.style.backgroundColor = '#878787';
			toggleTree(mainCurrent, 'visible');
		}
	}
	
	function current(e, s) {
		//alert(e.className+' - '+e.parentNode.parentNode.className);
		if (e.className == 'current' || (!s && e.parentNode.parentNode.className == 'current')) {
			return true;
		}
		return false;
	}
	
	function toggleTree(e, vis) {
		e.childNodes[0].style.visibility = vis;
		e.childNodes[2].style.visibility = vis;
		var ul = getElementsByClass('current', menu)[0].getElementsByTagName('ul')[0];
		if (vis == 'hidden') {
			ul.style.left = '-999em';
		} else {
			ul.style.left = 'auto';
		}
	}
}