//#########################################################################
// M O D I F I C A T I O N    Jonathan Parks 8/12/08     ISSUE # 4392
//#########################################################################
// Created the following script functions per Craig Wagner (see issue 4392)
//#########################################################################

/*
***********************************************************************************************
*    script by Craig Wagner 7/13/08                                                           *
*    JavaScript                                                                               * 
*    Style-a-Menu v1.0 - styles an unordered list and makes it function like a drop-down menu *
*    tested in ie 6, firefox 2 and safari 3                                                   *
***********************************************************************************************
*/

var mouseMe;
mouseMe="white";
var clickMe;
clickMe="hidden";

function crossScroll() {
	var d;
	d = document.getElementById("ullist");
	d.scrollTop -= d.scrollHeight;
}

function menuBlue () {
		document.getElementById("view").style.color="#FFFFFF";
		document.getElementById("view").style.backgroundColor="#0a246a";
}

function menuWhite() {
		document.getElementById("view").style.color="#000000";
		document.getElementById("view").style.backgroundColor="#FFFFFF";
}

document.body.onclick = function (e) {
	var targ;
	if (!e) {
            var e = window.event;
        }
	if (e.target) {
            targ = e.target;
        }
	else if (e.srcElement) {
            targ = e.srcElement;
        }
	
	switch (targ.id) {
		case ("view") :
			if (clickMe=="hidden") {
				document.getElementById("ullist").style.visibility="visible";
				crossScroll();
				menuBlue();
				clickMe="visible";
			}
			else if (clickMe=="visible") {
				document.getElementById("ullist").style.visibility="hidden";
				menuWhite();
				crossScroll();
				clickMe="hidden";
				mouseMe="white";
			}		
		break;
		default :
			document.getElementById("ullist").style.visibility="hidden";
			menuWhite();
			crossScroll();
			clickMe="hidden";
			mouseMe="white";
	}
};

function mouseIt() {
  var zap = document.getElementById('view');
     zap.onmouseover = function() {
	 if (mouseMe=="white"){
	 	menuBlue();
		mouseMe="blue";
		}
	};
	zap.onmouseout = function() {
	if (mouseMe=="blue" && clickMe=="hidden") {
		menuWhite();
		mouseMe="white";
		}
	};
}

window.attachEvent('onload', mouseIt); // IE6 only
