/*
 * 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.
 */
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_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));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
 	var nadd = 0;
	
	if (is_nav) nadd=14;
		
	var lOffset = 0;

var myWidth = 0, myHeight = 0;
 if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
if (typeof(myWidth) == "number") 
	{
	lOffset=Math.max(0,myWidth/2-395);
	}
if (myWidth == 0) lOffset=screen.width/2 - 395;

function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh)
{
    this.version = "990702 [Menu; menu.js]";
    this.type = "Menu";
    this.menuWidth = mw;
    this.menuItemHeight = mh;
    this.fontSize = fs||12;
    this.fontWeight = "plain";
    this.fontFamily = fnt||"arial,helvetica,verdana,sans-serif";
    this.fontColor = fclr||"#000000";
    this.fontColorHilite = fhclr||"#ffffff";
    this.bgColor = "#555555";
    this.menuBorder = 0;
    this.menuItemBorder = 0;
    this.menuItemBgColor = bg||"#cccccc";
    this.menuLiteBgColor = "#ffffff";
    this.menuBorderBgColor = "#777777";
    this.menuHiliteBgColor = bgh||"#000084";
    this.menuContainerBgColor = "#cccccc";
    this.childMenuIcon = "arrows.gif";
    this.items = new Array();
    this.actions = new Array();
    this.itemavailable = new Array();
    this.childMenus = new Array();

    this.hideOnMouseOut = true;

    this.addMenuItem = addMenuItem;
    this.addMenuSeparator = addMenuSeparator;
    this.writeMenus = writeMenus;
    this.FW_showMenu = FW_showMenu;
    this.onMenuItemOver = onMenuItemOver;
    this.onMenuItemAction = onMenuItemAction;
    this.hideMenu = hideMenu;
    this.hideChildMenu = hideChildMenu;

    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();
}

function addMenuItem(label, action, available)
{   this.items[this.items.length] = label;
    this.actions[this.actions.length] = action;
    this.itemavailable[this.itemavailable.length] = available;
}

function addMenuSeparator()
{
    this.items[this.items.length] = "separator";
    this.actions[this.actions.length] = "";
    this.itemavailable[this.itemavailable.length] = "N";
    this.menuItemBorder = 0;
}

// For NS6.
function FIND(item)
{
    if (document.all) return(document.all[item]);
    if (document.getElementById) return(document.getElementById(item));
    return(false);
}

