jQuery(window).resize(function(){
	resizeBandeau();
});

jQuery(document).ready(function() {
	//jQuery(".ui-tabs-nav li").css('background','none');
	resizeBandeau();
	//alert(jQuery('#mycarousel_evenements li').length);
   jQuery('#mycarousel').jcarousel({
        auto: 0,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
	
	jQuery('#mycarousel_evenements').jcarousel({
        auto: 0,
        wrap: 'last',
        scroll: 1
		//size: eval(jQuery('#mycarousel_evenements li').length - 1),
    //    initCallback: mycarousel_initCallback
    });


	jQuery(function() {

			var jQuerytabs = jQuery('#tabs').tabs();
	
			jQuery(".ui-tabs-panel").each(function(i){
	
			  var totalSize = jQuery(".ui-tabs-panel").size() - 1;
	
			  if (i != totalSize) {
			      next = i + 2;
		   		  jQuery(this).append("<a href='#' class='next-tab mover' rel='" + next + "'> >> </a>");
			  }
	  
			  if (i != 0) {
			      prev = i;
		   		  jQuery(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'> <<</a>");
			  }
   		
			});
	
			jQuery('.next-tab, .prev-tab').click(function() { 
		           jQuerytabs.tabs('select', jQuery(this).attr("rel"));
		           return false;
		       });
       

		});
		
		jQuery(function() {

			var jQuerytabs = jQuery('#tabs2').tabs();
	
			jQuery(".ui-tabs-panel").each(function(i){
	
			  var totalSize = jQuery(".ui-tabs-panel").size() - 1;
	
			  if (i != totalSize) {
			      next = i + 2;
		   		  jQuery(this).append("<a href='#' class='next-tab mover' rel='" + next + "'> >> </a>");
			  }
	  
			  if (i != 0) {
			      prev = i;
		   		  jQuery(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'> <<</a>");
			  }
   		
			});
	
			jQuery('.next-tab, .prev-tab').click(function() { 
		           jQuerytabs.tabs('select', jQuery(this).attr("rel"));
		           return false;
		       });
       

		});
		
	
	jQuery(".toggle_container").hide();
	jQuery(".toggle_container_first").slideToggle("slow,");
	jQuery(".trigger").toggle(function(){
		jQuery(this).addClass("active");
	}, function () {
		jQuery(this).removeClass("active");
	});

	jQuery(".trigger").click(function(){
		jQuery(this).next(".toggle_container").slideToggle("slow,");
	});
	
	
	//Onglet Agenda

	jQuery(".focus_evenement:first").click(function(){
		jQuery(".container-evenement:first").css('visibility','visible')
		jQuery(".container-focus:first").parent('.bloc_contenu:first').css('display','none');
		jQuery(".container-focus:first").addClass('hide_block');
		
		jQuery(".container-evenement:first").parent('.bloc_contenu:first').css('display','block');
		jQuery(".container-evenement:first").removeClass('hide_block');
		return(false);
		
	});
	
	jQuery(".focus_agenda:first").click(function(){
		jQuery(".container-focus:first").parent('.bloc_contenu:first').css('display','block');
		jQuery(".container-focus:first").removeClass('hide_block');
		
		jQuery(".container-evenement:first").parent('.bloc_contenu:first').css('display','none');
		jQuery(".container-evenement:first").addClass('hide_block');
		return(false);
	});
		//jQuery.delay(3000);
		jQuery(".container-evenement:first").addClass('hide_block');
		//jQuery(".container-evenement:first").css('visibility','hidden');
 });

 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();
    });

}
 
 // redimentionement de l'image du bandeau
 function resizeBandeau()
 {	
	var bandeauWidth = jQuery("#fond_bandeau").width();
	if (bandeauWidth < '1000')
		bandeauWidth = '1000';
	if (jQuery(".tx-emedia-pi1:first").children().is('img')) {
			jQuery(".tx-emedia-pi1:first").css({'overflow':'hidden','height':'248px'});
			jQuery(".tx-emedia-pi1:first").children(":first").attr({'width':bandeauWidth,'height':''}).css({'width':bandeauWidth+'px','height':'auto'});
	}
	else if (jQuery("#fond_bandeau").children().is('img')) {
			jQuery("#fond_bandeau").css({'overflow':'hidden','height':'248px'});
			jQuery("#fond_bandeau").children(":first").attr({'width':bandeauWidth,'height':''}).css({'width':bandeauWidth+'px','height':'auto'});
	}
}