jQuery(document).ready(function() {

	if (typeof $.fancybox == 'function') {
		$("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({'titleShow':false});
	}
	
	if($(".effacable").val() == "") $(".effacable").val($(".effacable").attr("title"))

    $(".effacable").focus(function () {
        var el = $(this);
        if (el.val() == el.attr("title")) {
            el.val("")
        }
    });
    
    $(".effacable").blur(function () {
        var el = $(this);
        if (el.val() === "") {
            el.val(el.attr("title"))
        }
    });

	init_calendrier();

	function jcarousel_resize(carousel, height){
		
		$(carousel.container).animate({height:height+'px'}, 'fast');
			$(carousel.clip).animate({height:height+'px'}, 'fast');	 				
	}
	
	function callback2(carousel, li, index, state){
		path = $('img', li).attr('src');
		if(path != undefined){
			
			$('#illustr_bloc_jne').attr('src', path);
			
			jcarousel_resize(carousel, '102');
			$('#illustr_bloc_jne').fadeIn("slow");
		}
		else if(path == undefined){
			$('#illustr_bloc_jne').fadeOut("fast");
			jcarousel_resize(carousel, '230');
		}

	}				
	
    jQuery('#enbref').jcarousel({			    
		vertical: true,
		scroll: 1,
		auto: 5,
		wrap: 'circular',
		itemFirstInCallback: {
				onAfterAnimation: callback2
		}        			
		 });
			 
	jQuery.getFeed({
        url: stylesheet_directory+'/proxy.php?url=http://www.fne.asso.fr/fr/toutes-nos-actualites/actualite.html?action=get_rss&news_cat=38,53,40,41,43,55,198,197',
        success: function(feed) {

            var html = '';
            
            for(var i = 0; i < feed.items.length && i < 5; i++) {
            
                var item = feed.items[i];
                
                html += '<li>'
                + '<a href="'
                + item.link
                + '" title="'
                + item.title
                + '">'
                + item.title
                + '</a>'
                + '</li>';

            }
            
            $('#actus-fne').empty();
            $('#actus-fne').append(html);
            $('#actus-fne').jcarousel({			    
        		vertical: true,
        		scroll: 1,
        		wrap: 'circular'        			
   			});
   			
        }    
    });   
});
