$(document).ready(function(){

   /* cufon */
	Cufon.replace('.calibri', { fontFamily: 'calibri' });

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

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

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


  /*$('.decRouge a').hover(function(){
		$(this).find('img').attr("src", $(this).find('img').attr("src"));
	},function(){
		$(this).find('img').attr("src", $(this).find('img').attr("src").replace('_roll',''));
	});*/

	/* comportement vign rouge*/
	$(".decRouge a:not('.actif'):has('img')").each(function(i){
		window['rollr'+i] = $('.decRouge a:not(".actif"):has("img")').find('img').eq(i).attr('src');
		ImgRollover(this,i,window['rollr'+i],"img/accueil/rollRouge.jpg");
	});

	$(".decRouge a.actif").each(function(){
		ImgActif(this,"img/accueil/rollRouge.jpg");
	});

	/* comportement vign verte*/
	$(".decVert a:not('.actif'):has('img')").each(function(i){
		window['rollv'+i] = $('.decVert a:not(".actif"):has("img")').find('img').eq(i).attr('src');
		ImgRollover(this,i,window['rollv'+i],"img/accueil/rollVert.jpg");
	});

	$(".decVert a.actif").each(function(){
		ImgActif(this,"img/accueil/rollVert.jpg");
	});

	/* Gestion affichage menu */
  	$('#menuPrincipal li:not({".geoloc", ".actif"}) a.titre').next().hide();
  	$('#menuPrincipal li:not({".geoloc"}) a.titre').bind("click",function(e) {
		$(this).next().toggle('slow').prev().toggleClass("actif").parent().toggleClass("actif");
		e.preventDefault();
	});



	/* annuaire */
	$('#annuaire a.titre').next().toggle();
	$('#annuaire div.develop').hide();
	$('#annuaire a.titre').bind("click",function(e) {
		$(this).next().toggle('slow');
		e.preventDefault();
	});




}); /* fin doc ready */


/* ======== 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"); } }

ImgRollover = function(imageId,i,orig,src){
	$(imageId).mouseover( function(){ $(this).find("img").attr("src", src); } );
	$(imageId).mouseout( function(){ $(this).find("img").attr("src", orig); } );
}

ImgActif = function(imageId,src){
	$(imageId).find("img").attr("src", src);
}
