jQuery(document).ready(function($){
						
	//
	//
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////// 
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//
	
	//SWFAddress.addEventListener(SWFAddressEvent.CHANGE,onChangeHandler);
	
	//
	//
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////// Trigg les clicks sur les vignettes et update le numero de l'image dans l'adresse
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//
	
	/*
	 $('.nivo-control').live('click', function() {
		SWFAddress.setValue($(this).attr('rel'));
	});
	*/
	//
	//
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////// Trigg les clicks sur la navigation
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//
	/*
	$('#navigation span').live('click', function() {
		pageIndex = $(this).attr('id');
		$.post("../../wp-content/themes/euronavale/libs/photoGallery.php", { pageIndex: $(this).attr('id')},
				function(data) {
				    //alert("Data Loaded: " + data);
					$('#slider').remove();
					
					$('#galleryHolder').prepend('<div id="slider"></div>');
					
				    $('#slider').html(data);
				    initNivoSlider(0);
				    
				  });
	});
*/
	//
	//
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////// Recupere la photo dans l'url.
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//
	/*
	function onChangeHandler(event){
		console.log(SWFAddress.getParameter('page'));
		SWFAddress.removeEventListener(SWFAddressEvent.CHANGE,onChangeHandler);
		if (event.path!="/"){
			startIndex = event.pathNames[0];
		}else{
			startIndex = 0;
		}	
		initNivoSlider(startIndex);
	}
	*/
	//
	//
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////// Initialise le nivoslider.
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//
		var current = 0;
		var picsArray = Array();
		
		
		loadFirstImage();
		
		
		$('.thumbs').click(function() {
			loadNewImage($(this).attr('rel'));
			current = $(this).attr('id');
		});
		
		
		function loadFirstImage(){
			
			var src = $('#galerie-photos dd :first-child').attr('rel');
			$('#big img').attr('src',src);
			$('#big img').height(500);
			$('#big img').load(function() {
				$('#big')	.css('width',$('#big img').width())
							.animate({opacity:1},'fast')
			});	
			
		}
		
		
		function loadNewImage(src){
			$('#big').animate({
			    opacity: 0},'fast', function() {
				$('#big img').attr('src',src);
				$('#big img').attr('height','430');
				$('#big img').load(function() {
					$('#big')	.css('width',$('#big img').width())
								.animate({opacity:1},'fast')
				});
			});
		}	



		// Arrow Navigation
		


		$('#galerie-photos dd img').each(function(index) {
			picsArray.push($(this).attr('rel'));
		});
		
		$('#left-row').click(function() {
			if (current-1<0){current=picsArray.length-1;}else{current--;}
			loadNewImage(picsArray[current]);
		});	
		
		$('#right-row').click(function() {
			if (current+1>=picsArray.length){current=0;}else{current++;}
			loadNewImage(picsArray[current]);
		});	
		
	
	    					
						
						    	
				

    					

    					
	
    					
    					
  
    					
    					
    					
    					
    					
});
