/** 
 * Gestion du menu Ichec
 */
$(function(){
    
    // overlay on main menu
    $(".main-navigation > ul > li").hover(
        // over
        function() {
            $("div.submenu").hide();
            $("div.submenu", this).show();
        },
        // out
        function() {
            $("div.submenu").hide();
        }
    );
    
    // contact us layer
    $("#contactus").hover(
        // over
        function() {
            $("#contact-infos").show();
        },
        // out
        function() {
            $("#contact-infos").hide();
        }
    );
        
    // click for search
    $('#search-click').click(function(){
        $('#header-search').submit();
    });
    
    // quick fix old images to new size
    $('img[width=702]').attr({'width':'928'});
    // fix intra page links
    $('#breadlabels').append('<a name="pagetop"/>');
    $('p[align=right]').each(function(){
    	if ( $(this).text() == 'Retour haut de page') 
   		{
    		$(this).css({'cursor':'pointer'}).click(function(){window.location = '#pagetop';}).text(' ').html('<div class="backtotop">Retour haut de page</div>');
   		}
    });
    
    
    // news in a dialog
    $('.nwslatest a,#news-content-list a').click(function(e){
    	e.preventDefault();
		$('body').append('<div id="newsDialogIchec"></div>');
		$('#newsDialogIchec').load( $(this).attr('href')+'?sydneylayout=no', function(){
		} ).dialog({'title':'News','height':300,'width':500, 'close': function(event, ui) { $('#newsDialogIchec').remove(); } });
    	
    });
    
});