function writeMenus(container)
{
    if (window.triedToWriteMenus) return;

    if (!container && document.layers)
    {
        window.delayWriteMenus = this.writeMenus;
        var timer = setTimeout('delayWriteMenus()', 250);
        container = new Layer(100);
        clearTimeout(timer);
    }
    else
        if (document.all || document.hasChildNodes)
        {
            document.writeln('<SPAN ID="menuContainer"></SPAN>');
            container = FIND("menuContainer");
        }

    window.fwHideMenuTimer = null;
    if (!container) return;
    window.triedToWriteMenus = true;
    container.isContainer = true;
    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 lrs = false;
    var theStat = "";
    var tsc = 0;
    if (document.layers) lrs = true;
    for (var i=0; i<container.menus.length; i++, countMenus++)
    {
        var menu = container.menus[i];
        if (menu.bgImageUp)
        {
            menu.menuBorder = 0;
            menu.menuItemBorder = 0;
        }
        if (lrs)
        {
            var menuLayer = new Layer(100, container);
            var lite = new Layer(100, menuLayer);
            lite.top = menu.menuBorder;
            lite.left = menu.menuBorder;
            var body = new Layer(100, lite);
            body.top = menu.menuBorder;
            body.left = menu.menuBorder;
        }
        else
        {
            content += ''+
            '<DIV ID="menuLayer'+ countMenus +'" STYLE="position:absolute;z-index:1;left:10;top:'+ (i * 100) +';visibility:hidden;">\n'+
            '  <DIV ID="menuLite'+ countMenus +'" STYLE="position:absolute;z-index:1;left:'+ menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;" onMouseOut="mouseoutMenu();">\n'+
            '    <DIV ID="menuFg'+ countMenus +'" STYLE="position:absolute;left:'+ menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;">\n'+
            '';
        }
        var x=i;
        for (var i=0; i<menu.items.length; i++)
        {
            var item = menu.items[i];
            var childMenu = false;
            var defaultHeight = menu.fontSize+6;
            var defaultIndent = menu.fontSize;
            if (item.label)
            {
                item = item.label;
                childMenu = true;
            }
            menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
            menu.menuItemIndent = menu.menuItemIndent || defaultIndent;
            var itemProps = 'font-family:' + menu.fontFamily +';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
            if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
            if (document.all)
                itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
            else if (!document.layers)
            {
                itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
            }
            var l;
            if (lrs)
            {
                l = new Layer(800,body);
            }
            var dTag    = '<DIV ID="menuItem'+ countItems +'" STYLE="position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
            var dClose = '</DIV>'
            if (menu.bgImageUp)
            {
                menu.menuBorder = 0;
                menu.menuItemBorder = 0;
                dTag    = '<DIV ID="menuItem'+ countItems +'" STYLE="background:url('+menu.bgImageUp+');position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
                if (document.layers)
                {
                    dTag = '<LAYER BACKGROUND="'+menu.bgImageUp+'" ID="menuItem'+ countItems +'" TOP="'+ (i * menu.menuItemHeight) +'" style="' + itemProps +'">';
                    dClose = '</LAYER>';
                }
            }
            var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:1;';
            if (lrs)
            {
                textProps +=itemProps;
                dTag = "";
                dClose = "";
            }

            var dText   = '<DIV ID="menuItemText'+ countItems +'" STYLE="' + textProps + 'color:'+ menu.fontColor +';">'+ item +'&nbsp</DIV>\n<DIV ID="menuItemHilite'+ countItems +'" STYLE="' + textProps + 'top:1;color:'+ menu.fontColorHilite +';visibility:hidden;">'+ item +'&nbsp</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' + dClose);
            }
            else
                if (childMenu)
                {
                    content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" STYLE="position:absolute;left:0;top:3;"><IMG SRC="'+ menu.childMenuIcon +'"></DIV>\n' + dClose);
                }
                else
                {
                    content += ( dTag + dText + dClose);
                }
            if (lrs)
            {
                l.document.open("text/html");
                l.document.writeln(content);
                l.document.close();
                content = '';
                theStat += "-";
                tsc++;
                if (tsc > 50) {
                    tsc = 0;
                    theStat = "";
                }
                status = theStat;
            }
            countItems++;
        }
        if (lrs)
        {
            // focus layer
            var focusItem = new Layer(100, body);
            focusItem.visiblity="hidden";
            focusItem.document.open("text/html");
            focusItem.document.writeln("&nbsp;");
            focusItem.document.close();
        }
        else
        {
          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';
        }
        i=x;
    }
    if (document.layers)
    {
        container.clip.width = window.innerWidth;
        container.clip.height = window.innerHeight;
        container.onmouseout = mouseoutMenu;
        container.menuContainerBgColor = this.menuContainerBgColor;
        for (var i=0; i<container.document.layers.length; i++)
        {
            proto = 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.onmouseover = proto.onMenuItemOver;
                l.onclick = proto.onMenuItemAction;
                l.action = container.menus[i].actions[n];
                l.itemavailable = container.menus[i].itemavailable[n];
                //alert("i=" + i + "available" + container.menus[i].itemavailable[n] + "action" + container.menus[i].actions[n]);
                l.focusItem = body.document.layers[body.document.layers.length-1];
                l.clip.width = proto.menuWidth || body.clip.width + proto.menuItemIndent;
                l.clip.height = 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];
                if (proto.bgImageUp) l.background.src = proto.bgImageUp;
                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.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 +proto.menuBorder;
            body.clip.height = l.top + l.clip.height +proto.menuBorder;
            var focusItem = body.document.layers[n];
            focusItem.clip.width = body.clip.width;
            focusItem.Menu = l.Menu;
            focusItem.top = -30;
            focusItem.captureEvents(Event.MOUSEDOWN);
            focusItem.onmousedown = onMenuItemDown;
            menu.document.bgColor = proto.menuBorderBgColor;
            var lite = menu.document.layers[0];
            lite.document.bgColor = proto.menuLiteBgColor;
            lite.clip.width = body.clip.width +1;
            lite.clip.height = body.clip.height +1;
            menu.clip.width = body.clip.width + (proto.menuBorder * 3) ;
            menu.clip.height = body.clip.height + (proto.menuBorder * 3);
        }
    }
    else
    {
        if ((!document.all) && (container.hasChildNodes))
        {
            container.innerHTML=content;
        }
        else
        {
            container.document.open("text/html");
            container.document.writeln(content);
            container.document.close();
        }
        if (!FIND("menuLayer0")) return;
        var menuCount = 0;
        for (var x=0; x<container.menus.length; x++)
        {
            var menuLayer = FIND("menuLayer" + x);
            container.menus[x].menuLayer = "menuLayer" + x;
            menuLayer.Menu = container.menus[x];
            menuLayer.Menu.container = "menuLayer" + x;
            menuLayer.style.zIndex = 1;
            var s = menuLayer.style;
            s.top = s.pixelTop = -300;
            s.left = s.pixelLeft = -300;

            var menu = container.menus[x];
            menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
            menuLayer.style.backgroundColor = menu.menuBorderBgColor;
            var top = 0;
            for (var i=0; i<container.menus[x].items.length; i++)
            {
                var l = FIND("menuItem" + menuCount);
                l.Menu = container.menus[x];
                if (l.addEventListener)
                { // ns6
                    l.style.width = menu.menuItemWidth;
                    l.style.height = menu.menuItemHeight;
                    l.style.top = top;
                    l.addEventListener("mouseover", onMenuItemOver, false);
                    l.addEventListener("click", onMenuItemAction, false);
                    l.addEventListener("mouseout", mouseoutMenu, false);
                }
                else
                { //ie
                    l.style.pixelWidth = menu.menuItemWidth;
                    l.style.pixelHeight = menu.menuItemHeight;
                    l.style.pixelTop = top;
                }
                top = top + menu.menuItemHeight+menu.menuItemBorder;
                l.style.fontSize = menu.fontSize;
                l.style.backgroundColor = menu.menuItemBgColor;
                l.style.visibility = "inherit";
                l.saveColor = menu.menuItemBgColor;
                l.menuHiliteBgColor = menu.menuHiliteBgColor;
                l.action = container.menus[x].actions[i];
                l.itemavailable = container.menus[x].itemavailable[i];
                l.hilite = FIND("menuItemHilite" + menuCount);
                l.focusItem = FIND("focusItem" + x);
                l.focusItem.style.pixelTop = l.focusItem.style.top = -30;
                var childItem = FIND("childMenu" + menuCount);
                if (childItem)
                {
                    l.childMenu = container.menus[x].items[i].menuLayer;
                    childItem.style.pixelLeft = childItem.style.left = menu.menuItemWidth -15;  //for images arrows.gif's position
                    childItem.style.pixelTop = childItem.style.top =(menu.menuItemHeight /2) - 4 ;
                    //childItem.style.pixelWidth = 30 || 7;
                    //childItem.style.clip = "rect(0 7 7 3)";
                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
                }
                var sep = FIND("menuSeparator" + menuCount);
                if (sep)
                {
                    sep.style.clip = "rect(0 " + (menu.menuItemWidth - 3) + " 1 0)";
                    sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;
                    sep.style.backgroundColor = menu.bgColor;
                    sep = FIND("menuSeparatorLite" + menuCount);
                    sep.style.clip = "rect(1 " + (menu.menuItemWidth - 3) + " 2 0)";
                    sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;
                    sep.style.backgroundColor = menu.menuLiteBgColor;
                    l.style.height = l.style.pixelHeight = menu.menuItemHeight/2;
                    l.isSeparator = true
                    top -= (menu.menuItemHeight - l.style.pixelHeight)
                }
                else
                {
                    l.style.cursor = "hand"
                }
                menuCount++;
            }
            menu.menuHeight = top-1;
            var lite = FIND("menuLite" + x);
            var s = lite.style;
            s.height = s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
            s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 2);
            s.backgroundColor = menu.menuLiteBgColor;

            var body = FIND("menuFg" + x);
            s = body.style;
            s.height = s.pixelHeight = menu.menuHeight + menu.menuBorder;
            s.width = s.pixelWidth = menu.menuItemWidth + menu.menuBorder;
            s.backgroundColor = menu.bgColor;

            s = menuLayer.style;
            s.width = s.pixelWidth  = menu.menuItemWidth + (menu.menuBorder * 4);
            s.height = s.pixelHeight  = menu.menuHeight+(menu.menuBorder*4);
        }
    }
    if (document.captureEvents)
    {
        document.captureEvents(Event.MOUSEUP);
    }
    if (document.addEventListener)
    {
        document.addEventListener("mouseup", onMenuItemOver, false);
    }
    if (document.layers && window.innerWidth)
    {
        window.onresize = NS4resize;
        window.NS4sIW = window.innerWidth;
        window.NS4sIH = window.innerHeight;
    }
    document.onmouseup = mouseupMenu;
    window.fwWroteMenu = true;
    status = "";
}

