$(document).ready(function() {
    $("#logo").click(function() {
        window.location="index.jsp"
    });
    
    var $menu = $('#ldd_menu');
    $menu.children('li').each(function() {
        var $this = $(this);
        var $span = $this.children('span');
        $span.data('width', $span.width());
        $span.bind('click', function() {
            if ($span.attr('link') != null) {
                window.location = './' + $span.attr('link');
            }
        })
        $this.bind('mouseenter', function() {
            $menu.find('.ldd_submenu').stop(true, true).hide();
            if ($span.attr('link') == null) {
                $this.find('.ldd_submenu').show();
            }
        }).bind('mouseleave', function() {
            $this.find('.ldd_submenu').stop(true, true).hide();
        });
    });
    
    document.fillPathLine = function(category, news) {
        if ($.trim(category) != '') {
            if (news) {
                $('#globalPathLine').append($("<div>").append($("<a href='allNews.jsp'>" + category + "</a>")).append($("<span>").text(">")));
            } else {
                $('#globalPathLine').append($("<div>").append($("<a href='pages.jsp?category=" + category + "'>" + category + "</a>")).append($("<span>").text(">")));
            }
        }
    }
});
