(function(A){if(!A){throw new Error("This Script requires jQuery 1.0 or higher!");}A.fn.imageFlow=function(G){G=A.extend({reflectionP:0.25,focus:3,sliderWidth:14,imagesCursor:"pointer",sliderCursor:"default",imageFlowSelector:".imageFlow",loadingSelector:".imageFlow .loading",imagesSelector:".imageFlow .images",captionsSelector:".captions",scrollbarSelector:".imageFlow .scrollbar",sliderSelector:".imageFlow .slider",autoPlay:false,autoPlayInterval:2500},G);var R=0;var U=0;var V=0;var e=0;var T=0;var X=0;var f=0;var J=0;var P=0;var Z=0;var W=false;var B=null;var c=0;var Y=0;var D=0;var M=100;var C=false;var a=0;function K(){switch(f<X-1||f>X+1){case true:S(X+(f-X)/3);if(!P){P=window.setInterval(K,50);}break;default:if(P){window.clearInterval(P);P=0;}break;}}function b(h){var i=imgDiv.children().eq(h);var g=i.data("xPos");f=g;J=g;K();e=h;caption=i.attr("alt");if(caption==""){caption="&nbsp;";}captionDiv.attr("innerHTML",caption);if(W==false){Z=(scrollbarWidth*(-(g*100/((a-1)*M)))/100)-D;sliderDiv.css("marginLeft",(Z-G.sliderWidth)+"px");}}function S(p){X=p;var n=a;for(var l=0;l<a;l++){var j=imgDiv.children().eq(l);var k=l*-M;if((k+maxConfFocus)<J||(k-maxConfFocus)>J){j.css({visibility:"hidden",display:"none"});}else{var m=Math.sqrt(10000+p*p)+100;var g=p/m*size+size;j.css("display","block");var h=0;var q=Math.round((j.data("h")/j.data("w")*j.data("pc"))/m*size);switch(q>maxHeight){case false:h=Math.round(j.data("pc")/m*size);break;default:q=Math.round(maxHeight);h=Math.round(j.data("w")*q/j.data("h"));break;}var o=Math.round(imagesWidth*0.25-q)+imagesTop+((q/(G.reflectionP+1))*G.reflectionP);var i=Math.round(g-(j.data("pc")/2)/m*size+imagesLeft);j.css("left",i);if(h&&q){j.css({height:q+"px",width:h+"px",top:o+"px"});}j.css("visibility","visible");switch(p<0){case true:n++;break;default:n=n-1;break;}switch(j.data("i")==e){case false:j.unbind("click").click(Q);break;default:n++;j.unbind("click").click(L);break;}j.css("zIndex",n);}p+=M;}}function I(k){imageFlowDiv=A(G.imageFlowSelector);imgDiv=A(G.imagesSelector);scrollbarDiv=A(G.scrollbarSelector);sliderDiv=A(G.sliderSelector);captionDiv=A(G.captionsSelector);a=imgDiv.children("img").length;imagesWidth=imgDiv[0].offsetWidth;imagesTop=imageFlowDiv[0].offsetTop;imagesLeft=imageFlowDiv[0].offsetLeft;maxConfFocus=G.focus*M;size=imagesWidth*0.5;scrollbarWidth=imagesWidth*0.6;G.sliderWidth=G.sliderWidth*0.5;maxHeight=imagesWidth*0.51;U=e;imgDiv.css("height",imagesWidth*0.338+"px");sliderDiv.unbind("mousedown").mousedown(function(){dragStart(this);});sliderDiv.css("cursor",G.sliderCursor);var h=0;for(var g=0;g<a;g++){var j=imgDiv.children("img").eq(g);if(j.attr("nodeType")==1){j.click(Q);j.data("url",j.attr("longdesc"));j.data("xPos",(-h*M));j.data("i",h);if(k==true){j.data("w",j.width());j.data("h",j.height());}switch((j.data("w")+1)>(j.data("h")/(G.reflectionP+1))){case true:j.data("pc",202);break;default:j.data("pc",200);break;}j.unbind("dblclick").dblclick(L);j.css("cursor",G.imagesCursor);h++;}}if(G.autoPlay){H();}S(X);b(e);}function Q(){N();b(A(this).data("i"));}function L(){N();var g=A(this).data("url");if(!g){console.info("sorry no url!");return ;}window.open(g);}function d(h){var g=A(h);g.css("visibility","visible");}function O(h){var g=A(h);g.css({visibility:"hidden",display:"none"});}function F(){if(U+1>=a){U=-1;}b(++U);}function E(){if(U-1<0){U=a;}b(--U);}function H(){if(V){return ;}V=setInterval(F,G.autoPlayInterval);G.onAutoPlayStart instanceof Function&&G.onAutoPlayStart();}function N(){if(!V){return ;}clearInterval(V);V=0;G.onAutoPlayStop instanceof Function&&G.onAutoPlayStop();}A(window).load(function(){if(A(G.imageFlowSelector)){O(G.loadingSelector);I(true);d(G.imagesSelector);d(G.scrollbarSelector);}});A(window).resize(function(){if(A(G.imageFlowSelector)){I();}});A(window).unload(function(){document=null;});return{showPrev:E,showNext:F,startAutoPlay:H,stopAutoPlay:N};};})(jQuery);
