var zindex=31;
var auto = true;
$(document).ready(function(){	

// +-+-+-+-+-+-+-+- TOP IMAGE 	
	var currentTopImage = $('#topImage01');
	var direction = 'next';
	

		var timer = setInterval (function () {
			if(auto)
			{	
			
				if ((currentTopImage.next('.topImageToFade').attr('class') == undefined) || ((direction == 'previous') && (currentTopImage.prev('.topImageToFade').attr('class') != undefined)))
				{
					
					currentTopImage = currentTopImage.prev('.topImageToFade'); 
					currentTopImage.show(function(){currentTopImage.fadeTo('slow', 1);});

					var myidee = currentTopImage.attr('id');
					myidee = myidee.substring(8,10);
					
					myidee = 'point'+myidee;
					$('.defilantDiapo a').attr('class','normal');
					$('#'+myidee).attr('class','current');

					direction = 'previous';
				}
				else
				{
					currentTopImage.fadeTo('slow', 0, function(){$(this).hide();});
					currentTopImage = currentTopImage.next('.topImageToFade');
				
					var myidee = currentTopImage.attr('id');
					myidee = myidee.substring(8,10);
					
					myidee = 'point'+myidee;
					$('.defilantDiapo a').attr('class','normal');
					$('#'+myidee).attr('class','current');
					direction = 'next'; 	
				}				
			}	
		}, 3000 ); 
	
	
	
	
	$('.defilantDiapo a').click(function(){
		$('.defilantDiapo a').attr('class','normal');								 
		$('.topImageToFade').show();	
		$(this).attr('class','current');
		var idee = $(this).attr('id');
		idee = idee.substring(5,7);
		
		idee = 'topImage'+idee;
		$('#'+idee).css('z-index',zindex);
		$('#'+idee).show(function(){$('#'+idee).fadeTo('normal', 1);});
		
		zindex++;
		auto = false;
										 
	});

});

