$(function(){
    $("#navigation li").fadeTo(0,0);
    
    $("#navigation li").hover(
        function() {
            $(this).stop().fadeTo(400,1);
        },
        function() {
            $(this).stop().fadeTo(400,0.6);
        }
    );
    
    // $("#navigation").mouseenter(showNavigation);
    // $("#navigation").mouseleave(hideNavigation);
    
    
    //var config = {    
    //    over: showNavigation, // function = onMouseOver callback (REQUIRED)    
    //    timeout: 500, // number = milliseconds delay before onMouseOut    
    //    out: hideNavigation // function = onMouseOut callback (REQUIRED)    
    //};
    //$("#navigation").hoverIntent(config);
    
    //$("#navigation").hoverIntent(
    //	 function() {
    //         showNavigation();
    //     },
    //     function() {
    //         hideNavigation();
    //     }
    //);
    
    $("#navigation").hoverIntent({
       over: showNavigation,
       timeout: 500,
       out: hideNavigation
    });
    
    
    function showNavigation() {
        /* switch_tab_image(); */
    	$("#navigation p img").stop().fadeTo(1000,0);
        $("#navigation li").stop().fadeTo(800,0.6);
        $("#navigation").stop().animate({top:"0"}, 500, "easeOutExpo");
        $("#header, #main, #bread_crumbs, #social_buttons").stop().animate({top:"44px"}, 500, "easeOutExpo");
    }
    
    function hideNavigation() {
        /* switch_tab_image(); */
        $("#navigation p img").stop().delay(500).fadeTo(1000,1.0);
        $("#navigation li").stop().fadeTo(400,0);
        $("#navigation").stop().animate({top:'-44px'},1000);
        $("#header,  #main, #bread_crumbs, #social_buttons").stop().animate({top:"0px"}, 1000);
    }
    
    /* function switch_tab_image() {
    	var src = $("#navigation p img").attr('src');
    	$("#navigation p img").attr('src', $("#navigation p img").attr('hsrc'));
    	$("#navigation p img").attr('hsrc', src);
    } */
    
    function wordbreak() {
        var $targetElement = '.wordbreak';
        if($.browser.msie) {
            $($targetElement).css('word-break', 'break-all');
        } else {
            $($targetElement).each(function(){
                // if(navigator.userAgent.indexOf('Firefox/2') != -1) {
                    $(this).html($(this).text().split('').join('<wbr />'));
                // } else {
                //     $(this).html($(this).text().split('').join(String.fromCharCode(8203)));
                // }
            });
        }
    }
    wordbreak();
    
});
