(function($) {
	$.fn.displayInfo = function(options){
		var defaults = {
			show_speed : 500,
			hide_speed : 500
		};
		
		// On étend les options
		var opt = $.extend({}, defaults, options);
			
		// On crée une variable pour notre objet
		var obj = $(this);
				
		// On véhicule une variable currentlymoving sur notre objet
		obj.data("currentlyChanging", false);
				
		// Opacity des images non séléctionnez
		var opacityThumb = 0.4;

		$("> li > a > img", obj).css({
			"opacity":opacityThumb
		});
		$("#theInfo").css({
			"opacity":1
		});				
		
		$("> li > a > img",obj).mouseenter(function(){
			$(this).css("opacity","1");
		});
		$("> li > a > img",obj).mouseleave(function(){
			$(this).css("opacity",opacityThumb);
		});
		
		// On crée les fonctions pour la navigation
		$("> li > a",obj).click(function(){
			if(obj.data("currentlyChanging") == false){
				var alias = $(this).attr("name");
				var lang = $(this).attr("lang");
				$("> li >a.over",obj).removeClass('over').animate({"opacity":opacityThumb},opt.hide_speed);
				$(this).addClass('over').animate({"opacity":"1"},opt.show_speed);			
				
				$.ajax({
				   type: "POST",
				   url: "data-accueil.php",
				   data: "alias="+alias+"&lang="+lang,
				   success: function(msg){
				     	showInfo( msg );
				   }
				 });	
				
			}
			return false;
		});
		
		//$("> li > a:first",obj).click();
		
		function showInfo(text){
			if(obj.data("currentlyChanging") == false){
				obj.data("currentlyChanging",true);
				
				if($("#theInfo").css("opacity") == 0){
					$("#theInfo").append(text);
					Cufon.replace(".accueilInfo h3",{ fontFamily: 'nissan_light' });
					Cufon.replace(".accueilInfo h2",{ fontFamily: 'nissan_reg' });
					$("#theInfo").animate({"opacity":1},opt.show_speed,"linear",function(){
						obj.data("currentlyChanging",false);
						
					});
				} else {
					$("#theInfo").animate({"opacity":0},opt.hide_speed,"linear",function(){
						$("#theInfo").empty();
						$("#theInfo").append(text);
						Cufon.replace(".accueilInfo h3",{ fontFamily: 'nissan_light' });
						Cufon.replace(".accueilInfo h2",{ fontFamily: 'nissan_reg' });
						$("#theInfo").animate({"opacity":1},opt.show_speed,"linear",function(){
							obj.data("currentlyChanging",false);

						});
					});
				}
				
	
			}
		}
		
		function showGoodThumb(newObj){
			$("> .over",obj).removeClass('over').animate({"opacity":opacityThumb},opt.hide_speed);
			$(this).addClass('over').animate({"opacity":"1"},opt.show_speed);
		}
	};
})(jQuery);
