//	---------------------------------------------------------------------------
//	FUNCTION:	menuDropDown()
//	AUTHOR:		Ryan J. Salva
//	REVISED:	August 2005
//
//	Creates a drop-down menu for navigation. Also Corrects Windows IE support 
//	for LI:hover and adds an <IFRAME> behind drop-down menus to keep the 
//	menu above <SELECT> elements.
//
//	REQUIREMENTS:
//	Styles found in default.css
//	
//	TESTED IN:
//	Windows: IE 6, Firefox 1, Opera 8
//	Mac: IE 5.2, Firefox 1, Safari 1


var browser = navigator.appName;
var browserVersion = parseFloat(navigator.appVersion);
var is_ie = (browser=="Microsoft Internet Explorer")?true:false;

var myAgent   = navigator.userAgent.toLowerCase();
var is_win = ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1)); 
var is_mac = (myAgent.indexOf("mac")!=-1); 

function menu() {
	var m = document.getElementsByTagName("UL");
	for (x=0; x<m.length;x++) {
		if (m[x].className == "DropDown") {
			if (is_win) {
				var u = m[x].getElementsByTagName("UL");
				for (n=0;n<u.length;n++) {
					// IE displays <select> elements over dropdown menus
					// so we use an <iframe> to stand between the menu and all other page elements
					// don't forget to set width and height to "0" so that we calculate the style correctly
					u[n].innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0" width="0" height="0"></iframe>' + u[n].innerHTML);
					
					// we know the frame is the first child because we just added it!
					var f = u[n].firstChild;

					// adjust frame style to exactly cover the menu
					f.style.width=u[n].offsetWidth+"px";
					f.style.height=u[n].offsetHeight+"px";
					f.style.position="absolute";	
					f.style.left="0px";	
					f.style.top="0px";	
					f.style.zIndex="-10";	
					f.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
					
					// move the z-index (layer) to the top of the page
					u[n].style.zIndex="99";
				}
			}

			var i = m[x].getElementsByTagName("LI");
			for (var n=0; n<i.length; n++) {
				i[n].onmouseover=function() {
				this.className+=(this.className.length>0? " ": "") + "iehover";
				}
				// event added to keep menu items from disappearing
				i[n].onMouseDown=function() {
				this.className+=(this.className.length>0? " ": "") + "iehover";
				}
				// event added to keep menu items from disappearing
				i[n].onMouseUp=function() {
				this.className+=(this.className.length>0? " ": "") + "iehover";
				}
				i[n].onmouseout=function() {
				this.className=this.className.replace(new RegExp("( ?|^)iehover\\b"), "");
				}
			}
		}
	}	
}
if (is_ie) Event.observe(window,"load",menu);
