	/*$('#animBanner').innerfade(
	{
		speed: 'slow',
		timeout: 5000,
		type: 'random',
		containerheight: '313px',
		containerwidth: '950px'
	});*/

	/*$(".playNav").find(".previous").click( function() {
		$("#animBanner").find('li').each( function() {
			if($(this).css("display") == "list-item") {
				$(this).css("display", "none");
				$(this).css("z-index", parseInt($(this).css("z-index"))+1);
				$(this).prev($(this).css("display", "list-item"));
				$(this).prev($(this).css("z-index", parseInt($(this).css("z-index"))+1));
			}
		})
	 });
	$(".playNav").find(".next").click( function() {
		$('#animBanner').innerfade();
	});
*/
$(document).ready(function(){
	$('#animBanner').find('li').each(function(){
		$(this).css('opacity', '0.0');
	});
	var $first = $('#animBanner').find('li:first');
	$first.css('opacity', '1.0');

	$('.playNav').find('.next').click(function() {
		
		slideSwitch();
		return false;

	});

	$('.playNav').find('.previous').click(function() {
		
		slideSwitch('prev');
		return false;
	});
});

var timer;
var animationLength = 500;
var betweenAnimation = 5000;

function slideSwitch(mode) {

	clearTimeout(timer);
	if( mode == 0 || mode == undefined ) mode = 'next';
	
    var $active = $('#animBanner').find('li.active');

    if ( $active.length == 0 ) $active = $('#animBanner').find('li:first');

	if( mode == 'next'){
    var $next = $active.next().length > 0 ? $active.next() : $('#animBanner').find('li:first');
  	}else{
    var $next = $active.prev().length > 0 ? $active.prev() : $('#animBanner').find('li:last');
	}
 
	$('#animBanner li').removeClass('last-active'); 
    $active.addClass('last-active').removeClass('active');

    $next.css('opacity', '0.0');
    $next.addClass('active');
    $next.stop();
    $next.animate({
		opacity: 1.0}, animationLength );
    timer = setTimeout("slideSwitch()", betweenAnimation);
    var $input = $next.find('.inputBanner');
    var $text = $input.val();
    $desc = $(".works").find(".desc p");
    $desc.html($text);
    //alert($text);
    var aBody = $('body');
    var aRand = Math.random();
    	// Default
    if(aRand < 0.33) {
	aBody.removeClass('changeColor-1');
	aBody.removeClass('changeColor-2');
	// couleur 1
    } else if(aRand < 0.66) {
	aBody.addClass('changeColor-1');
	aBody.removeClass('changeColor-2');
    }
    	// couleur 2
    else {
	aBody.addClass('changeColor-2');
	aBody.removeClass('changeColor-1');
    }
}

$(document).ready(function(){
	timer = setTimeout("slideSwitch()", betweenAnimation);
});