function NS4resize()
{
    if (NS4sIW < window.innerWidth ||
        NS4sIW > window.innerWidth ||
        NS4sIH > window.innerHeight ||
        NS4sIH < window.innerHeight )
    {
        window.location.reload();
    }
}

function onMenuItemOver(e, l)
{
    FW_clearTimeout();
    l = l || this;
    a = window.ActiveMenuItem;
    if (document.layers)
    {   //Net4.7
        if (a)
        {  if(a.itemavailable == "Y"){
            a.document.bgColor = a.saveColor;
            if (a.hilite) a.hilite.visibility = "hidden";
            if (a.Menu.bgImageOver)
            {
                a.background.src = a.Menu.bgImageUp;
            }
            a.focusItem.top = -100;
            a.clicked = false;
           }

        }
        if (l.hilite)
        {   // N4.7
            if(l.itemavailable == "Y") {
            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;
            }

        }
        if (l.Menu.bgImageOver)
        {
            l.background.src = l.Menu.bgImageOver;
        }

        if(l.itemavailable == "Y") {
        l.focusItem.top = this.top;
        }
        l.Menu.hideChildMenu(l);
    }
    else
        if (l.style && l.Menu)
        {  //IE5alert("l.style&&l.menu");
            if (a)
            {   if(a.itemavailable == "Y"){
                    a.style.backgroundColor = a.saveColor;
                    if (a.hilite) a.hilite.style.visibility = "hidden";
                    if (a.Menu.bgImageUp)
                    {
                        a.style.background = "url(" + a.Menu.bgImageUp +")";;
                    }
                }

            }
            if (l.isSeparator) return;
            l.style.backgroundColor = l.menuHiliteBgColor;
            l.zIndex = 1;  // magic IE 4.5 mac happy doohicky.  jba
            if (l.Menu.bgImageOver)
            {
                l.style.background = "url(" + l.Menu.bgImageOver +")";
            }
            if (l.hilite)
            {   if(l.itemavailable == "Y") {
                l.style.backgroundColor = l.menuHiliteBgColor;
                l.hilite.style.visibility = "inherit";
                }
            }
            if(l.itemavailable == "Y") {
            l.focusItem.style.top = l.focusItem.style.pixelTop = l.style.pixelTop;
            l.focusItem.style.zIndex = l.zIndex +1;
            }
            l.Menu.hideChildMenu(l);
        }
        else
        {   return; // not a menu - magic IE 4.5 mac happy doohicky.  jba
        }
//if(l.itemavailable == "Y") {
        window.ActiveMenuItem = l;
//    }
}

