

// timer for 5s delay
var timerID = null;

var menuItem = newObject ({
    init : function()
    {
    },
    
    onready : function()
    {
        loader = this.getLoadWrapper('/treemenu_handler.php', 'get', false);
        
        // click on producer
        $('#browser li.expandable span a').click(function() {
            loader.send({
                item: $(this).attr('id')
            });
            if ($(this).parent().next().hasClass('hide')) {
                $(this).parent().next().toggleClass('hide');
                
                //delay(5000);
                var href = $(this).attr('href');
                if (timerID) clearTimeout(timerID);
          		timerID = setTimeout(function() { window.location = href }, 5000);
          		
                return false;
                //return true;
            }
            if (!$(this).parent().parent().hasClass('hide')) {
                $(this).parent().next().toggleClass('hide');
                return false;
            }
        });
        
        // click on model
        $('#browser li.submenu_li a').click(function() {
        	if (timerID) clearTimeout(timerID);
            timerID = null;
        });
        
        // hide all tree
        $('#masstoggler a').click(function() {
            $('.expandable ul').css('display', 'none');
            loader.send({
                collapseAll: true
            });
        });
    }
});
