$(document).ready(function() {
    $('#home-slideshow').nivoSlider({
    	effect: 'fold',
    	directionNav: false,
    	controlNav: false,
    	captionOpacity: 0,
    	pauseOnHover: false
    });
    
    // Si sidebar il y a, et si IE>6
    if( $('#sidebar #inner').size() > 0 && !( $.browser.msie && parseInt($.browser.version) < 7 ) ) {
	    $('#sidebar #inner').jStick({
	    	offset: 20,
	    	limit: $('#footer').offset().top
	    });
    }
    
    /***********************
	Convertit de "http://www.youtube.com/watch?v=iyxcqoZTs8o" à "http://www.youtube.com/v/iyxcqoZTs8o"
	***********************/    
	
    $('#content a[href*="youtube.com"]').each(function(){
    	
    	var url = $(this).attr('href');
    	url = url.replace( /(.+)\?(.+)?v=([a-zA-Z0-9_-]+)(.+)?/ , "http://www.youtube.com/v/$3" );
    	$(this).attr('href',url).append('<span class="youtube">');
    	
    	$(this).colorbox({
    		iframe: true,
    		innerWidth: 634,
    		innerHeight: 500
    	});
    	
    	$(this).css({
    		'display':'block',
    		'margin-bottom':'50px'
    	});
    	
    });

    /**********
     * ouvrir les liens vers images dans une lightbox
     */
    $('#content a:not([href*="youtube.com"]) img').parent('a').colorbox({
        maxWidth: 1000,
        maxheight: 900
    });
});