function onMenuItemAction(e, l)
{
    l = window.ActiveMenuItem;
    if (!l) return;
   // alert("itemavailable" + l.itemavailable + "available" + l.available);
    hideActiveMenus();
    if (l.action) {
        if (l.itemavailable == "Y" ){
        eval("" + l.action);
        }
    }
    window.ActiveMenuItem = 0;
}

function FW_clearTimeout()
{
    if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
    fwHideMenuTimer = null;
    fwDHFlag = false;
}
function FW_startTimeout()
{
    fwStart = new Date();
    fwDHFlag = true;
    fwHideMenuTimer = setTimeout("fwDoHide()", 150);
}

function fwDoHide()
{
    if (!fwDHFlag) return;
    var elapsed = new Date() - fwStart;
    if (elapsed < 150)
    {
        fwHideMenuTimer = setTimeout("fwDoHide()", 160-elapsed);
        return;
    }
    fwDHFlag = false;
    hideActiveMenus();
    window.ActiveMenuItem = 0;
}

function FW_showMenu(menu, x, y, child)
{
    if (!window.fwWroteMenu) return;
    FW_clearTimeout();
    if (document.layers)
    {
        if (menu)
        {
            var l = menu.menuLayer || menu;
            l.left = 1;
            l.top = 1;
            hideActiveMenus();
            if (this.visibility) l = this;
            window.ActiveMenu = l;
        }
        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)
                FW_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
        if (FIND("menuItem0"))
        {
            var l = menu.menuLayer || menu;
            hideActiveMenus();
            if (typeof(l) == "string")
            {
                l = FIND(l);
            }
            window.ActiveMenu = l;
            var s = l.style;
            s.visibility = "inherit";
            if (x != "relative")
                s.left = s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
            if (y != "relative")
                s.top = s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
            l.Menu.xOffset = document.body.scrollLeft;
            l.Menu.yOffset = document.body.scrollTop;
        }
        if (menu)
        {
            window.activeMenus[window.activeMenus.length] = l;
        }
}

