jQuery(document).ready(function(){
	
	$('div#add-comment').hide();
	$('div#read-comment').hide();
	$('div.sous-metanav').hide();
	
	
	jQuery('a.add-comment').click(function() {
		$('div#add-comment').toggle(200);
	});
	jQuery('a.fermer_comment').click(function() {
		$('div#add-comment').toggle(200);
	});
	jQuery('a.read-comment').click(function() {
		$('div#read-comment').toggle(200);
	});
	jQuery('a.fermer_comment_read').click(function() {
		$('div#read-comment').toggle(200);
	});
	
	
	// Lien pour l'affichage recherche - reseaux sociaux
	jQuery('a.switch_recherche').click(function() {
		if ($('div#recherche-meta').css('display') == "none") {
			$('div#reseaux-meta').hide();
			$('div#recherche-meta').fadeIn(300);
		} else {
			$('div#recherche-meta').fadeOut(300);
		}		
	});
	jQuery('a.switch_reseaux').click(function() {
		if ($('div#reseaux-meta').css('display') == "none") {
			$('div#recherche-meta').hide();
			$('div#reseaux-meta').fadeIn(300);	
		} else {
			$('div#reseaux-meta').fadeOut(300);			
		}
	});
	
	
	// Carousel galerie en page d'accueil
	/*
	jQuery('#carousel_portrait').jcarousel({
        //auto: 2,
        wrap: 'last',
        initCallback: mycarousel_initCallback,
		scroll: 1
	});
	*/
	/*jQuery("ul#carousel_portrait li a img[id^='imgHover_']").each(function(i){
		jQuery(this).hover(function() {
			jQuery(this).animate({ 
	  	      width: "136"
	     	},500);
		}, function () {
		       jQuery(this).animate({ 
			  	     width: "91"
			    },500);
     	 });

	});*/
		
	
	// Carousel galerie de portrait en page d'accueil
	$('ul#fade_galerie').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '140px'
	})
	
	
	// Expand agenda
	/*$("div[id^='evt_']").each(function(i){
		var this_id = $(this).attr("id");
		$("div#" + this_id + " p").hide();
		$("div#" + this_id + " h5 a").click(function(){
			$("div#" + this_id + " p").toggle(200);
		});
	});*/
	
	/*$('img.captify').captify({
		speedOver: 'fast',
		speedOut: 'normal',
		hideDelay: 500,	
		animation: 'slide',		
		prefix: '',		
		opacity: '0.7',					
		className: 'caption-bottom',	
		position: 'bottom',
		spanWidth: '100%'
	});*/

	
	// Tab page calendrier
	jQuery("#tab_agenda").tabs({ fxFade: true, fxSpeed: 'fast' });	
		
	
	// masque les descriptions des evenements
	jQuery('#tab_agenda .evt-group .evt-line p.evt-desc').hide();

});


function showEvt(id_evt) {
	jQuery('#tab_agenda .evt-group .evt-line p.evt-desc:visible').slideUp(200);
	jQuery('#tab_agenda .evt-group .evt-line#'+id_evt+' p.evt-desc').slideDown(200);
}


function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
