$(document).ready(function(){


	$('input[name=login]').bind('click',function(){
		if($(this).val()=='courriel')$(this).val('');
	}).bind("blur",function() {
	  if($(this).val()=='')$(this).val('courriel');
  });

	$('input[name=pass]').bind('click',function(){
		if($(this).val()=='mot de passe')$(this).val('');
	}).bind("blur",function() {
	  if($(this).val()=='')$(this).val('mot de passe');
  });

	/* cufon */
	Cufon.replace('.myriad', { fontFamily: 'myriad' });
	Cufon.replace('#body h3', { fontFamily: 'myriad' });
	Cufon.replace('h2.contenu', { fontFamily: 'myriad' });


	/* Comportement Rollover avec class="rollover" */
	$("img.rollover").each(function(){
		attachRollOverEvent(this);
	});

	/* Remplacement image actif avec class="actif" */
	$("img.actif").each( function(){
		attachActif(this);
	});

	$("#printPage").click(function(e){
 		window.print();
 		e.preventDefault();
 	});

 	$("#ad2fav").click(function(e){
 		favoris();
 		e.preventDefault();
 	});

	$(".ad2fav").click(function(e){
 		favoris();
 		e.preventDefault();
 	});

	$('#header').cycle({
    fx:    'fade',
    speed:  2500,
    timeout:  6500
	});

	/* 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 });
	$("a.fancyPasse").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true,'frameWidth': 470,'frameHeight': 220 });

  /* PNG Fix */
  $(document).pngFix();

	$('#colG ul li:not(".actif") a.titre').next().next().hide();

  	$('#colG ul li a.titre').bind("click",function(e) {
		$(this).next().next().toggle('slow').prev().prev().parent().toggleClass("actif");
		e.preventDefault();
	});

			/* Tableau 1 sur 2 */
	$("#body table tr:even").addClass("even");
	$("#body table tr:odd").addClass("odd");


}); /* 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("Communauté de Communes des Avaloirs","http://www.cc-avaloirs.fr",""); }
else { window.external.AddFavorite("http://www.cc-avaloirs.fr","Communauté de Communes des Avaloirs"); } }
