$(document).ready(function(){

  /* Remplacement titre flash */
  $.sifrSettings({path:'font/'});
  $(".bodega").sifr({font:'bodegaSC'});
  $(".volkorn").sifr({font:'volkorn'});
  $("h2.police").sifr({font:'century gothic'});

	/* Comportement Rollover avec class="rollover" */
	$("img.rollover").each(function(){
		attachRollOverEvent(this);
	});

	/* Remplacement image actif avec class="actif" */
	$("img.actif").each( function(){
		attachActif(this);
	});

	/* Fancybox Propriétés */
  $("a.fancy").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true });
  $("a#fenetre").fancybox({ 'overlayShow': true, 'zoomSpeedOut':0, 'zoomSpeedIn':0, 'overlayOpacity': 0.70, 'hideOnContentClick': true });


  animBandeau(1500,1500);

  /* Defilement */
  $("#menuGauche a.appear").bind("click",function(e){
    e.preventDefault();
    $("#menuGauche ul:visible").slideToggle("fast").prev().removeClass("actif");
    $("#menuGauche a.actif").removeClass("actif");
  	 $(this).addClass("actif").next().slideToggle("fast");
  });
  $("#menuGauche a:not(.actif)").next("ul").hide();
  $("#menuGauche li ul li a.actif").parent().parent().show().prev().addClass("actif");


  $("#f_commentaire").bind("submit",function(e){
  	e.preventDefault();
  	info=$(this).serializeArray();
  	$.ajax({
  		url: "ajax_commentaire.php",
  		type: "POST",
  		dataType: "script",
  		data: info,
  		cache: false
  	});
  });

	/* Tableau 1 sur 2 */
	$("#body table tr:even").addClass("even");
	$("#body table tr:odd").addClass("odd");


	
}); /* fin doc ready */


/* ======== Fonctions ========================================================================== */

function animBandeau(speed,between){
	setTimeout(function(){

      $("p#vignettes a:eq(0)").hide(speed,function(){
   		var not="";
   		$("p#vignettes a").each(function(){
   			not=not+"&not[]="+$(this).attr("rel");
   		});

      	$(this).remove();

//      	data= $(this);
      	$.get("photo-aleatoire.php", not, function(data){
			  $("p#vignettes a:last").after(data).next().hide(0).fadeIn(speed);
      	  animBandeau(speed,between);
			});
      });
	},(speed*2)+between);
}

/* Comportement Rollover avec class="rollover" */
attachRollOverEvent = function(imageId){
	$(imageId).mouseover( function(){ $(this).attr("src", $(this).attr("src").replace('.','_roll.')) } );
	$(imageId).mouseout( function(){ $(this).attr("src", $(this).attr("src").replace('_roll','')) } );
}

/* Change image pour les "actif" */
attachActif = function(imageId){
	$(imageId).attr("src", $(imageId).attr("src").replace('.','_roll.'));
}