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

$(document).ready(function(){
	
	if ($('html').attr('lang') == 'fr') {
		langue = 'fr';
	} else if ($('html').attr('lang') == 'nl') {
		langue = 'nl';
	} else {
		langue = 'en';
	}
	
	// Galerie de type "diaporama"
	$("#diaporama").innerfade(
	{
		speed: 3000,
		timeout: 4000,
		type: 'random',
		containerheight: '150px'
	});
	
	// Galerie de type "numerotée"
	$("#numerotee").css({height:'150px'}).after('<p id="numerotation"></p>').children().css({position:'absolute'}).hide().each(
		function(i)
		{
			id = i + 1;
			titre = $(this).children('a').children('img').attr('alt');
			$(this).attr('id', 'photo-'+id);
			$("#numerotation").append('<a id="#lien-'+id+'" href="#photo-'+id+'" title="Show '+titre+'">'+id+'</a>');
		}
	)
	.first().show();
	
	$("#numerotation").children().click(
		function()
		{
			id = $(this).attr('id').substring(6);
			if($(this).attr('class')!='actif')
			{
				$("#numerotation").children().removeClass('actif');
				$(this).removeAttr('href').addClass('actif');
				$("#numerotee").children().fadeOut('normal');
				$('#photo-'+id).fadeIn('normal');
			}
		}
	).first().addClass('actif');
	
	// Diaporama Page d'accueil
    $("#diapos").innerfade({
      speed: 1500,
      timeout: 4000,
      position: 'absolute',
      containerheight: '230px'
    });
  //}

	
	$('a.fancybox').fancybox({
		//'titlePosition':'over'
	 });
	
	$('.adresse').defuscate();

	$.ga.load('UA-19798781-1'); // Google Analytics nouvelle formule
	
});

