var items = new Array();
var currentitem = 1;
var t;

function changeThumb()
{
    $(".imgentete").stop().animate({"opacity": "0"}, "slow");
    $(".textentete").stop().animate({"opacity": "0"}, "slow");
        
    $("#imgentete" + items[currentitem]).show();
    $("#imgentete" + items[currentitem]).stop().animate({"opacity": "1"}, "slow");
        
    $("#textentete" + items[currentitem]).css('opacity', 0);
    $("#textentete" + items[currentitem]).show();
    $("#textentete" + items[currentitem]).css('marginLeft', "250px");
    $("#textentete" + items[currentitem]).stop().animate({opacity: 1}, {queue: false, duration: 'slow'});
    $("#textentete" + items[currentitem]).animate({'marginLeft' : "-=100px"}, "slow");  
    
    $('.thumbentete').each(function(index) {
    	$(this).attr('src', $(this).attr("off"));
  	});

    $("#thumbentete" + items[currentitem]).attr("src", $("#thumbentete" + items[currentitem]).attr("on"));
	
	currentitem = currentitem + 1; 
		
	if (currentitem == items.length)
		currentitem = 0; 
		
	t=setTimeout("changeThumb()",4000);  
}
	
t=setTimeout("changeThumb()",4000);

////// NOUVELLE VERSION ///////
$(document).ready(function(){

    $('.thumbentete').first().attr('src', $('.thumbentete').first().attr("on"));
    
    // Lecture des items
	$('.thumb').each(function(index) {
    	items.push($(this).attr('imageId'));//.attr("imageid"));
  	});
    
    $(".thumbentete").mouseenter(function(){
        $('.thumbentete').each(function(index) {
            $(this).attr('src', $(this).attr("off"));
        });
        $(this).attr('src', $(this).attr('on')); 
    });

    $(".thumbentete").mouseleave(function(){
        $(this).attr('src', $(this).attr('off')); 
    });
    	    
    $(".thumb").mouseenter(function(){
		
		clearTimeout(t);
    
        $(".imgentete").stop().animate({"opacity": "0"}, "slow");
        $(".textentete").stop().animate({"opacity": "0"}, "slow");
        
        $("#imgentete" + $(this).attr("imageid")).show();
        $("#imgentete" + $(this).attr("imageid")).stop().animate({"opacity": "1"}, "slow");
        
        $("#textentete" + $(this).attr("imageid")).css('opacity', 0);
        $("#textentete" + $(this).attr("imageid")).show();
        $("#textentete" + $(this).attr("imageid")).css('marginLeft', "250px");
        $("#textentete" + $(this).attr("imageid")).stop().animate({opacity: 1}, {queue: false, duration: 'slow'});
        $("#textentete" + $(this).attr("imageid")).animate({'marginLeft' : "-=100px"}, "slow");     
        
    });  
});
