$(document).ready(function(){
	/** Scrolling Design */ 
	if ($("ul#uldesign").length > 0) {
        /** Défilement */
        var ulsize = $("ul#uldesign").width();
        var start = 0;
        
        $("ul#uldesign li").each(function(){
            $(this).css('left',start+'px');
            start += $(this).width();
            $(this).show('slow');
        });
        
        var ecart = start - ulsize;
        
        if (ecart > 0) {
            $('#right_arrow').live('click', function() {
                var posfirst = $("ul#uldesign li:first").position();

                if (ecart + posfirst.left > 0) {
                    $("ul#uldesign li").each(function(){
                        var lipos = $(this).position();
                        $(this).animate({left: lipos.left - $(this).width()},500);
                    });
                }
            });
            
            $('#left_arrow').live('click', function() {
                var posfirst = $("ul#uldesign li:first").position();
                
                if (posfirst.left < 0) {
                    $("ul#uldesign li").each(function(){
                        var lipos = $(this).position();
                        $(this).animate({left: lipos.left + $(this).width()},500);
                    });
                }
            });
        }
    }
	
	/** Scrolling Videos */
	if ($("ul#ulvideos").length > 0) {
        /** Défilement */
        var ulsize2 = $("ul#ulvideos").width();
        var start2 = 0;
        
        $("ul#ulvideos li").each(function(){
            $(this).css('left',start2+'px');
            start2 += $(this).width();
            $(this).show('slow');
        });
        
        var ecart2 = start2 - ulsize2;
        
        if (ecart2 > 0) {
            $('#right_arrow2').live('click', function() {
                var posfirst = $("ul#ulvideos li:first").position();

                if (ecart2 + posfirst.left > 0) {
                    $("ul#ulvideos li").each(function(){
                        var lipos = $(this).position();
                        $(this).animate({left: lipos.left - $(this).width()},500);
                    });
                }
            });
            
            $('#left_arrow2').live('click', function() {
                var posfirst = $("ul#ulvideos li:first").position();
                
                if (posfirst.left < 0) {
                    $("ul#ulvideos li").each(function(){
                        var lipos = $(this).position();
                        $(this).animate({left: lipos.left + $(this).width()},500);
                    });
                }
            });
        }
    }
})
