/*
   ========================================================
        script: image-flow
        author: Gerard Ferrandez - [Ge1doot]
          date: March 15, 2008
           maj: May 24, 2008 - AJAXification bank images
           maj: Jan 18, 2010 - fixed thumbs vibrations
          site: http://www.dhteumeuleu.com
       license: CC-BY-NC - do not remove this notice
   ========================================================
*/
var imf=function(){function h(c,b,a){for(var c=c.getElementsByTagName(b),b=0,d=c.length,e=[];b<d;b++)c[b].className==a&&e.push(c[b]);e.length==1&&(e=e[0]);return e}function j(c,b,a){window.addEventListener?c.addEventListener(b,a,!1):window.attachEvent&&(r=c.attachEvent("on"+b,a))}function l(c,b,a,d,e,g,f,j){this.diapos=[];this.scr=!1;this.size=d;this.zoom=e;this.horizon=a;this.bdw=g;this.oCont=c;this.oc=document.getElementById(c);this.scrollbar=h(this.oc,"div","scrollbar");this.text=h(this.oc,"div", "text");this.title=h(this.text,"div","title");this.legend=h(this.text,"div","legend");this.bar=h(this.oc,"img","bar");this.arL=h(this.oc,"img","arrow-left");this.arR=h(this.oc,"img","arrow-right");this.bw=this.bar.width;this.alw=this.arL.width-5;this.arw=this.arR.width-5;this.bar.parent=this.oc.parent=this;this.arL.parent=this.arR.parent=this;this.view=this.back=-1;this.time_start=f*62.5||0;this.time_inter=j*62.5||0;this.time_out=this.time_start;this.time=0;this.time_dir=1;this.resize();this.oc.onselectstart= function(){return!1};c=k(b).responseXML.getElementsByTagName("bank").item(0).getElementsByTagName("img");this.NF=c.length;for(b=0;b<this.NF;b++){var i=c.item(b),a=function(a){a=i.getElementsByTagName(a);return a.length&&a[0].firstChild?a[0].firstChild.nodeValue:""};this.diapos[b]=new Diapo(this,b,a("src"),a("title"),a("caption"),a("link"),a("target")||"_self")}window.addEventListener&&this.oc.addEventListener("DOMMouseScroll",function(a){a.preventDefault&&a.preventDefault();this.parent.scroll(-a.detail); return!1},!1);this.oc.onmousewheel=function(){this.parent.scroll(event.wheelDelta);return!1};this.bar.onmousedown=function(a){if(!a)a=window.event;var c=a.screenX-this.offsetLeft,b=this.parent;this.parent.oc.onmousemove=function(a){if(!a)a=window.event;b.bar.style.left=Math.round(Math.min(b.ws-b.arw-b.bw,Math.max(b.alw,a.screenX-c)))+"px";b.view=Math.round((a.screenX-c)/(b.ws-b.alw-b.arw-b.bw)*(b.NF-1));b.view!=b.back&&b.calc();return!1};this.parent.oc.onmouseup=function(){b.oc.onmousemove=null;return!1}; return!1};this.arR.onclick=this.arR.ondblclick=function(){this.parent.view<this.parent.NF-1&&this.parent.calc(1)};this.arL.onclick=this.arL.ondblclick=function(){this.parent.view>0&&this.parent.calc(-1)}}var f=[],k=function(c){return function(b){var a=c();a.open("GET",b,!1);a.send("");return a}}(this.XMLHttpRequest?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")});l.prototype={calc:function(c){if(c)this.view+=c,this.time=0,this.time_out=this.time_start; var b=c=0,a=this.diapos[this.view];if(a&&a.loaded){var d=this.diapos[this.back];if(d&&d!=a)d.img.className="diapo",d.z1=1;this.title.innerHTML=a.title;this.legend.innerHTML=a.text;a.url?(a.img.className="diapo link",window.status="hyperlink: "+a.url):(a.img.className="diapo",window.status="");a.w1=a.r<1?Math.min(a.iw,this.wh*0.8,Math.round(this.ht*this.horizon/a.r))*a.z1:Math.round(this.ht*this.horizon/a.r)*a.z1;for(var d=a.x1=this.wh*0.5-a.w1*0.5,e=d+a.w1+this.bdw,g=this.view+1;a=this.diapos[g];g++)if(a.loaded)a.x1= e,a.w1=this.ht/a.r*this.size,e+=a.w1+this.bdw,c+=a.w1+this.bdw;e=d-this.bdw;for(g=this.view-1;a=this.diapos[g];g--)if(a.loaded)a.w1=this.ht/a.r*this.size,a.x1=e-a.w1,e-=a.w1+this.bdw,c+=a.w1+this.bdw,b+=a.w1+this.bdw;if(!this.scr&&c)this.bar.style.left=Math.round(this.alw+b*((this.ws-this.alw-this.arw-this.bw)/c))+"px";this.back=this.view}},scroll:function(c){c<0?this.view<this.NF-1&&this.calc(1):this.view>0&&this.calc(-1)},resize:function(){this.wh=this.oc.clientWidth;this.ht=this.oc.clientHeight; this.ws=this.scrollbar.offsetWidth;this.calc();this.run(!0)},run:function(c){for(var b=this.NF;b--;)this.diapos[b].move(c);if(this.time_out&&(this.time++,this.time>this.time_out)){this.view+=this.time_dir;if(this.view>=this.NF||this.view<0)this.time_dir=-this.time_dir,this.view+=this.time_dir*2;this.calc();this.time=0;this.time_out=this.time_inter}}};Diapo=function(c,b,a,d,e,g,f){this.parent=c;this.loaded=!1;this.title=d;this.text=e;this.url=g;this.target=f;this.N=b;this.img=document.createElement("img"); this.img.src=a;this.img.parent=this;this.img.className="diapo";this.x1=this.x0=this.parent.oc.clientWidth;this.w1=this.w0=0;this.z1=1;this.z2=0;this.img.parent=this;this.img.onclick=function(){this.parent.click()};this.parent.oc.appendChild(this.img);if(g)this.img.onmouseover=function(){this.className="diapo link"},this.img.onmouseout=function(){this.className="diapo"}};Diapo.prototype={move:function(c){var b=this.parent;if(this.loaded){var a=this.x1-this.x0,d=this.w1-this.w0;if(Math.abs(a)>2||Math.abs(d)> 2||c)if(this.x0+=a*0.1,this.w0+=d*0.1,c=this.w0*this.r,this.z2=(b.ht*b.horizon+1-this.z2-c)*0.5,this.x0<b.wh&&this.x0+this.w0>0){if(this.visible=!0,a=this.img.style,a.left=Math.round(this.x0)+"px",a.bottom=Math.floor(b.ht*(1-b.horizon)+this.z2)+"px",a.width=Math.round(this.w0)+"px",a.height=Math.floor(c)+"px",this.flx)a=this.flx.style,a.left=Math.round(this.x0)+"px",a.top=Math.ceil(b.ht*b.horizon+1-this.z2)+"px",a.width=Math.round(this.w0)+"px",a.height=Math.floor(c)+"px"}else if(this.visible&&(this.visible= !1,this.img.style.width="0px",this.flx))this.flx.style.width="0px"}else if(this.img.complete&&this.img.width){this.iw=this.img.width;this.ih=this.img.height;this.r=this.ih/this.iw;this.loaded=!0;c=b.oc;a=this.img;d=!1;if(document.createElement("canvas").getContext){d=document.createElement("canvas");d.width=a.width;d.height=a.height;var e=d.getContext("2d");e.translate(0,a.height);e.scale(1,-1);e.drawImage(a,0,0,a.width,a.height);d.style.opacity="0.35"}else d=document.createElement("img"),d.src=a.src, d.style.filter="flipv progid:DXImageTransform.Microsoft.Alpha(opacity=50, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy="+a.height*0.25+")";d.style.position="absolute";d.style.left="-4000px";c.appendChild(d);this.flx=d;if(b.view<0)b.view=this.N;else if(this.N==0)b.view=this.N;b.calc()}},click:function(){this.parent.time=0;this.parent.time_out=this.parent.time_start;this.parent.view==this.N?this.url?window.open(this.url,this.target):(this.z1=this.z1==1?this.parent.zoom:1,this.parent.calc()): (this.parent.view=this.N,this.parent.calc());return!1}};return{create:function(c,b,a,d,e,g,h,k){var i=function(){for(var i=!1,m=f.length;m--;)f[m].oCont==c&&(i=!0);if(!i&&(f.push(new l(c,b,a,d,e,g,h,k)),!imf.initialized))imf.initialized=!0,j(window,"resize",function(){for(var a=f.length;a--;)f[a].resize()}),j(document.getElementById(c),"mouseout",function(a){if(!a)a=window.event;if((a=a.relatedTarget||a.toElement)&&a.tagName=="HTML")for(a=f.length;a--;)f[a].oc.onmousemove=null;return!1}),setInterval(function(){for(var a= f.length;a--;)f[a].run()},16)};j(window,"load",function(){i()})}}}();imf.create("imageFlow","image-flow.xml",0.75,0.15,1.8,10,8,4);

