
var over = 0;

$(document).ready(function (){
	$("#pikame").PikaChoose({carousel:true, transition:[-1]});
	Shadowbox.init(); 
	
	
	
	
	
	$('.tdPhoto').each(function(index, item){
		if(index == 0){
			$(item).children('.image:first').addClass('active');
		}
		
		
		$(item).mouseenter(function(){
			$(item).children('.image:first').addClass('upper-active');
			over = 1;
		});
		$(item).mouseleave(function(){
			$(item).children('.image:first').removeClass('upper-active');
			over = 0;
		});
	});
	
	
});

function slideSwitch() {
	if(over) return 0;
	var $next = 0;
	var $nextTrouvee = 0;
	var $activeTrouvee = 0;
	$('.tdPhoto').each(function(index, item){
		if(index == 0 ){
			$next =  $(item).children('.image:first');
		}
		
		if($activeTrouvee && $nextTrouvee == 0){
			$next =  $(item).children('.image:first');
			$nextTrouvee = 1;
		}
		
		if($(item).children('.image:first').hasClass('active')){
			$active = $(item).children('.image:first');
			$activeTrouvee = 1;
		}
	});
	if(typeof $active == 'undefined') return 0;
	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
	
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});






















