/* AU CHARGEMENT
--------------------------------------------------------------------------------------------------------------------------------------*/

$(function(){
	// Form focus
	$('#s').focus(function(){
		if($(this).attr('value') == this.defaultValue) $(this).attr('value', '');
	}).blur(function(){
		if($.trim(this.value) == '') this.value = (this.defaultValue ? this.defaultValue : '');
	});
	
	// Reply com
	$('.thdrpy a').each(function(i, el){
		$(el).addClass('reply').unwrap().appendTo($(el).prevAll('.meta'));
	});
	
	// Carousel Home
	if($('#boxActu')[0]){
		$('#homeCarousel').jcarousel({
			scroll:1,
			auto:5,
			wrap: 'last',
			initCallback: carouselInit,
			buttonNextHTML: null,
			buttonPrevHTML: null,
			itemFirstInCallback : function(carousel, el, index, state){
				$('#boxActu .nav li').removeClass('active');
				$('#boxActu .nav #elem'+index).addClass('active');
			}
		}); 
	}

	if($('#partenaires_carousel')[0]){
		$('#partenaires_carousel').jcarousel({
			auto : 2,
			scroll: 1,
			wrap: 'last'
		});
	}
	
	$('#bmcbj_cestquoi_lien').hover(function(){
		$('#bmcbj_cestquoi').fadeIn(100);
	},function(){
		$('#bmcbj_cestquoi').fadeOut(100);
	});
	
	
});

function carouselInit(carousel){
	// Items
	$('#boxActu .nav li').click(function(){
		carousel.stopAuto();
		$('#boxActu .nav li').removeClass('active');
		carousel.scroll($.jcarousel.intval($(this).attr('id').substr(4)));
		$(this).addClass('active');
	});
}
/*
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();
    });
};*/
