jQuery.fn.defuscate = function( settings ) {
		settings = jQuery.extend({
				link: true,
				find: /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi,
				replace: '$1@$2'
		}, settings);
		return this.each(function() {
				if ( $(this).is('a[@href]') ) {
						$(this).attr('href', $(this).attr('href').replace(settings.find, settings.replace));
						var is_link = true;
				}
				$(this).html($(this).html().replace(settings.find, (settings.link && !is_link ? '<a href="mailto:' + settings.replace + '">' + settings.replace + '</a>' : settings.replace)));
		});
};

var ancienMois;
var id;
var months = new Array('janvier', 'fevrier', 'mars', 'avril', 'mai', 'juin', 'juillet', 'aout', 'septembre', 'octobre', 'novembre', 'decembre');
function hideCalendarContent() {
	$('#calendarContent>*').hide();
}
function loadCalendarContentForMonth(monthNumber){
	if (ancienMois) {
		ancienMois.attr('id', id);
	};
	$('#calendarContent>*').hide();
	$('#calendarContent>h3').each(function(){
		$(this).attr('id', $(this).attr('id'));
	});
	$('#calendarContent #'+months[monthNumber-1]).fadeIn('slow');
	$('#calendarContent #'+months[monthNumber-1]+'+ul').fadeIn('slow');
 	ancienMois = $('#calendarContent #'+months[monthNumber-1]);
	id = ancienMois.attr('id');
	ancienMois.attr('id', ancienMois.attr('id')+'M');
	window.location.hash = months[monthNumber-1];
	// console.log("mois n° : "+monthNumber);
}


$(document).ready(function() {

	var baseURL = $('base').attr('href');
	baseURL = baseURL.replace('http://','');
	baseURL = baseURL.replace('/','');

	if ($('#actualites #calendrier').length) {
		var flashvars = {};
		flashvars.ancre = window.location.hash;
		flashvars.ancre = flashvars.ancre.replace('#','');
		var params = {};
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = "calendrier";
		swfobject.embedSWF(baseURL+"/swf/roueDesMois.swf", "calendrier", "540", "540", "8.0.0", false, flashvars, params, attributes);
	};

	// $('#calendarContent li span').hide();
	// $('#calendarContent li>a').toggle(
	// 	function(){
	// 		$(this).css({'background-image':'url('+baseURL+'/images/puce2_open.png)'}).parent().children('span').slideDown('normal');
	// 		return false;
	// 	},
	// 	function(){
	// 		$(this).css({'background-image':'url('+baseURL+'/images/puce2.png)'}).parent().children('span').slideUp('normal');
	// 		return false;
	// 	}
	// )
	// $(".adresse").defuscate();

	// $.gaTracker('UA-1176780-1');

	// $('body').append('<div id="grille"></div>');

});

