// script issu de : http://sitesweb.abondance.free.fr/copyleft/billet.php?idBillet=38
function byId(a){return document.getElementById(a)}function byTN(a,b){b=b?b:document;return b.getElementsByTagName(a)}String.prototype.trim=function(){var a=this.replace(/^\s+/,'');for(var i=a.length-1;i>=0;i--){if(/\S/.test(a.charAt(i))){a=a.substring(0,i+1);break}}return a};function transfer(a,b){var c,transfered={};for(c in b){transfered[c]=b[c]}for(c in a){transfered[c]=a[c]}return transfered}function setOpacity(a,b){b=(b==1)?0.99999:b;a.style.opacity=b;a.style.filter='alpha(opacity='+b*100+')';a.style.MozOpacity=b;a.style.KhtmlOpacity=b}function easeInOut(a,b,c,d,e){var f=b-a;var g=a+(Math.pow(((1/c)*d),e)*f);return g}function getPos(a){var b={'r':0,'l':0,'t':0,'b':0};var c=a;do{b.l+=c.offsetLeft;c=c.offsetParent}while(c!==null);b.r=b.l+a.offsetWidth;c=a;do{b.t+=c.offsetTop;c=c.offsetParent}while(c!==null);b.b=b.t+a.offsetHeight;return b}function pageDim(){var d=document,dE=d.documentElement,dB=d.body,w,h;h=dE.scrollHeight;w=dE.scrollWidth;if(dE.clientHeight>h){h=dE.clientHeight}if(dE.clientWidth>w){w=dE.clientWidth}if(dB.scrollHeight>h){h=dB.scrollHeight}if(dB.scrollWidth>w){w=dB.scrollWidth}return{'w':w,'h':h}}function scrolled(){var x,y;if(window.pageXOffset!==undefined){x=window.pageXOffset;y=window.pageYOffset}else{x=document.documentElement.scrollLeft?document.documentElement.scrollLeft:(document.body.scrollLeft?document.body.scrollLeft:0);y=document.documentElement.scrollTop?document.documentElement.scrollTop:(document.body.scrollTop?document.body.scrollTop:0)}return{'x':x,'y':y}}function winDim(){var w,h;if(window.innerWidth){w=window.innerWidth;h=window.innerHeight}else if(document.documentElement.clientWidth){w=document.documentElement.clientWidth;h=document.documentElement.clientHeight}else if(document.body.clientWidth){w=document.body.clientWidth;h=document.body.clientHeight}else{alert("winDim() n'est pas parvenu à lire les dimentions de la fenêtre")}return{'w':w,'h':h}}function Animate(d,e){this.defSettings={"elem":window.document.body,"from":{},"to":{},"restart":false,"ease":1,"duration":1000,"frameRate":30,"onFinish":false};this.defSettings=transfer(d,this.defSettings);this.guessProp=function(a){var b=this.options.elem;switch(a){case'width':return b.offsetWidth+'px';case'height':return b.offsetHeight+'px';case'top':return(typeof(getPos)=='undefined')?'0px':getPos(b,'t')+'px';case'bottom':return(typeof(getPos)=='undefined')?'0px':getPos(b,'b')+'px';case'left':return(typeof(getPos)=='undefined')?'0px':getPos(b,'l')+'px';case'right':return(typeof(getPos)=='undefined')?'0px':getPos(b,'r')+'px';case'borderWidth':return'1px';case'borderColor':return'rgb(0,0,0)';case'backgroundColor':return'rgb(255,255,255)';case'color':return'rgb(0,0,0)';case'opacity':return 1;default:return 0}return false};this.readProp=function(a){var b={};b.asked=a+'';b.unit=b.asked.match(/px|em|%/);b.clean=parseFloat(b.asked);var c=b.asked.match(/rgb|(#[a-f0-9]{3,6})/i);if(typeof rgbString2Array=='function'&&typeof sharp2rgb=='function'&&c){b.clean=b.asked;b.rgb=rgbString2Array(sharp2rgb(b.asked));if(!b.rgb){b.rgb=rgbString2Array(b.asked)}}return b};this.readFromTo=function(a){if(!a){return false}var i,lg,tmp,prop,eachDeclared={};if(typeof a=='string'){a=a.trim();var b=a.split(/;/);lg=b.length;for(i=0;i<lg;i++){if(!b[i]){b.splice(i,1)}}lg=b.length;a={};for(i=0;i<lg;i++){tmp=b[i].split(/:/);prop=tmp[0].trim();a[prop]=tmp[1].trim()}}for(prop in a){eachDeclared[prop]=this.readProp(a[prop]+'')}return eachDeclared};this.go=function(a){var b,prop;this.options=transfer(a?a:{},this.defSettings);var c=this.options.elem.style;this.totalFrames=Math.ceil(this.options.duration/1000*this.options.frameRate);if(this.options.restart){this.frameNb=0}else{this.frameNb=this.framesLeft?this.framesLeft:0}this.from=this.readFromTo(this.options.from?this.options.from:this.defSettings.from);this.to=this.readFromTo(this.options.to?this.options.to:this.defSettings.to);for(prop in this.to){if(!this.from[prop]){if(c[prop]||c[prop]===0){this.from[prop]=this.readProp(c[prop])}if(!this.from[prop]){this.from[prop]=this.readProp(this.guessProp(prop))}}}for(prop in this.from){c[prop]=this.from[prop].clean}this.next()};this.frame=function(){var a=this.options.elem.style;var c,coulFrom,coulTo,prop;for(prop in this.to){if(this.to[prop].rgb){coulTo=this.to[prop].rgb;coulFrom=this.from[prop].rgb;var r=easeInOut(parseInt(coulFrom[0],10),parseInt(coulTo[0],10),this.totalFrames,this.frameNb,this.options.ease);var g=easeInOut(parseInt(coulFrom[1],10),parseInt(coulTo[1],10),this.totalFrames,this.frameNb,this.options.ease);var b=easeInOut(parseInt(coulFrom[2],10),parseInt(coulTo[2],10),this.totalFrames,this.frameNb,this.options.ease);a[prop]='rgb('+Math.round(r)+','+Math.round(g)+','+Math.round(b)+')'}else{c=easeInOut(this.from[prop].clean,this.to[prop].clean,this.totalFrames,this.frameNb,this.options.ease);if(this.to[prop].units==='px'){c=parseInt(c,10)}a[prop]=c+this.to[prop].unit;if(prop==='opacity'&&typeof setOpacity=='function'){setOpacity(this.options.elem,c)}}}if(this.frameNb===this.totalFrames){if(typeof this.options.onFinish=='function'){setTimeout(this.options.onFinish,1)}}else{this.frameNb++;this.framesLeft=this.totalFrames-this.frameNb;this.next()}};this.next=function(){this.prog=setTimeout(function(){f.frame()},1000/this.options.frameRate)};this.pause=function(){clearTimeout(this.prog)};var f=this;if(e){this.go(typeof e=='object'?e:{})}}var imZoom={gal:[],defaultOpt:{screenColor:'#fff',screenOpacity:0.6,zIndex:1000,openDuration:500,changeDuration:150,frameRate:25,animEase:2,onOpen:0,onChange:0,onClose:0,showNav:1,showTitle:1,prevTxt:'&lt;&lt;',nextTxt:'&gt;&gt;',playTxt:'diaporama',pauseTxt:'pause',slideDelay:4000,autoPlay:0,preloaderUrl:'loading.gif',margins:30},applyTo:function(a,b){if(!a.length){a=[a]}this.gal=a;var c=a.length,i;for(i=0;i<c;i++){a[i].onclick=function(){imZoom.go(this,b);return false}}},autoApplyInto:function(a,b){var c=byTN('a',b);var d=c.length;var i,n=0;var e=[];for(i=0;i<d;i++){if(/\.(jpe?g|gif|png|tiff?)/i.test(c[i].href)){e[n]=c[i];n++}}imZoom.applyTo(e,a)},goTo:function(n){n=n>this.gal.length-1?0:(n<0?this.gal.length-1:n);this.active=n;this.go(this.gal[n])},progImg:function(a){a=a===undefined?imZoom.active+1:a;imZoom.prog=setTimeout(function(){imZoom.goTo(a)},imZoom.options.slideDelay)},play:function(){if(!imZoom.prog){this.progImg();byId('izPlay').style.display='none';byId('izPause').style.display=''}},pause:function(){clearTimeout(imZoom.prog);imZoom.prog=0;byId('izPause').style.display='none';byId('izPlay').style.display=''},callback:function(a){if(typeof imZoom.options[a]==='function'&&byId('izImg')){imZoom.options[a]()}},change:function(){this.animCont.go({from:{opacity:1},to:{opacity:0},onFinish:function(){var b=byId('izImg');if(b){b.onload=function(){imZoom.setPos();var a=byId('izTitle');if(a&&imZoom.options.showTitle){a.innerHTML=imZoom.gal[imZoom.active].title}imZoom.animCont.go({to:{opacity:1},onFinish:function(){imZoom.callback('onChange');if(imZoom.prog){clearTimeout(imZoom.prog);imZoom.prog=0;imZoom.progImg()}}})};b.src=imZoom.gal[imZoom.active].href}}})},go:function(a,b){var i=0,opt;var c;var d;var f;var g=byId('izCont');if(!g){b=typeof b==='object'?b:{};for(opt in this.defaultOpt){if(typeof b[opt]==='undefined'){b[opt]=this.defaultOpt[opt]}}this.options=b;while(this.gal[i]!==a&&i<this.gal.length){i++}this.active=i}b=this.options;c=a.firstChild.nodeType===3?a:a.firstChild;d=byTN("body")[0].appendChild(document.createElement("img"));d.id='izLoading';d.src=b.preloaderUrl;d.style.position='absolute';d.style.zIndex=b.zIndex;f=g?g:c;d.style.top=(f.offsetHeight-d.offsetHeight)/2+getPos(f).t+'px';d.style.left=(f.offsetWidth-d.offsetWidth)/2+getPos(f).l+'px';this.actionner=a;this.area=c;if(this.xhr){this.xhr.abort()}this.xhr=null;if(window.XMLHttpRequest){this.xhr=new XMLHttpRequest()}else if(window.ActiveXObject){try{this.xhr=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){this.xhr=new ActiveXObject("Microsoft.XMLHTTP")}}else{this.xhr=false;alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...")}this.xhr.onreadystatechange=function(){if(imZoom.xhr.readyState===4){byTN("body")[0].removeChild(byId(d.id));if(!byId('izCont')){imZoom.open()}else{imZoom.change()}}};this.xhr.open('GET',this.actionner.href,true);this.xhr.send(null);d.onclick=function(){imZoom.close()}},setPos:function(){var a=byId('izCont');if(a){var b=byId('izScreen');var c=byId('izMeta');var d=byId('izImg');var e=scrolled();var f=winDim();var g=pageDim();var h=imZoom.options;var i;b.style.width=g.w+'px';b.style.height=g.h+'px';a.style.width=f.w-(h.margins*2)+'px';a.style.height=f.h-(h.margins*2)-c.offsetHeight+'px';a.style.top=h.margins+e.y+'px';a.style.left=h.margins+e.x+'px';i=getPos(d);c.style.top=i.b+'px';c.style.width=d.offsetWidth+'px';c.style.left=i.l+'px'}},close:function(){var a=byTN("body")[0];var b=byId('izMeta');var c=byId('izCont');imZoom.xhr.abort();if(imZoom.prog){imZoom.pause()}if(b){a.removeChild(b)}a.removeChild(byId('izScreen'));c.style.display='none';imZoom.callback('onClose');a.removeChild(c)},open:function(){if(!byId('izCont')){var a=scrolled();var b=winDim();var c=pageDim();var d=imZoom.options;var e=byTN("body")[0];var f=getPos(this.area);var g;var h;var i;var j;var k;g=e.appendChild(document.createElement("div"));g.id='izScreen';g.style.position='absolute';g.style.backgroundColor=d.screenColor;g.style.top='0px';g.style.left='0px';g.style.width=c.w+'px';g.style.height=c.h+'px';g.onclick=this.close;g.style.zIndex=d.zIndex;i=e.appendChild(document.createElement("div"));i.id='izCont';i.style.position='absolute';i.style.textAlign='center';i.style.width='100%';i.onclick=this.close;i.style.zIndex=d.zIndex;j=byId('izCont').appendChild(document.createElement("img"));j.id='izImg';j.src=this.actionner.href;j.style.height='100%';h=e.appendChild(document.createElement("div"));h.id='izMeta';h.style.display='none';h.style.position='absolute';h.style.zIndex=d.zIndex;if(d.showTitle){h.innerHTML='<span id="izTitle">'+this.gal[this.active].title+'</span>'}if(d.showNav&&this.gal.length>1){h.innerHTML+=''+'<span id="izNav">'+' <a href="#" id="izPrev" onclick="imZoom.goTo(imZoom.active-1);return false;">'+d.prevTxt+'</a>'+' <a href="#" id="izPlay" onclick="imZoom.play();return false;">'+d.playTxt+'</a>'+' <a href="#" id="izPause" style="display:none;" onclick="imZoom.pause();return false;">'+d.pauseTxt+'</a>'+' <a href="#" id="izNext" onclick="imZoom.goTo(imZoom.active+1);return false;">'+d.nextTxt+'</a>'+'</span>'}k=new Animate({elem:g,to:{opacity:d.screenOpacity},from:{opacity:0},duration:d.openDuration,ease:d.animEase,frameRate:d.frameRate},1);this.animCont=new Animate({elem:i,duration:d.changeDuration,ease:d.animEase,frameRate:d.frameRate});this.animCont.go({duration:d.openDuration,to:{width:b.w-(d.margins*2)+'px',height:b.h-(d.margins*2)+'px',top:d.margins+a.y+'px',left:d.margins+a.x+'px'},from:{width:this.area.offsetWidth+'px',height:this.area.offsetHeight+'px',top:f.t+'px',left:f.l+'px'},onFinish:function(){imZoom.setPos();if((d.showNav||d.showTitle)&&byId('izMeta')){byId('izMeta').style.display=''}if(imZoom.options.autoPlay){imZoom.play()}imZoom.callback('onOpen')}})}}};if(window.attachEvent){window.attachEvent('onresize',imZoom.setPos);window.attachEvent('onscroll',imZoom.setPos)}else{window.addEventListener('resize',imZoom.setPos,false);window.addEventListener('scroll',imZoom.setPos,false)}