var rules =
{
    '.blank' : {
        onmouseover : function() {
            for (i = 1; i < 5; i++) {
                var menu_popup = getObject('menu_popup0' + i);
                 
                if (menu_popup) {
                    hide(menu_popup);
                }
            }
        }
    },
    '.menu' : {
        onclick : function() {
            return false;
        },
        onmouseover : function() {
            hilite(this);
             
            for (i = 1; i < 5; i++) {
                var menu_popup = getObject('menu_popup0' + i);
                 
                if (menu_popup) {
                    hide(menu_popup);
                }
            }
             
            var i = this.id.substring(this.id.length - 2);
            var menu_popup = getObject('menu_popup' + i);
            var menu_column = getObject('menu_column01'); 
            
            hover(getObject('link0' + i));
                
            if (menu_popup) { 
                var left = getWidth(menu_column) * -1;
                var right = getWidth(menu_column);
                
                var offset = (parseInt(i) % 2) > 0 ? left : right;
                
                var x = findPosX(this) + offset;
                var y = findPosY(this);
                
                menu_popup.style.left = x + 'px';
                menu_popup.style.top = y + 'px';
                
                show(menu_popup);
            }
        },
        onmouseout : function() {
            unhilite(this);

            var i = this.id.substring(this.id.length - 2);
            var menu_popup = getObject('menu_popup' + i);;
             
            unhover(getObject('link0' + i));
            
            if (menu_popup) { 
            hideLater(menu_popup, 1000);
            }
        }
    },
    '.menu_item' : {
        onclick : function() {
            unhilite(this);

            var i = this.id.substring(this.id.length - 3);
            var href = getObject('link' + i).getAttribute('href');
             
            unhover(getObject('link' + i));

            if (href && href != null) document.location = href;
        },
        onmouseover : function() {
            hilite(this);

            var i = this.id.substring(this.id.length - 3);
             
            hover(getObject('link' + i));
             
            window.status = getObject('link' + i).getAttribute('href');
        },
        onmouseout : function() {
            unhilite(this);
             
            var i = this.id.substring(this.id.length - 3);
             
            unhover(getObject('link' + i));

            window.status = ' ';
        }
    },
    '.menu_popup' : {
        onclick : function() {
            hide(this); 
        },
        onmouseover : function() {
            show(this);
            var i = this.id.substring(this.id.length - 2);
             
            hover(getObject('link0' + i));

            hilite(getObject('menu' + i));
        },
        onmouseout : function() {
            hideLater(this, 1000);
            var i = this.id.substring(this.id.length - 2);
             
            unhover(getObject('link0' + i));

            unhilite(getObject('menu' + i));
        }
    }
};

Behavior.register(rules);

