var rightMenuWidthControl = function()
{
    var link = jQuery('#filtre_agenda-showhide a'), rightmenu = jQuery('#filtre_agenda'), timeout = null, maincolumn = jQuery('#evenements'), cookie = jQuery.cookie('agenda_column');
    
		if(cookie == 0)
		{
			/* Masquer les filtres par défaut */
      rightmenu.css({ paddingRight: '0', paddingLeft: '0', width: '0%', height: '0'});
      maincolumn.css({paddingRight: '0%', width: '100%'});
		}
		
    link.attr('href', 'JavaScript:void(0);').html( rightmenu.width() <= 0 ? '<img src=\"/extension/iagutils/design/ezwebin/images/background/puce02.png\" width=\"19\" height=\"8\" alt=\"\" \/> Afficher les filtres' : 'Masquer les filtres <img src=\"/extension/iagutils/design/ezwebin/images/background/puce01.png\" width=\"19\" height=\"8\" alt=\"\" \/>' ).click(function(e)
    {
        if ( timeout !== null )
        {
            clearTimeout( timeout );
            timeout = null;
        }

        var link = jQuery( this ), rightmenu = jQuery('#filtre_agenda'), hidden = rightmenu.width() <= 0;
        if ( hidden )
        {
            maincolumn.animate({
                width: '54%'
            }, 300, 'swing');

            rightmenu.animate({
            	paddingRight: '2%',
                paddingLeft: '3%',
                width: '35%',
                height: '100%'
            }, 300, 'swing', function(){
                timeout = setTimeout( saveRightMenuStatus, 500 );
            } );
        }
        else
        {
			maincolumn.delay(100).animate({
								paddingRight: '0%',
								width: '100%'
								}, 300, 'swing');

                rightmenu.animate({
                paddingRight: '0',
                paddingLeft: '0',
                width: '0%',
                height: '0'
            }, 300, 'swing', function(){
                timeout = setTimeout( saveRightMenuStatus, 500 );
            } );
        }
        link.html( hidden ? 'Masquer les filtres <img src=\"/extension/iagutils/design/ezwebin/images/background/puce01.png\" width=\"19\" height=\"8\" alt=\"\" \/>' : '<img src=\"/extension/iagutils/design/ezwebin/images/background/puce02.png\" width=\"19\" height=\"8\" alt=\"\" \/> Afficher les filtres' );
        e.preventDefault();
    });

    function saveRightMenuStatus()
    {
        var show  = jQuery( '#filtre_agenda' ).width() <= 0 ? '' : '1';
        jQuery.post( jQuery.ez.url.replace( 'ezjscore/', 'style/preferences/agenda_column/' ) + show );
				//jQuery.post( jQuery.ez.url.replace( 'ezjscore/', 'user/preferences/set_and_exit/admin_right_menu_show/' ) + show );
    }
};
