// ©2008 Max Barel a_x@ac-mb.info

$(function(){diapos=$('.dia img');diapos.eq(0).attr('src','')[0].ix=0;diaporama_croise();diapos.eq(0).attr('src',f_diapos[0]);diapos.eq(1).hide().attr('src',f_diapos[1])[0].ix=1;$('#ecran').toggle(function(){diapos.dia_init().delay_clear()},diaporama_croise);});var diapos,info
t_stable=3500,t_fondu=1000;function diaporama_croise(){diapos.dia_init(t_stable,croise_on,croise_off).eq(0).dia_top();}
function croise_on(){this.dim=img_dim(this);$(this)[(document.body.offsetWidth/document.body.offsetHeight>this.dim.width/this.dim.height)?'addClass':'removeClass']('large').fadeIn(t_fondu);set_ti_photo(f_diapos[this.ix]);}
function croise_off(){var self=this,dia_0=this.id=='dia_0';diapos.eq(dia_0*1).dia_top();dia_0||$(this).fadeOut(t_fondu);$(this).delay(function(){self.ix=tirage(f_diapos);self.top=false;self.src='';self.src=f_diapos[self.ix];},t_fondu*1.1);}
$.fn.dia_init=function(t_on,f_on,f_off){return this.each(function(){var self=this,$this=$(this);this.top=this.top!==undefined;this.f_on=f_on;this.f_off=f_off;$this.delay_init(t_on);$this.unbind('load.diapo')
f_on&&$this.bind('load.diapo',$this.dia_top);});};$.fn.dia_top=function(){return(this.jquery?this:$(this)).each(function(){var self=this;if(this.top){this.f_on&&this.f_on();this.f_off&&$(this).delay(function(){self.f_off()});}else this.top=true;});};function set_ti_photo(path){var texte=path.replace(/.*\/[0-9]*_?(.*)\.jpg/,'$1').replace(/_/g,' ');if($.browser.msie)$('#ti_photo').text(texte);else $('#ti_photo').fadeOut(function(){$(this).text(texte)}).fadeIn();}
function tirage(table){var ix=Math.floor(Math.random()*table.length);while(tirage.crible[ix]&&tirage.n_crible<table.length)ix=(ix+1)%table.length;tirage.crible[ix]=true;tirage.n_crible++;if(tirage.n_crible>=table.length){tirage.crible=[];tirage.n_crible=0;}
return ix;}
tirage.crible=[true,true];tirage.n_crible=tirage.crible.length;