function onMenuItemDown(e, l)
{
    var a = window.ActiveMenuItem;
    if (document.layers)
    {
        if (a)
        {
            a.eX = e.pageX;
            a.eY = e.pageY;
            a.clicked = true;
        }
    }
}

function mouseupMenu(e)
{
    hideMenu(true, e);
    hideActiveMenus();
    return true;
}

function mouseoutMenu()
{
    hideMenu(false, false);
    return true;
}


function hideMenu(mouseup, e)
{
    var a = window.ActiveMenuItem;
    if (a && document.layers)
    {
        a.document.bgColor = a.saveColor;
        a.focusItem.top = -30;
        if (a.hilite) a.hilite.visibility = "hidden";
        if (mouseup && a.action && a.clicked && window.ActiveMenu)
        {
            if (a.eX <= e.pageX+15 && a.eX >= e.pageX-15 && a.eY <= e.pageY+10 && a.eY >= e.pageY-10)
            {
                setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 2);
            }
        }
        a.clicked = false;
        if (a.Menu.bgImageOver)
        {
            a.background.src = a.Menu.bgImageUp;
        }
    }
    else
        if (window.ActiveMenu && FIND("menuItem0"))
        {
            if (a)
            {
                a.style.backgroundColor = a.saveColor;
                if (a.hilite) a.hilite.style.visibility = "hidden";
                if (a.Menu.bgImageUp)
                {
                    a.style.background = "url(" + a.Menu.bgImageUp +")";;
                }
            }
        }
        if (!mouseup && window.ActiveMenu)
        {
            if (window.ActiveMenu.Menu)
            {
                if (window.ActiveMenu.Menu.hideOnMouseOut)
                {
                    FW_startTimeout();
                }
                return(true);
            }
        }
    return(true);
}

function PxToNum(pxStr)
{ // pxStr == 27px, we want 27.
    if (pxStr.length > 2)
    {
        n = Number(pxStr.substr(0, pxStr.length-2));
        return(n);
    }
    return(0);
}

function hideChildMenu(hcmLayer)
{
    FW_clearTimeout();
    var l = hcmLayer;
    for (var i=0; i < l.Menu.childMenus.length; i++)
    {
        var theLayer = l.Menu.childMenus[i];
        if (document.layers)
        {
            theLayer.visibility = "hidden";
        }
        else
        {
            theLayer = FIND(theLayer);
            theLayer.style.visibility = "hidden";
        }
        theLayer.Menu.hideChildMenu(theLayer);
    }

    if (l.childMenu)
    {
        var childMenu = l.childMenu;
        if (document.layers)
        {
            l.Menu.FW_showMenu(null,null,null,childMenu.layers[0]);
            childMenu.zIndex = l.parentLayer.zIndex +1;
            childMenu.top = l.top + l.parentLayer.top + l.Menu.menuLayer.top + l.Menu.menuItemHeight/3;
            if (childMenu.left + childMenu.clip.width > window.innerWidth)
            {
                childMenu.left = l.parentLayer.left - childMenu.clip.width + l.Menu.menuLayer.left + 15;
                l.Menu.container.clip.left -= childMenu.clip.width;
            }
            else
            {
                childMenu.left = l.parentLayer.left + l.parentLayer.clip.width  + l.Menu.menuLayer.left -5;
            }
            var w = childMenu.clip.width+childMenu.left-l.Menu.container.clip.left;
            if (w > l.Menu.container.clip.width)
                l.Menu.container.clip.width = w;
            var h = childMenu.clip.height+childMenu.top-l.Menu.container.clip.top;
            if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
            l.document.layers[1].zIndex = 0;
            childMenu.visibility = "inherit";
        }
        else
            if (FIND("menuItem0"))
            {
                childMenu = FIND(l.childMenu);
                var menuLayer = FIND(l.Menu.menuLayer);
                var s = childMenu.style;
                s.zIndex = menuLayer.style.zIndex+1;
                if (document.all)
                { // ie case.
                    s.pixelTop = l.style.pixelTop + menuLayer.style.pixelTop + l.Menu.menuItemHeight/3;
                    s.left = s.pixelLeft = (menuLayer.style.pixelWidth) + menuLayer.style.pixelLeft -5;
                }
                else
                { // zilla case
                    var top = PxToNum(l.style.top) + PxToNum(menuLayer.style.top) + l.Menu.menuItemHeight/3;
                    var left = (PxToNum(menuLayer.style.width)) + PxToNum(menuLayer.style.left) -5;
                    s.top = top;
                    s.left = left;
                }
                childMenu.style.visibility = "inherit";
            }
            else
            {
                return;
            }
        window.activeMenus[window.activeMenus.length] = childMenu;
    }
}

