jQuery(function(){
    
    // Menu mouseover effect
    //$(document).pngFix();
	
	$('#nav>li').hover(
        function(){
            $("a img", this).fadeTo("fast", 0.001);
        },
        function(){
            $("a img", this).fadeTo("fast", 1);
        }
    );
	
	$('#nav li').hover(
        function(){
			$(this).addClass('sfhover')
        },
        function(){
			$(this).removeClass('sfhover')
        }
    );
    
	
	// Stick menu
	//var souMenuItem = $('#sous-menu').find('a[href=' + window.location.pathname + window.location.search + window.location.hash + ']').addClass('selected').parent().parent().parents("ul").find('a:first');
	var souMenuItem = $('#sous-menu').find('a[href=' + window.location.pathname + window.location.search + window.location.hash + ']').addClass('selected').parent().parents("li").find('a:first');
	if (souMenuItem.length > 0) {
        var location = src = souMenuItem.attr("href"); 
    } else {
		var location = window.location.pathname + window.location.search + window.location.hash;
	}
	
	// Main menu
	var img = $('#nav li ul').find('a[href=' + location + ']').addClass('selected').parent().parent().parent().find('a:first img');
    if (img.length > 0) {
        src = img.attr("src");
        img.attr("src", src.replace(".gif", "_over.gif"));
    }
	
	/* Add icon to link */
	// External link
    $('#page a[target=_blank]').filter("a[href^=http]").css({
        paddingRight: '12px',
        background: 'transparent url("/imports/images/icons/external_link.png") no-repeat center right'
    });
    $('#page a[href$=".doc"]').css({
        paddingRight: '18px',
        background: 'transparent url("/imports/sys/fileinfo/icone_doc.gif") no-repeat center right'
    });
    $('#page a[href$=pdf]').css({
        paddingRight: '18px',
        paddingTop: '1px',
        paddingBottom: '1px',
        background: 'transparent url("/imports/sys/fileinfo/icone_pdf.gif") no-repeat center right'
    });
    $('#page a[href$=jpg], a[href$=JPG]').not(".no-icon").css({
        paddingRight: '18px',
        background: 'transparent url("/imports/sys/fileinfo/icone_img.gif") no-repeat center right'
    });
    
    
    $(".popup-calendar").click(function(){
    	var href = $(this).attr("href");
    	window.open(href, null, "height=750,width=850,scrollbars=1,resizable=1");
    	return false;
    });
    
    
    
});
