/*********************************************************************
 * Menu V 1.1 6/8/2001
 * By Todd Baker
 *
 *
 * Based on menu.js by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 * 
 *
 * Modified by XT3/IGA:
 *
 *	David Forster:	Debugged to work with IE5 on a Mac
 *			Added functionality to work on NS6 (Gecko)
 *
 *	Todd Baker:	Incoported Daves browser detection into the script
 *			Added functionality to define height of each menu item. 
 *			(For two line menus you need to ad <br>'s to get netscape to wrap it)
 *			Added simpleDrop Shadow to IE 5.5(using Microsoft.Shadow filter) and to NS6 (using a grey 2px at the bottom and right)
 */

/******* Browser detection *********/
var is;
function Is (){
    var agt=navigator.userAgent.toLowerCase();
    this.major		= parseInt(navigator.appVersion);
    this.minor		= parseFloat(navigator.appVersion);
    this.nav			= ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav4		= (this.nav && (this.major == 4));
    this.nav4up		= (this.nav && (this.major >= 4));    
    this.nav6		= (this.nav && (this.major == 5));
    this.nav6up		= (this.nav && (this.major >= 5));
    this.ie			= ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie4			= (this.ie && (this.major == 4) && (agt.indexOf("msie 5")==-1) );
    this.ie4up		= (this.ie && (this.major >= 4));
    this.ie5			= (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5		= (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5")!=-1));
    this.ie6			= (this.ie && (this.major == 4) && (agt.indexOf("msie 6.0")!=-1));
    this.ie5up		= ((this.ie && !this.ie4) || this.ie6);
    this.ie5_5up	= ((this.ie && !this.ie4 && !this.ie5) || this.ie6);
    this.ie6up		= ((this.ie && !this.ie4 && !this.ie5 && !this.ie5_5) || this.ie6);
    this.mac			= (agt.indexOf("mac")!=-1);
}
is = new Is(); 

/******* End Browser detection ******/



 
function Menu(label) {
    this.version = "1.2 [menu.js; Menu; 990602]";
    this.type = "Menu";
	this.fontSize = 10;
    this.fontWeight = "plain";
    this.fontFamily = "verdana,arial,helvetica,espy,sans-serif";
    this.fontColor = "#ffffff";
    this.fontColorHilite = "#000000";
    this.bgColor = "#99CCFF";
    this.menuBorder = 0;
    this.menuItemWidth = 100;
    this.menuItemBorder = 0;
    this.menuItemBgColor = "#3399CC";
    this.menuLiteBgColor = "#CBAFD7";
    this.menuBorderBgColor = "#99CCFF";
    this.menuHiliteBgColor = "#3399CC";
    this.menuContainerBgColor = "#99CCFF";
    this.menuContainerDropShadow = true;
    this.childMenuIcon = "";
    this.childMenuIconHilite = "";
    this.items = new Array();
    this.actions = new Array();
    this.colors = new Array();
    this.height = new Array();    
    this.mouseovers = new Array();
    this.mouseouts = new Array();
    this.childMenus = new Array();
	this.disableDrag = true;
	
    this.addMenuItem = addMenuItem;
    this.addMenuSeparator = addMenuSeparator;
    this.writeMenus = writeMenus;
    this.showMenu = showMenu;
    this.onMenuItemOver = onMenuItemOver;
    this.onMenuItemOut = onMenuItemOut;
    this.onMenuItemDown = onMenuItemDown;
    this.onMenuItemAction = onMenuItemAction;
    this.hideMenu = hideMenu;
    this.hideChildMenu = hideChildMenu;
    this.mouseTracker = mouseTracker;
    this.setMouseTracker = setMouseTracker;

    if (!window.menus) window.menus = new Array();
    this.label = label || "menuLabel" + window.menus.length;
    window.menus[this.label] = this;
    window.menus[window.menus.length] = this;
    if (!window.activeMenus) window.activeMenus = new Array();
    if (!window.menuContainers) window.menuContainers = new Array();
    if (!window.mDrag) {
        window.mDrag    = new Object();
        mDrag.startMenuDrag = startMenuDrag;
        mDrag.doMenuDrag    = doMenuDrag;
        this.setMouseTracker();
    }
    if (window.MenuAPI) MenuAPI(this);
}

function addMenuItem(label, action, height, color, mouseover, mouseout) {
    this.items[this.items.length] = label;
    this.actions[this.actions.length] = action;
    this.height[this.height.length] = height;
	this.colors[this.colors.length] = color;
    this.mouseovers[this.height.length] = mouseover;
    this.mouseouts[this.mouseouts.length] = mouseout;
}

function addMenuSeparator() {
    this.items[this.items.length] = "separator";
    this.actions[this.actions.length] = "";
    this.menuItemBorder = 0;
}

function objLookup(strID) {
	if (is.ie4up) 
		return document.all(strID)
	else if (is.nav6up)
		return document.getElementById(strID)
}



function writeMenus(container) {
    if (!container && is.nav4) {
        if (eval("document.width")) 
            container = new Layer(1000);
    } else if (!container && is.ie4up) {
        if (!document.all["menuContainer"]) 
            document.writeln('<SPAN ID="menuContainer"></SPAN>');
        container = document.all["menuContainer"];
    } else if (!container && is.nav6up) {
        if (!document.getElementById("menuContainer")) {
			var spanelement =  document.createElement("SPAN");
			spanelement.id = "menuContainer";
			var newtext = document.createTextNode("") ;
		    spanelement.appendChild(newtext) ;
			document.body.appendChild(spanelement);
        }
        container = document.getElementById("menuContainer");
    }
    if (!container && !window.delayWriteMenus) {
        window.delayWriteMenus = this.writeMenus;
        window.menuContainerBgColor = this.menuContainerBgColor;
        setTimeout('delayWriteMenus()', 3000);
        return;
    }

    
    container.isContainer = "menuContainer" + menuContainers.length;
    menuContainers[menuContainers.length] = container;
    container.menus = new Array();
    for (var i=0; i<window.menus.length; i++) 
        container.menus[i] = window.menus[i];
    window.menus.length = 0;
    var countMenus = 0;
    var countItems = 0;
    var top = 0;
    var content = '';
    var proto;

    for (var i=0; i<container.menus.length; i++, countMenus++) {
        var menu = container.menus[i];
        proto = menu.prototypeStyles || this.prototypeStyles || menu;
        content += ''+
        //'<DIV ID="shadowLayer'+ countMenus +'" STYLE="position:absolute;bordercolor:#000000;left:10;top:'+ i +';visibility:hidden;cursor:hand;"><table width="101%" height="101% bgcolor="#cccccc" cellspacing="0" cellpadding="5" border="1"><tr><td>\n'+
        '<DIV ID="menuLayer'+ countMenus +'" STYLE="position:absolute;left:10;top:'+ i +';visibility:hidden;cursor:hand;">\n'+
        '  <DIV ID="menuLite'+ countMenus +'" STYLE="position:absolute;left:'+ proto.menuBorder +';top:'+ proto.menuBorder +';visibility:hide;cursor:hand;" onMouseOut="hideMenu(event);">\n'+
        '    <DIV ID="menuFg'+ countMenus +'" STYLE="position:absolute;left:1;top:1;visibility:hide;cursor:hand;">\n'+
        '';
        var x=i;
        for (var i=0; i<menu.items.length; i++) {
            var item = menu.items[i];
            var childMenu = false;
            var defaultHeight = 20;
            var defaultIndent = 5;
            if (item.label) {
                item = item.label;
                childMenu = true;
            } else if (item.indexOf(".gif") != -1 && item.indexOf("<IMG") == -1) {
                item = '<IMG SRC="' + item + '" ALIGN="right" NAME="menuItem'+ countItems +'Img">';
                defaultIndent = 0;
                if (document.layers) {
                    defaultHeight = null;
                }
            }
            proto.menuItemHeight = proto.menuItemHeight || defaultHeight;
            proto.menuItemIndent = proto.menuItemIndent || defaultIndent;
            var itemProps = 'visibility:hide;font-Family:' + proto.fontFamily +';font-Weight:' + proto.fontWeight + ';fontSize:' + proto.fontSize + 'px;';
            if (is.ie4up || is.nav6up){
                itemProps += 'font-size:' + proto.fontSize + 'px;" onMouseOver="onMenuItemOver(null,this);" onMouseOut="onMenuItemOut(event,this);" onClick="onMenuItemAction(null,this);';
            }
            var dTag    = '<DIV ID="menuItem'+ countItems +'" STYLE="position:absolute;left:0;top:'+ (i * proto.menuItemHeight) +';'+ itemProps +'">';
            var dText   = '<DIV ID="menuItemText'+ countItems +'" STYLE="padding-top:2px;padding-bottom:2px;position:absolute;left:' + proto.menuItemIndent + ';top:0;color:'+ proto.fontColor +'">'+ item +'</DIV>\n<DIV ID="menuItemHilite'+ countItems +'" STYLE="padding-top:2px;padding-bottom:2px;position:absolute;left:' + proto.menuItemIndent + ';top:0;color:'+ proto.fontColorHilite +';visibility:hidden;">'+ item +'</DIV>';
            if (item == "separator") {
                content += ( dTag + '<DIV ID="menuSeparator'+ countItems +'" STYLE="position:absolute;left:1;top:2"></DIV>\n<DIV ID="menuSeparatorLite'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n</DIV>');
            } else if (childMenu) {
                content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" STYLE="position:absolute;left:0;top:3;'+ itemProps +'"><IMG SRC="'+ proto.childMenuIcon +'"></DIV>\n</DIV>');
            } else {
                content += ( dTag + dText + '</DIV>');
            }
            countItems++;
        }
        content += '      <DIV ID="focusItem'+ countMenus +'" STYLE="position:absolute;left:0;top:0;visibility:hide;" onClick="onMenuItemAction(null,this);">&nbsp;</DIV>\n';
        content += '   </DIV>\n  </DIV>\n</DIV>\n';//</td></tr></table></DIV>\n';
		i=x;

    }

    if (!container) return;
    if (container.innerHTML || container.firstChild) {//
        container.innerHTML=content;

    } else {

        container.document.open("text/html");
        container.document.writeln(content);
        container.document.close();
    }

    proto = null;
	if (is.ie4up || is.nav6up) {
        var menuCount = 0;

        for (var x=0; x<container.menus.length; x++) {
            var menu = objLookup("menuLayer" + x);
            container.menus[x].menuLayer = menu;
            container.menus[x].menuLayer.Menu = container.menus[x];
            container.menus[x].menuLayer.Menu.container = menu;
            proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];
            proto.menuItemWidth = proto.menuItemWidth || 200;
            menu.style.backgroundColor = proto.menuBorderBgColor;
            if ((proto.menuContainerDropShadow) && (!is.ie5_5up)){
				menu.style.borderRight = "#cccccc solid 2px";
				menu.style.borderBottom = "#cccccc solid 2px";
            }
            for (var i=0; i<container.menus[x].items.length; i++) {
                var l = objLookup("menuItem" + menuCount);
                l.Menu = container.menus[x];
                proto = container.menus[x].prototypeStyles || this.prototypeStyles || container.menus[x];
                l.style.width = proto.menuItemWidth;
                l.style.height = container.menus[x].height[i];
                if (i>0) l.style.top = parseInt(objLookup("menuItem" + (menuCount -1)).style.top) + parseInt(objLookup("menuItem" + (menuCount -1)).style.height) + proto.menuItemBorder;
                l.style.fontSize = proto.fontSize;
                l.style.backgroundColor = proto.menuItemBgColor;
                l.style.visibility = "inherit";
                l.saveColor = proto.menuItemBgColor;
                l.menuHiliteBgColor = proto.menuHiliteBgColor;
                l.action = container.menus[x].actions[i];
                l.hilite = objLookup("menuItemHilite" + menuCount);
                l.focusItem = objLookup("focusItem" + x);
                l.focusItem.style.top = -30;

                if (l.Menu.mouseovers[x]) l.mouseover = l.Menu.mouseovers[x];
                if (l.Menu.mouseouts[x]) l.mouseout  = l.Menu.mouseouts[x];
                var childItem = objLookup("childMenu" + menuCount);
                if (childItem) {
                    l.childMenu = container.menus[x].items[i].menuLayer;
                    childItem.style.left = (parseInt(l.style.width) -11) ;
                    childItem.style.top = ((parseInt(l.style.height)/2) -4);
                    childItem.style.width = (30 || 7);
                    childItem.style.clip = "rect(0 7 7 3)";
                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
                }
                var sep = objLookup("menuSeparator" + menuCount);
                if (sep) {
                    sep.style.clip = "rect(0 " + (proto.menuItemWidth - 3) + " 1 0)";
                    sep.style.backgroundColor = proto.bgColor;
                    sep = objLookup("menuSeparatorLite" + menuCount);
                    sep.style.clip = "rect(1 " + (proto.menuItemWidth - 3) + " 2 0)";
                    sep.style.backgroundColor = proto.menuLiteBgColor;
                    l.style.height = (proto.menuItemHeight/2);
                    l.isSeparator = true
                }
                menuCount++;
            }
            proto.menuHeight = (parseInt(l.style.top) + parseInt(l.style.height));
            var lite = objLookup("menuLite" + x);
            lite.style.height = (proto.menuHeight +2);
            lite.style.width = (proto.menuItemWidth + 2);
            lite.style.backgroundColor = proto.menuLiteBgColor;
            var body = objLookup("menuFg" + x);
            body.style.height = (proto.menuHeight + 1);
            body.style.width = (proto.menuItemWidth + 1);
            body.style.backgroundColor = proto.bgColor;
            container.menus[x].menuLayer.style.width  = proto.menuWidth || proto.menuItemWidth + (proto.menuBorder * 2) +2;
            container.menus[x].menuLayer.style.height = proto.menuHeight + (proto.menuBorder * 2) +2;        
        
			if (proto.menuContainerDropShadow){
				container.menus[x].menuLayer.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#777777,direction=135,strength=4)"
				//container.menus[x].menuLayer.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=90, FinishOpacity=90, Style=3, StartX=100, FinishX=70, StartY=100, FinishY=70)"
															 
            }
            if (menu.Menu.enableTracker) {
                menu.Menu.disableHide = true;
                setMenuTracker(menu.Menu);
            }
        }
        objLookup("menuContainer").style.backgroundColor = container.menus[0].menuContainerBgColor;
        container.saveBgColor = container.style.backgroundColor;

    } else if (container.document.layers) {
        container.clip.width = window.innerWidth;
        container.clip.height = window.innerHeight;
        container.onmouseout = this.hideMenu;
        container.menuContainerBgColor = this.menuContainerBgColor;
        for (var i=0; i<container.document.layers.length; i++) {
            proto = container.menus[i].prototypeStyles || this.prototypeStyles || container.menus[i];
            var menu = container.document.layers[i];
            container.menus[i].menuLayer = menu;
            container.menus[i].menuLayer.Menu = container.menus[i];
            container.menus[i].menuLayer.Menu.container = container;
            var body = menu.document.layers[0].document.layers[0];
            body.clip.width = proto.menuWidth || body.clip.width;
            body.clip.height =	 proto.menuHeight || body.clip.height;
            for (var n=0; n<body.document.layers.length-1; n++) {
                var l = body.document.layers[n];
                l.Menu = container.menus[i];
                l.menuHiliteBgColor = proto.menuHiliteBgColor;
                l.document.bgColor = proto.menuItemBgColor;
                l.saveColor = proto.menuItemBgColor;
                l.mouseout  = l.Menu.mouseouts[n];
                l.mouseover = l.Menu.mouseovers[n];
                l.onmouseover = proto.onMenuItemOver;
                l.onclick = proto.onMenuItemAction;
				//l.OpenWindow = container.menus[i].OpenWindows[n];
                l.action = container.menus[i].actions[n];
                l.focusItem = body.document.layers[body.document.layers.length-1];
                l.clip.width = proto.menuItemWidth || body.clip.width + proto.menuItemIndent;
                l.clip.height = container.menus[i].height[n]; //proto.menuItemHeight || l.clip.height;
                if (n>0) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder;
                l.hilite = l.document.layers[1];
                l.document.layers[1].isHilite = true;
                if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {
                    l.hilite = null;
                    l.clip.height -= l.clip.height / 2;
                    l.document.layers[0].document.bgColor = proto.bgColor;
                    l.document.layers[0].clip.width = l.clip.width -2;
                    l.document.layers[0].clip.height = 1;
                    l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
                    l.document.layers[1].clip.width = l.clip.width -2;
                    l.document.layers[1].clip.height = 1;
                    l.document.layers[1].top = l.document.layers[0].top + 1;
                } else if (l.document.layers.length > 2) {
                    l.childMenu = container.menus[i].items[n].menuLayer;
                    l.icon = proto.childMenuIcon;
                    l.iconHilite = proto.childMenuIconHilite;
                    l.document.layers[2].left = l.clip.width -13;
                    l.document.layers[2].top = (l.clip.height / 2) -4;
                    l.document.layers[2].clip.left += 3;
                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
                }
            }
            body.document.bgColor = proto.bgColor;
            body.clip.width  = l.clip.width +1;
            body.clip.height = l.top + l.clip.height +1;
            body.document.layers[n].clip.width = body.clip.width;
            body.document.layers[n].captureEvents(Event.MOUSEDOWN);
            body.document.layers[n].onmousedown = proto.onMenuItemDown;
            body.document.layers[n].onmouseout = proto.onMenuItemOut;
            body.document.layers[n].Menu = l.Menu;
            body.document.layers[n].top = -30;
            menu.document.bgColor = proto.menuBorderBgColor;
            menu.document.layers[0].document.bgColor = proto.menuLiteBgColor;
            menu.document.layers[0].clip.width = body.clip.width +1;
            menu.document.layers[0].clip.height = body.clip.height +1;
            menu.clip.width = body.clip.width + (proto.menuBorder) +1;
            menu.clip.height = body.clip.height + (proto.menuBorder) +1;
            if (menu.Menu.enableTracker) {
                menu.Menu.disableHide = true;
                setMenuTracker(menu.Menu);
            }
        }
    } 
    window.wroteMenu = true;
}

function onMenuItemOver(e, l, a) {

    l = l || this;
    a = a || window.ActiveMenuItem;
    if (document.layers) {
        if (a) {
            a.document.bgColor = a.saveColor;
            if (a.hilite) a.hilite.visibility = "hidden";
            if (a.childMenu) a.document.layers[1].document.images[0].src = a.icon;
        } else {
            a = new Object();
        }
        if (this.mouseover && this.id != a.id) {
            if (this.mouseover.length > 4) {
                var ext = this.mouseover.substring(this.mouseover.length-4);
                if (ext == ".gif" || ext == ".jpg") {
                    this.document.layers[1].document.images[0].src = this.mouseover;
                } else {
                    eval("" + this.mouseover);
                }
            }
        }
        if (l.hilite) {
            l.document.bgColor = l.menuHiliteBgColor;
            l.zIndex = 1;
            l.hilite.visibility = "inherit";
            l.hilite.zIndex = 2;
            l.document.layers[1].zIndex = 1;
            l.focusItem.zIndex = this.zIndex +2;
        }
        l.focusItem.top = this.top;
        l.Menu.hideChildMenu(l);
    } else if (l.style) {
        document.onmousedown=l.Menu.onMenuItemDown;
        if (a) {
            a.style.backgroundColor = a.saveColor;
            if (a.hilite) a.hilite.style.visibility = "hidden";
        } else {
            a = new Object();
		}
        if (l.mouseover && l.id != a.id) {
            if (l.mouseover.length > 4) {
                var ext = l.mouseover.substring(l.mouseover.length-4);
                if (ext == ".gif" || ext == ".jpg") {
                    l.document.images[l.id + "Img"].src = l.mouseover;
                } else {
                    eval("" + l.mouseover);
                }
            }
        }
		if (l.isSeparator) return;
        l.style.backgroundColor = l.menuHiliteBgColor;
        if (l.hilite) {
            l.style.backgroundColor = l.menuHiliteBgColor;
            l.hilite.style.visibility = "inherit";
        }
        l.focusItem.style.top = parseInt(l.style.top);
        l.focusItem.style.zIndex = l.style.zIndex +1;
        l.style.zIndex = 1;
        l.Menu.hideChildMenu(l);
    }
    window.ActiveMenuItem = l;
}

function onMenuItemOut(e, l, a) {
    l = l || this;
	a = a || window.ActiveMenuItem;
    if (l.id.indexOf("focusItem")) {
        if (a && l.top) {
            l.top = -30;
			if (a.mouseout && a.id != l.id) {
				if (a.mouseout.length > 4) {
					var ext = a.mouseout.substring(a.mouseout.length-4);
					if (ext == ".gif" || ext == ".jpg") {
						a.document.layers[1].document.images[0].src = a.mouseout;
					} else {
						eval("" + a.mouseout);
					}
				}
			}
        } else if (a && l.style) {
			if (is.ie4up) e = window.event;
			
            document.onmousedown=null;
            e.cancelBubble=true;
	        if (l.mouseout) {
				if (l.mouseout.length > 4) {
					var ext = l.mouseout.substring(l.mouseout.length-4);
					if (ext == ".gif" || ext == ".jpg") {
						l.document.images[l.id + "Img"].src = l.mouseout;
					} else {
						eval("" + l.mouseout);
					}
				}
			}
        }
    }
}

function onMenuItemAction(e, l) {
    l = window.ActiveMenuItem;
    if (!l) return;
    if (!ActiveMenu.Menu.disableHide) hideActiveMenus(ActiveMenu.menuLayer);
    if (l.action) {
        eval("" + l.action);
    }
}
var IsMenu = false;
var gstrImageName = "";
var gstrImageOff = "";

function showMenu(menu, x, y, child, strImageName, strImageOn, strImageOff) {
    if (!window.wroteMenu) return;
    if (is.nav4) {
        if (menu) {
            var l = menu.menuLayer || menu;
            if (typeof(menu) == "string") {
                for (var n=0; n < menuContainers.length; n++) {
                    l = menuContainers[n].menus[menu];
                    for (var i=0; i<menuContainers[n].menus.length; i++) {
                        if (menu == menuContainers[n].menus[i].label) l = menuContainers[n].menus[i].menuLayer;
                        if (l) break;
                    }
                }
				if (!l) return;
            }
            l.Menu.container.document.bgColor = null;
            l.left = 1;
            l.top = 1;
            hideActiveMenus(l);
            if (this.visibility) l = this;
            window.ActiveMenu = l;
			gstrImageName = strImageName;
			gstrImageOff = strImageOff;
			ImageSwap(gstrImageName,strImageOn);            
            //window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
            setTimeout('if(window.ActiveMenu)window.ActiveMenu.Menu.setMouseTracker();', 300);
        } else {
            var l = child;
        }
        if (!l) return;
        for (var i=0; i<l.layers.length; i++) {                
            if (!l.layers[i].isHilite) 
                l.layers[i].visibility = "inherit";
            if (l.layers[i].document.layers.length > 0) 
                showMenu(null, "relative", "relative", l.layers[i]);
        }
        if (l.parentLayer) {
            if (x != "relative") 
                l.parentLayer.left = x || window.pageX || 0;
            if (l.parentLayer.left + l.clip.width > window.innerWidth) 
                l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
            if (y != "relative") 
                l.parentLayer.top = y || window.pageY || 0;
            if (l.parentLayer.isContainer) {
                l.Menu.xOffset = window.pageXOffset;
                l.Menu.yOffset = window.pageYOffset;
                l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
                l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
                if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
            }
        }
        l.visibility = "inherit";
        if (l.Menu) l.Menu.container.visibility = "inherit";
    } else {
	
        var l = menu.menuLayer || menu;
        hideActiveMenus(l);
		gstrImageName = strImageName;
		gstrImageOff = strImageOff;
		ImageSwap(gstrImageName,strImageOn);
		
        if (typeof(menu) == "string") {
            l = document.all[menu];
            for (var n=0; n < menuContainers.length; n++) {
                l = menuContainers[n].menus[menu];
                for (var i=0; i<menuContainers[n].menus.length; i++) {
                    if (menu == menuContainers[n].menus[i].label) l = menuContainers[n].menus[i].menuLayer;
                    if (l) break;
                }
            }
        }
        window.ActiveMenu = l;
        l.style.visibility = "inherit";
        var windowLeft = (is.ie4up) ? document.body.scrollLeft : window.pageXOffset
        var windowTop = (is.ie4up) ? document.body.scrollTop : window.pageYOffset
        if (x != "relative") 
            l.style.left = x || (window.pageX + windowLeft) || 0;
        if (y != "relative") 
            l.style.top = y || (window.pageY + windowTop) || 0;
        l.Menu.xOffset = windowLeft;
        l.Menu.yOffset = windowTop;
    }
    if (menu) {
        window.activeMenus[window.activeMenus.length] = l;
    }
	IsMenu =true;
}

function hideMenu(e) {
    var l = e || window.ActiveMenu;
    if (!l) return true;
    if (l.menuLayer) {
        l = l.menuLayer;
    } else if (this.visibility) {
        l = this;
    }
    if (l.menuLayer) {
        l = l.menuLayer;
    }
    var a = window.ActiveMenuItem;
    document.saveMousemove = document.onmousemove;
    document.onmousemove = mouseTracker;
    if (a && is.nav4) {
        a.document.bgColor = a.saveColor;
        a.focusItem.top = -30;
        if (a.hilite) a.hilite.visibility = "hidden";
        if (a.childMenu) a.document.layers[1].document.images[0].src = a.icon;
        if (mDrag.oldX <= e.pageX+3 && mDrag.oldX >= e.pageX-3 && mDrag.oldY <= e.pageY+3 && mDrag.oldY >= e.pageY-3) {
            if (a.action && window.ActiveMenu) setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 2);
        } else if (document.saveMousemove == mDrag.doMenuDrag) {
            if (window.ActiveMenu) return true;
        }
    } else if (window.ActiveMenu && (is.ie4up || is.nav6up)) {
        document.onmousedown=null;
        if (a) {
            a.style.backgroundColor = a.saveColor;
            if (a.hilite) a.hilite.style.visibility = "hidden";
        }
        if (document.saveMousemove == mDrag.doMenuDrag) {
           return true;
        }
	}
    if (window.ActiveMenu) {
		if (is.ie4up || is.nav6up){
	        if (window.ActiveMenu.Menu) {
		        if (window.ActiveMenu.Menu.disableHide) return true;
			    e = window.event || e;
				if (!window.ActiveMenu.Menu.enableHideOnMouseOut && e.type == "mouseout") return true;
			}
       }
    }
    hideActiveMenus(l);
    IsMenu = false;
    return true;
}

function hideChildMenu(menuLayer) {
    var l = menuLayer || this;
    for (var i=0; i < l.Menu.childMenus.length; i++) {
        if (is.nav4) {
            l.Menu.childMenus[i].visibility = "hidden";
        } else if (is.ie4up || is.nav6up) {
            l.Menu.childMenus[i].style.visibility = "hidden";
        }
        l.Menu.childMenus[i].Menu.hideChildMenu(l.Menu.childMenus[i]);
    }
    if (l.childMenu) {
        if (is.nav4) {
            l.Menu.container.document.bgColor = null;
            l.Menu.showMenu(null,null,null,l.childMenu.layers[0]);
            l.childMenu.zIndex = l.parentLayer.zIndex +1;
            l.childMenu.top = l.top + l.parentLayer.top + l.Menu.menuLayer.top;
            if (l.childMenu.left + l.childMenu.clip.width > window.innerWidth) {
                l.childMenu.left = l.parentLayer.left - l.childMenu.clip.width + l.Menu.menuLayer.top + 15;
                l.Menu.container.clip.left -= l.childMenu.clip.width;
            } else if (l.Menu.childMenuDirection == "left") {
                l.childMenu.left = l.parentLayer.left - l.parentLayer.clip.width;
                l.Menu.container.clip.left -= l.childMenu.clip.width;
            } else {
                l.childMenu.left = l.parentLayer.left + l.parentLayer.clip.width  + l.Menu.menuLayer.left -5;
            }
            l.Menu.container.clip.width += l.childMenu.clip.width +100;
            l.Menu.container.clip.height += l.childMenu.clip.height;
            l.document.layers[1].zIndex = 0;
            l.document.layers[1].document.images[0].src = l.iconHilite;
            l.childMenu.visibility = "inherit";
        } else if (is.ie4up || is.nav6up) {
            l.childMenu.style.zIndex = l.Menu.menuLayer.style.zIndex +1;
            l.childMenu.style.top = parseInt(l.style.top) + parseInt(l.Menu.menuLayer.style.top);
            if (parseInt(l.childMenu.style.left) + parseInt(l.childMenu.style.width) > document.width) {
                l.childMenu.style.left = parseInt(l.childMenu.style.width) + parseInt(l.Menu.menuLayer.style.top) + 15;
            } else if (l.Menu.childMenuDirection == "left") {
                l.childMenu.style.left = parseInt(l.parentLayer.left) - parseInt(l.parentLayer.clip.width);
            } else {
                l.childMenu.style.left = parseInt(l.Menu.menuLayer.style.width) + parseInt(l.Menu.menuLayer.style.left) -5;
            }
            l.childMenu.style.visibility = "inherit";
        }
        if (!l.childMenu.disableHide) 
            window.activeMenus[window.activeMenus.length] = l.childMenu;
    }
}

function hideActiveMenus(l) {
	if (IsMenu){	
		ImageSwap(gstrImageName,gstrImageOff)    
    }
   IsMenu = false;
    if (!window.activeMenus) return;
    for (var i=0; i < window.activeMenus.length; i++) {
    if (!activeMenus[i]) return;
        if (activeMenus[i].visibility && activeMenus[i].Menu) {
            activeMenus[i].visibility = "hidden";
            activeMenus[i].Menu.container.visibility = "hidden";
            activeMenus[i].Menu.container.clip.left = 0;
        } else if (activeMenus[i].style) {
            activeMenus[i].style.visibility = "hidden";
        }
    }
    document.onmousemove = mouseTracker;
    window.activeMenus.length = 0;
}

function mouseTracker(e) {
    e = e || window.Event || window.event;
    window.pageX = e.pageX || e.clientX;
    window.pageY = e.pageY || e.clientY;
}

function setMouseTracker() {
    if (document.captureEvents) {
        document.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
    }
    document.onmousemove = this.mouseTracker;
    document.onmouseup = this.hideMenu;
}

function setMenuTracker(menu) {
    if (!window.menuTrackers) window.menuTrackers = new Array();
    menuTrackers[menuTrackers.length] = menu;
    window.menuTrackerID = setInterval('menuTracker()',10);
}

function menuTracker() {
    for (var i=0; i < menuTrackers.length; i++) {
        if (!isNaN(menuTrackers[i].xOffset) && is.nav4) {
            var off = parseInt((menuTrackers[i].xOffset - window.pageXOffset) / 10);
            if (isNaN(off)) off = 0;
            if (off < 0) {
                menuTrackers[i].container.left += -off;
                menuTrackers[i].xOffset += -off;
            } else if (off > 0) {
                menuTrackers[i].container.left += -off;
                menuTrackers[i].xOffset += -off;
            }
        }
        if (!isNaN(menuTrackers[i].yOffset) && is.nav4) {
            var off = parseInt((menuTrackers[i].yOffset - window.pageYOffset) / 10);
            if (isNaN(off)) off = 0;
            if (off < 0) {
                menuTrackers[i].container.top += -off;
                menuTrackers[i].yOffset += -off;
            } else if (off > 0) {
                menuTrackers[i].container.top += -off;
                menuTrackers[i].yOffset += -off;
            }
        }
        if (!isNaN(menuTrackers[i].xOffset) && (is.ie4up || is.nav6up)) {
		    var windowLeft = (is.ie4up) ? document.body.scrollLeft : window.pageXOffset
            var off = parseInt((menuTrackers[i].xOffset - windowLeft) / 10);
            if (isNaN(off)) off = 0;
            if (off < 0) {
                menuTrackers[i].menuLayer.style.left += -off;
                menuTrackers[i].xOffset += -off;
            } else if (off > 0) {
                menuTrackers[i].menuLayer.style.left += -off;
                menuTrackers[i].xOffset += -off;
            }
        }
        if (!isNaN(menuTrackers[i].yOffset) && (is.ie4up || is.nav6up)) {
	        var windowTop = (is.ie4up) ? document.body.scrollTop : window.pageYOffset
            var off = parseInt((menuTrackers[i].yOffset - windowTop) / 10);
            if (isNaN(off)) off = 0;
            if (off < 0) {
                menuTrackers[i].menuLayer.style.top += -off;
                menuTrackers[i].yOffset += -off;
            } else if (off > 0) {
                menuTrackers[i].menuLayer.style.top += -off;
                menuTrackers[i].yOffset += -off;
            }
        }
    }
}

function onMenuItemDown(e, l) {
    l = l || window.ActiveMenuItem || this;
    if (!l.Menu) {
    } else {
        if (is.nav4) {
            mDrag.dragLayer = l.Menu.container;
            mDrag.startMenuDrag(e);
        } else {
			if (is.ie4up) e = window.event;
            mDrag.dragLayer = l.Menu.container.style;
            mDrag.startMenuDrag(e);
            e.cancelBubble=true;
        }
    }
}

function startMenuDrag(e) {
    if (is.nav4) {
        if (e.which > 1) {
            if (window.ActiveMenu) ActiveMenu.Menu.container.visibility = "hidden";
            window.ActiveMenu = null;
            return true;
        }
        document.captureEvents(Event.MOUSEMOVE);
        var x = e.pageX;
        var y = e.pageY;
    } else {
        var x = e.clientX;
        var y = e.clientY;
    }
    mDrag.offX = x;
    mDrag.offY = y;
    mDrag.oldX = x;
    mDrag.oldY = y;
    if (!ActiveMenu.Menu.disableDrag) document.onmousemove = mDrag.doMenuDrag;
    return false;
}

function doMenuDrag(e) {
    if (is.nav4) {
        mDrag.dragLayer.moveBy(e.pageX-mDrag.offX,e.pageY-mDrag.offY);
        mDrag.offX = e.pageX;
        mDrag.offY = e.pageY;
    } else {
		if (is.ie4up) e = window.event;
        mDrag.dragLayer.left = parseInt(e.offsetX);
        mDrag.dragLayer.top  = parseInt(e.offsetY);
        return false; //for IE or NS6
    }
}

function hideIEMenu(){
	if (is.ie4up ||  is.nav6up){
		hideMenu();
	}
}
function ImageSwap(SwapName,SwapImage){
		eval("document." +SwapName+ ".src = '"+SwapImage+"'");
}

function emailLinkControl(strURL, strName){

	window.open("/content/email/emaillink.asp?url="+strURL+"||name="+strName,"EmailLink","scrollbars=no,status=no,toolbar=no,resizable=no,menubar=no,height=500,width=500");
}

function printPage(){
	window.onerror = null;
	var  isNS = 0;
	var  isIE = 0;
	var brow = navigator.appName;
	
	if (brow == "Netscape" && parseInt(navigator.appVersion) >= 5){
	   isNS = 5;
	   }
	if (brow == "Netscape" && parseInt(navigator.appVersion) == 4){
	   isNS = 4;
	   }
	if (brow == "Netscape" && parseInt(navigator.appVersion) < 4){
	   isNS = 3;
	   }

	if (brow == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 7") != -1){
	   isIE = 7;
	   }

	if (brow == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6") != -1){
	   isIE = 6;
	   }

	if (brow == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 5") != -1){
	   isIE = 5;
	   }
	if (brow == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 4") != -1){
	   isIE = 4;
	}

	var printThis;
	if (isIE >4) {
		window.focus();	
	}
			

	if (isNS >=4 || ( isIE >=5 && navigator.platform.indexOf('Mac') == -1)){
				
	   	alert("This page has loaded in a printer-ready format, and will now try to print on your printer.   \n\n After you have finished printing, click on the 'Back to referring page' link above to return to the normal view of the AGL web site.")
		window.print()
			     
	}else{
			
		printThis = "To print this document, "
		if (isNS>=4){
				
			if (navigator.platform.indexOf('Mac')== -1){
				 printThis += "press 'Control+P'"
			 }
			else {
				 printThis += "press 'Command+P'"
			}
		}
		else {
				 printThis += "press 'Control+P'"
		}
		printThis += ".   \n\n  Once you have printed this page, click the 'Back to referring page' link above  to return to the normal view of the AGL web site."
		alert(printThis);
    }
}

function openWindow(url) {
	var newwin = window.open(url,"popupbox","scrollbars=yes,resizable=yes,width=680,height=500");
	newwin.focus();
	return false;
}