function hideActiveMenus()
{
    if (!window.activeMenus) return;
    for (var i=0; i < window.activeMenus.length; i++)
    {
        if (!activeMenus[i]) continue;
        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)
            {
                var s = activeMenus[i].style;
                s.visibility = "hidden";
                s.left = -200;
                s.top = -200;
            }
    }
    if (window.ActiveMenuItem)
    {
        hideMenu(false, false);
    }
    window.activeMenus.length = 0;
}

function fwLoadMenus(){
if(window.fw_menu_0){ return;};
window.fw_menu_0 = new Menu("root", 190, 18, 'Arial, Helvetica, sans-serif', 11, '#438b7a', '#6699cc','#b2efeb', '#ecf9f7');
fw_menu_0.addMenuItem('Anniversary and Wedding Bands','location="shopdisplayproducts.asp?id=6" ','Y');
fw_menu_0.addMenuItem('Engagement','location="shopdisplayproducts.asp?id=7"','Y');
fw_menu_0.addMenuItem('Promise','location="shopdisplayproducts.asp?id=8"','Y');
fw_menu_0.addMenuItem('Accent','location="shopdisplayproducts.asp?id=9" ','Y');
fw_menu_0.addMenuItem('Three Stone','location="shopdisplayproducts.asp?id=10"','Y');
fw_menu_0.addMenuItem('Mens','location="shopdisplayproducts.asp?id=11" ','Y');
fw_menu_0.addMenuItem('Fashion','location="shopdisplayproducts.asp?id=12" ','Y');
fw_menu_0.addMenuItem('Motif','location="shopdisplayproducts.asp?id=27" ','Y');
fw_menu_0.addMenuItem('All Purpose','location="shopdisplayproducts.asp?id=31" ','Y');
fw_menu_0.addMenuItem('Heart','location="shopdisplayproducts.asp?id=35" ','Y');
fw_menu_0.addMenuItem('Cluster','location="shopdisplayproducts.asp?id=36" ','Y');
fw_menu_0.addMenuItem('Precious Stone','location="shopdisplayproducts.asp?id=52" ','Y');
fw_menu_0.addMenuItem('Semi-Precious Stone','location="shopdisplayproducts.asp?id=57" ','Y');
fw_menu_0.fontWeight='bold';
fw_menu_0.hideOnMouseOut=true;
window.fw_menu_1 = new Menu("root", 165, 18, 'Arial, Helvetica, sans-serif', 11, '#438b7a', '#6699cc','#b2efeb', '#ecf9f7');
fw_menu_1.addMenuItem('Hoops and Huggies','location="shopdisplayproducts.asp?id=13" ','Y');
fw_menu_1.addMenuItem('Fashion','location="shopdisplayproducts.asp?id=15" ','Y');
fw_menu_1.addMenuItem('Heart','location="shopdisplayproducts.asp?id=29" ','Y');
fw_menu_1.addMenuItem('Vintage','location="shopdisplayproducts.asp?id=37" ','Y');
fw_menu_1.addMenuItem('Motif','location="shopdisplayproducts.asp?id=41" ','Y');
fw_menu_1.addMenuItem('All Purpose','location="shopdisplayproducts.asp?id=42" ','Y');
fw_menu_1.addMenuItem('Journey','location="shopdisplayproducts.asp?id=44" ','Y');
fw_menu_1.addMenuItem('Circle','location="shopdisplayproducts.asp?id=45" ','Y');
fw_menu_1.addMenuItem('Drop','location="shopdisplayproducts.asp?id=38" ','Y');
fw_menu_1.addMenuItem('Pearl','location="shopdisplayproducts.asp?id=39" ','Y');
fw_menu_1.addMenuItem('Precious Stone','location="shopdisplayproducts.asp?id=53" ','Y');
fw_menu_1.addMenuItem('Semi-Precious Stone','location="shopdisplayproducts.asp?id=59" ','Y');
fw_menu_1.fontWeight='bold';
fw_menu_1.hideOnMouseOut=true;
window.fw_menu_2 = new Menu("root", 120, 18, 'Arial, Helvetica, sans-serif', 11, '#438b7a', '#6699cc','#b2efeb', '#ecf9f7');
fw_menu_2.addMenuItem('Fashion','location="shopdisplayproducts.asp?id=17" ','Y');
fw_menu_2.addMenuItem('Tennis','location="shopdisplayproducts.asp?id=18" ','Y');
fw_menu_2.addMenuItem('All Purpose','location="shopdisplayproducts.asp?id=47" ','Y');
fw_menu_2.fontWeight='bold';
fw_menu_2.hideOnMouseOut=true;
window.fw_menu_3 = new Menu("root", 165, 18, 'Arial, Helvetica, sans-serif', 11, '#438b7a', '#6699cc','#b2efeb', '#ecf9f7');
fw_menu_3.addMenuItem('Fashion','location="shopdisplayproducts.asp?id=19" ','Y');
fw_menu_3.addMenuItem('Vintage','location="shopdisplayproducts.asp?id=20" ','Y');
fw_menu_3.addMenuItem('Circle','location="shopdisplayproducts.asp?id=21" ','Y');
fw_menu_3.addMenuItem('Journey','location="shopdisplayproducts.asp?id=22" ','Y');
fw_menu_3.addMenuItem('Three Stone','location="shopdisplayproducts.asp?id=23" ','Y');
fw_menu_3.addMenuItem('Heart','location="shopdisplayproducts.asp?id=24" ','Y');
fw_menu_3.addMenuItem('Religous','location="shopdisplayproducts.asp?id=25" ','Y');
fw_menu_3.addMenuItem('Motif','location="shopdisplayproducts.asp?id=26" ','Y');
fw_menu_3.addMenuItem('Mini Solitaire','location="shopdisplayproducts.asp?id=30" ','Y');
fw_menu_3.addMenuItem('All Purpose','location="shopdisplayproducts.asp?id=32" ','Y');
fw_menu_3.addMenuItem('Accents','location="shopdisplayproducts.asp?id=33" ','Y');
fw_menu_3.addMenuItem('Cluster','location="shopdisplayproducts.asp?id=34" ','Y');
fw_menu_3.addMenuItem('Necklace','location="shopdisplayproducts.asp?id=55" ','Y');
fw_menu_3.addMenuItem('Pearl','location="shopdisplayproducts.asp?id=40" ','Y');
fw_menu_3.addMenuItem('Precious Stone','location="shopdisplayproducts.asp?id=54" ','Y');
fw_menu_3.addMenuItem('Semi-Precious Stone','location="shopdisplayproducts.asp?id=58" ','Y');
fw_menu_3.fontWeight='bold';
fw_menu_3.hideOnMouseOut=true;
window.fw_menu_4 = new Menu("root", 130, 18, 'Arial, Helvetica, sans-serif', 11, '#ffffff', '#6699cc','#cc0000', '#ff0000');
fw_menu_4.addMenuItem('Silver','location="shopdisplayproducts.asp?id=2" ','Y');
fw_menu_4.addMenuItem('Gold','location="shopdisplayproducts.asp?id=2" ','Y');
fw_menu_4.fontWeight='bold';
fw_menu_4.hideOnMouseOut=true;
fw_menu_4.writeMenus();

}
function clearfield(){
if (document.form3.keyword.value == "search this site")
	document.form3.keyword.value = "";
}

