$(function() {
	$('.rounded').corner('5px');
	$('.recentcomments').corner('4px');

	$('#main').corner('7px');
	
	$('#brevedecomptoir').corner('5px br bl');
	
	if ($('#button-facebook').length) {
		$('#button-facebook a').corner('5px br bl');
	}
	
	$('#newsletter-email').focus(function() {
		if ($(this).val() == 'Ton adresse email !') {
			$(this).val('');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val('Ton adresse email !');
		}
	});
	
	$('#s').focus(function() {
		if ($(this).val() == 'Recherche sur le site') {
			$(this).val('');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val('Recherche sur le site');
		}
	}).val('Recherche sur le site');
	
	if ($('#slideshow').length) {
		$("#slideshow ul").jcarousel({
			auto: 5,
			scroll: 1,
			wrap: 'last',
			initCallback: mycarousel_initCallback,
			itemVisibleInCallback: {
				onBeforeAnimation:  function(carousel, item, idx, state) {
					$('#jcarousel-controls .selected').removeClass('selected');
					$('#jcarousel-controls a#'+idx).addClass('selected');
				}
			}
	    });
	
		$('.jcarousel-item .description').corner('5px');
	}
	
	$('.link-facebook').click(function() {
		u = $(this).attr('href');
		t = $(this).attr('title');
		window.open(u+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
		return false;
	});
	
	if ($('#submit').length) {
		
		if ( ! $.browser.msie) {
			$('#submit').corner('5px');
		}
	}
});

function mycarousel_initCallback(carousel) { 
	
	$('#jcarousel-controls a').bind('click', function() {
		var $link = $(this);
		$('#jcarousel-controls .selected').removeClass('selected');
		$link.addClass('selected');
	    carousel.scroll(jQuery.jcarousel.intval($link.attr('id')));
	    return false;
	});
	
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

