var defImage = {

   nbImg : 0,
   nbCurrent : 1 ,
   elemCurrent : null,
   elem : null,
   timer : null,
   
   def : function(elem){
   
     this.elem = elem ;
     this.nbImg = elem.find(".Nytsee").length;
   
	 //on cré la partie navigation
	 this.elem.append("<div id='navigation'></div>");
	 for(i=1;i<=this.nbImg;i++){
	 this.elem.find("#navigation").append("<span>"+i+"</span>");
	 } 
	 
     /* Initialisation des variables*/
	 this.elem.find(".Nytsee").hide();
	 this.elemCurrent = this.elem.find(".Nytsee:first");
	 this.elemCurrent.show();
	 this.elem.find("#navigation span:first").addClass("active");
	 this.elem.find(".inform").css("opacity",0.91);
	 
	 //On cré le timer
	  defImage.play();
      this.elem.mouseover(defImage.stop);
      this.elem.mouseout(defImage.play);
	  
	  //On déclenche l'evénement sur les spans
	  this.elem.find("#navigation span").click(function(){defImage.slideTo($(this).text())});
   
   },
   
   slideTo : function(num){
   if(num == this.nbCurrent){return false;}
        this.elem.find(".titre_rouge").animate({ bottom: 40 },800);
   		this.elemCurrent.fadeOut(2000);
		this.elem.find("#slide"+num).fadeIn(2000);
		this.elem.find(".titre_rouge").animate({ bottom: 73 },800);
		
		//On garde le numéro current actif
		this.elem.find("#navigation span").removeClass("active");
		this.elem.find("#navigation span:eq("+(num - 1)+")").addClass("active");
		
		this.elemCurrent = this.elem.find("#slide"+num);
		this.nbCurrent = num ;

   },
   
   goNext : function(){
		num  = parseInt(this.nbCurrent) + 1 ;

		if(num> this.nbImg){
		   num = 1 ;
		   }
		   this.slideTo(num);
   },
   
   
   play : function(){
        window.clearInterval(defImage.timer);
		defImage.timer = window.setInterval("defImage.goNext()",3500);
   },
   
   stop : function(){
        window.clearInterval(defImage.timer);
   }




}


$(function(){
defImage.def($("#flash_infos"));
});