function rbc(newcurr) {
	var sL = document.location.href;
	if (sL.indexOf('c=CAD',1) > 0)
	   sL = sL.replace('c=CAD', '')
	if (sL.indexOf('c=USD',1) > 0)
	   sL = sL.replace('c=USD', '')
  	if (sL.indexOf('c=EUR',1) > 0)
	   sL = sL.replace('c=EUR', '')
  //  document.location.href = "shopcurrency.asp?cid=" + newcurr + "&curl=" + sL;
	 document.location.href = "shopcurrency.asp?cid=" + newcurr + "&curl=" + sL.replace(/&/, "*");
}
function rbc2(newcurr) {
    document.location.href = "shopcurrency.asp?cid=" + newcurr + "&curl=" + document.location.href;
}

function fillCategory(){
addOption(document.soptions.Category, "1", "Rings", "");
addOption(document.soptions.Category, "2", "Bracelets", "");
addOption(document.soptions.Category, "3", "Pendants", "");
addOption(document.soptions.Category, "4", "Earrings", "");
}

function SelectSubCat(){
removeAllOptions(document.soptions.SubCat);
addOption(document.soptions.SubCat, "", "SubCategory", "");

if(document.soptions.Category.value == '1'){
addOption(document.soptions.SubCat,"6", "Bands");
addOption(document.soptions.SubCat,"7", "Engagement");
addOption(document.soptions.SubCat,"8", "Promise");
addOption(document.soptions.SubCat,"9", "Accent");
addOption(document.soptions.SubCat,"10", "3-Stone");
addOption(document.soptions.SubCat,"11", "Mens");
addOption(document.soptions.SubCat,"12", "Fashion");
addOption(document.soptions.SubCat,"27", "Motif");
addOption(document.soptions.SubCat,"31", "All Purpose");
addOption(document.soptions.SubCat,"35", "Heart");
addOption(document.soptions.SubCat,"36", "Cluster");
addOption(document.soptions.SubCat,"48", "Pearl");
addOption(document.soptions.SubCat,"52", "Precious Stone");
addOption(document.soptions.SubCat,"57", "Semi-Precious");
}
if(document.soptions.Category.value == '2'){
addOption(document.soptions.SubCat,"17", "Fashion");
addOption(document.soptions.SubCat,"18", "Tennis");
addOption(document.soptions.SubCat,"47", "All Purpose");
}
if(document.soptions.Category.value == '3'){
addOption(document.soptions.SubCat,"19", "Fashion");
addOption(document.soptions.SubCat,"20", "Vintage");
addOption(document.soptions.SubCat,"21", "Circle");
addOption(document.soptions.SubCat,"22", "Journey");
addOption(document.soptions.SubCat,"23", "3-Stone");
addOption(document.soptions.SubCat,"24", "Heart");
addOption(document.soptions.SubCat,"25", "Religious");
addOption(document.soptions.SubCat,"26", "Motif");
addOption(document.soptions.SubCat,"30", "Mini-Solitaire");
addOption(document.soptions.SubCat,"32", "All Purpose");
addOption(document.soptions.SubCat,"33", "Accent");
addOption(document.soptions.SubCat,"34", "Cluster");
addOption(document.soptions.SubCat,"40", "Pearl");
addOption(document.soptions.SubCat,"43", "Charms");
addOption(document.soptions.SubCat,"54", "Precious Stone");
addOption(document.soptions.SubCat,"55", "Necklace");
addOption(document.soptions.SubCat,"58", "Semi-Precious");
}

if(document.soptions.Category.value == '4'){
addOption(document.soptions.SubCat,"13", "Hoops n Huggies");
addOption(document.soptions.SubCat,"14", "Solo");
addOption(document.soptions.SubCat,"15", "Fashion");
addOption(document.soptions.SubCat,"29", "Heart");
addOption(document.soptions.SubCat,"37", "Vintage");
addOption(document.soptions.SubCat,"38", "Drop");
addOption(document.soptions.SubCat,"39", "Pearl");
addOption(document.soptions.SubCat,"41", "Motif");
addOption(document.soptions.SubCat,"42", "All Purpose");
addOption(document.soptions.SubCat,"44", "Journey");
addOption(document.soptions.SubCat,"45", "Circle");
addOption(document.soptions.SubCat,"46", "Accent");
addOption(document.soptions.SubCat,"53", "Precious-Stone");
addOption(document.soptions.SubCat,"56", "Mini-Solitaire");
addOption(document.soptions.SubCat,"59", "Semi-Precious");

}

}
//////////////////

function removeAllOptions(selectbox)
{
        var i;
        for(i=selectbox.options.length-1;i>=0;i--)
        {
                //selectbox.options.remove(i);
                selectbox.remove(i);
        }
}


function addOption(selectbox, value, text )
{
        var optn = document.createElement("OPTION");
        optn.text = text;
        optn.value = value;

        selectbox.options.add(optn);
}
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
return (true)
}
alert("Invalid E-mail Address! The correct format is username@domain.com. Please try again.")
return (false)
}                                     

/////////////////////// New Drop Down
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 