$(document).ready(function(){

   /* cufon */
//	Cufon.replace('.bauhaus', { fontFamily: 'bauhaus' });
//	Cufon.replace('.bauhausl', { fontFamily: 'bahaussl' });
//	Cufon.replace('.din', { fontFamily: 'din' });

	/* 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.fancy360").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': false,'padding': 0,'autoDimensions': true });
  $("a#fenetre").fancybox({ 'overlayShow': true, 'zoomSpeedOut':0, 'zoomSpeedIn':0, 'overlayOpacity': 0.70, 'hideOnContentClick': true });

  /* PNG Fix */
  $(document).pngFix();

  $("#media .rollme").each(function(i,e){
	  $(e).addClass('cursor');
	  $(e).click(function(){
		  $("#big a").eq(i).click();
	  });
	  $(e).hover(function(){
		  //console.log(''+i);
		  $("#big a img").hide(0,function(){
			   $("#big a").eq(''+i).find("img").show();
		  });
	  },function(){});
  });

  $('#defile').cycle({
    fx:    'fade',
    speed:  2500,
    timeout:  4000
	});

	/* comportement fiche produit */

	$("#miniatures #contentMin img").mouseover(function(event) {
		var name = $("#miniatures #contentMin img").index(this);
		$("#offProd").hide();
		$('#affichage img:first').hide();
		$('#affichage img').eq(name).show();
	});

	$("#miniatures .ligne img").mouseout(function(event) {
		$('#affichage img').hide();
		$('#affichage img:first').show();
	});


}); /* fin doc ready */

$(document).ajaxSuccess(function() {
	Cufon.refresh();
});

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

/* 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.'));
}

/* Impression des documents */
function imprimer(){
	if(window.print) window.print();
	else alert("Désolé mais votre navigateur ne supporte pas cette fonctionnalité. Pour la plupart des navigateurs, vous pouvez imprimer cette page  en allant dans le menu 'Fichier' > 'Imprimer'");
}

/* Ajouter aux favoris */

function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("le nom du site","http://www.tonsite.com",""); }
else { window.external.AddFavorite("http://www.tonsite.com","le nom du site"); } }

function loadAnnonce(id,lang){
	$("#loadAnnonce").load("a_annonces.php",{annonce: id, lang: lang});
}
