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)));
    });
};
jQuery.fn.image = function(src, f){
	return this.each(function(){
		var i = new Image();
		i.src = src;
		i.onload = f;
		this.appendChild(i);
	});
} 

$(document).ready(function(){

	$('#resteVide').hide();

	$("#grandeImage").css('height', '400px');
	$('#vignettes li a').click(function() {
		var imgName = $(this).attr('href').replace('projet/', 'projet/thumb_');
		$("#grandeImage").fadeTo('fast', 0.01, function() {
			$("#grandeImage").html('');
			$("#grandeImage").parent().children("h3").after('<img style="position:absolute;margin-top:370px;margin-left:0px;" id="loadingAnimation" src="/images/ajax-loader.gif" alt="loading" />');
			$("#loadingAnimation").hide().fadeIn('slow');
			$("#grandeImage").image(imgName,function(){
				$("#loadingAnimation").remove();
				$("#grandeImage").fadeTo('slow', 1);
			});
		});
				return false;
	});
	
	/*$('.thickbox').click(
	function()
	{
		var legende=$(this).parent().children("p").html();
		$("#TB_window").append(legende);
		
		return false;
	});*/
	/*
	$("#photosListe").css({height:500});
	$("#photosListe>li>a").hide();
	$("#photosListe>li>h3").hide();
	$("#photosListe>li>p").hide();
	$("#photosListe>li").addClass("vignette");
	
	var premierClic=1;
	var contenu="";
	var endroit="";
	
	var dernier="";
	dernier=$("#photosListe li:last-child").attr("id");
	dernier=dernier.substring(8, dernier.length);
	dernier=parseInt(dernier);
	
	$(".vignette").click(
	function()
	{
		contenu=$(this).html();
		
		image=$(this).attr("style");
		
		endroit=$(this).attr("id");
		endroit=endroit.substring(8, endroit.length);
		endroit=parseInt(endroit);
		endroit=Math.floor((endroit-1)/4)*4+4;
		
		if(endroit>dernier)
		{
			endroit=dernier;
		}
		
		endroit=endroit.toString();
		
		if(premierClic==1)
		{
			$("#vignette"+endroit).after('<li id="contenu">'+contenu+'</li><div style="clear:both"></div>');
			$("#contenu>a").css({width:180, border:0, marginBottom:10, overflow:"hidden"});
			$("#contenu>h3").css({width:560, marginLeft:10});
			$("#contenu>p").css({width:560, marginLeft:10, marginBottom:10});
			$("#contenu").slideUp();
			$("#contenu>a").show();
			$("#contenu>h3").show();
			$("#contenu>p").show();
			$("#contenu").slideDown("slow");
			
			premierClic=0;
		}
		
		else
		{
			$("#contenu").slideUp("slow",
			function()
			{
				$("#contenu").remove();
				$("#vignette"+endroit).after('<li id="contenu">'+contenu+'</li>');
				$("#contenu>a").css({width:180, border:0, marginBottom:10, overflow:"hidden"});
				$("#contenu>h3").css({width:560, marginLeft:10});
				$("#contenu>p").css({width:560, marginLeft:10, marginBottom:10});
				$("#contenu").slideUp();
				$("#contenu>a").show();
				$("#contenu>h3").show();
				$("#contenu>p").show();
				$("#contenu").slideDown("slow");
			});
		}
	});
	*/
	
//if(!$.browser.safari || jQuery.browser.version > 524){
  $(".adresse").defuscate();
//}

  $.gaTracker('UA-9461288-1');

});
