function ImageFlow(){this.defaults={animationSpeed:150,aspectRatio:1.964,buttons:true,captions:true,circular:true,imageCursor:"default",ImageFlowID:"menu",imageFocusM:1,imageFocusMax:6,imagePath:"",imageScaling:true,imagesHeight:.67,imagesM:1,onClick:function(){document.location=this.url},opacity:true,opacityArray:[10,8,6,4,2],percentLandscape:118,percentOther:100,preloadImages:false,reflections:true,reflectionGET:"",reflectionP:.5,reflectionPNG:true,reflectPath:"",scrollbarP:.6,slider:true,sliderCursor:"e-resize",sliderWidth:14,slideshow:true,slideshowSpeed:3e3,slideshowAutoplay:false,startID:1,glideToStartID:true,startAnimation:true,xStep:160};var a=this;this.init=function(b){for(var c in a.defaults){this[c]=b!==undefined&&b[c]!==undefined?b[c]:a.defaults[c]}var d=document.getElementById(a.ImageFlowID);if(d){d.style.visibility="visible";this.ImageFlowDiv=d;if(this.createStructure()){this.imagesDiv=document.getElementById(a.ImageFlowID+"_images");this.captionDiv=document.getElementById(a.ImageFlowID+"_caption");this.navigationDiv=document.getElementById(a.ImageFlowID+"_navigation");this.scrollbarDiv=document.getElementById(a.ImageFlowID+"_scrollbar");this.sliderDiv=document.getElementById(a.ImageFlowID+"_slider");this.buttonNextDiv=document.getElementById(a.ImageFlowID+"_next");this.buttonPreviousDiv=document.getElementById(a.ImageFlowID+"_previous");this.buttonSlideshow=document.getElementById(a.ImageFlowID+"_slideshow");this.indexArray=[];this.current=0;this.imageID=0;this.target=0;this.memTarget=0;this.firstRefresh=true;this.firstCheck=true;this.busy=false;var e=this.ImageFlowDiv.offsetWidth;var f=Math.round(e/a.aspectRatio);document.getElementById(a.ImageFlowID+"_loading_txt").style.paddingTop=f*.5-22+"px";d.style.height=f+"px";this.loadingProgress()}}};this.createStructure=function(){var b=a.Helper.createDocumentElement("div","images");var c,d,e,f;var g=a.ImageFlowDiv.childNodes.length;for(var h=0;h<g;h++){c=a.ImageFlowDiv.childNodes[h];if(c&&c.nodeType==1&&c.nodeName=="IMG"){if(a.reflections===true){d=a.reflectionPNG?"3":"2";e=a.imagePath+c.getAttribute("src",2);e=a.reflectPath+"reflect"+d+".php?img="+e+a.reflectionGET;c.setAttribute("src",e)}f=c.cloneNode(true);b.appendChild(f)}}if(a.circular){var i=a.Helper.createDocumentElement("div","images");var j=a.Helper.createDocumentElement("div","images");g=b.childNodes.length;if(g<a.imageFocusMax){a.imageFocusMax=g}if(g>1){var k;for(k=0;k<g;k++){c=b.childNodes[k];if(k<a.imageFocusMax){f=c.cloneNode(true);i.appendChild(f)}if(g-k<a.imageFocusMax+1){f=c.cloneNode(true);j.appendChild(f)}}for(k=0;k<g;k++){c=b.childNodes[k];f=c.cloneNode(true);j.appendChild(f)}for(k=0;k<a.imageFocusMax;k++){c=i.childNodes[k];f=c.cloneNode(true);j.appendChild(f)}b=j}}if(a.slideshow){var l=a.Helper.createDocumentElement("div","slideshow");b.appendChild(l)}var m=a.Helper.createDocumentElement("p","loading_txt");var n=document.createTextNode(" ");m.appendChild(n);var o=a.Helper.createDocumentElement("div","loading");var p=a.Helper.createDocumentElement("div","loading_bar");o.appendChild(p);var q=a.Helper.createDocumentElement("div","caption");var r=a.Helper.createDocumentElement("div","scrollbar");var s=a.Helper.createDocumentElement("div","slider");r.appendChild(s);if(a.buttons){var t=a.Helper.createDocumentElement("div","previous","button");var u=a.Helper.createDocumentElement("div","next","button");r.appendChild(t);r.appendChild(u)}var v=a.Helper.createDocumentElement("div","navigation");v.appendChild(q);v.appendChild(r);var w=false;if(a.ImageFlowDiv.appendChild(b)&&a.ImageFlowDiv.appendChild(m)&&a.ImageFlowDiv.appendChild(o)&&a.ImageFlowDiv.appendChild(v)){g=a.ImageFlowDiv.childNodes.length;for(h=0;h<g;h++){c=a.ImageFlowDiv.childNodes[h];if(c&&c.nodeType==1&&c.nodeName=="IMG"){a.ImageFlowDiv.removeChild(c)}}w=true}return w};this.loadingProgress=function(){var b=a.loadingStatus();if((b<100||a.firstCheck)&&a.preloadImages){if(a.firstCheck&&b==100){a.firstCheck=false;window.setTimeout(a.loadingProgress,100)}else{window.setTimeout(a.loadingProgress,40)}}else{document.getElementById(a.ImageFlowID+"_loading_txt").style.display="none";document.getElementById(a.ImageFlowID+"_loading").style.display="none";window.setTimeout(a.Helper.addResizeEvent,1e3);a.refresh();if(a.max>1){a.MouseWheel.init();a.MouseDrag.init();a.Touch.init();a.Key.init();if(a.slideshow){a.Slideshow.init()}if(a.slider){a.scrollbarDiv.style.visibility="visible"}}}};this.loadingStatus=function(){var b=a.imagesDiv.childNodes.length;var c=0,d=0;var e=null;for(var f=0;f<b;f++){e=a.imagesDiv.childNodes[f];if(e&&e.nodeType==1&&e.nodeName=="IMG"){if(e.complete){d++}c++}}var g=Math.round(d/c*100);var h=document.getElementById(a.ImageFlowID+"_loading_bar");h.style.width=g+"%";if(a.circular){c=c-a.imageFocusMax*2;d=g<1?0:Math.round(c/100*g)}var i=document.getElementById(a.ImageFlowID+"_loading_txt");var j=document.createTextNode("loading images "+d+"/"+c);i.replaceChild(j,i.firstChild);return g};this.refresh=function(){this.imagesDivWidth=a.imagesDiv.offsetWidth+a.imagesDiv.offsetLeft;this.maxHeight=Math.round(a.imagesDivWidth/a.aspectRatio);this.maxFocus=a.imageFocusMax*a.xStep;this.size=a.imagesDivWidth*.5;this.sliderWidth=a.sliderWidth*.5;this.scrollbarWidth=(a.imagesDivWidth-Math.round(a.sliderWidth)*2)*a.scrollbarP;this.imagesDivHeight=Math.round(a.maxHeight*a.imagesHeight);a.ImageFlowDiv.style.height=a.maxHeight+"px";a.imagesDiv.style.height=a.imagesDivHeight+"px";a.navigationDiv.style.height=a.maxHeight-a.imagesDivHeight+"px";a.captionDiv.style.width=a.imagesDivWidth+"px";a.captionDiv.style.paddingTop=Math.round(a.imagesDivWidth*.02)+"px";a.scrollbarDiv.style.width=a.scrollbarWidth+"px";a.scrollbarDiv.style.marginTop=Math.round(a.imagesDivWidth*.02)+"px";a.scrollbarDiv.style.marginLeft=Math.round(a.sliderWidth+(a.imagesDivWidth-a.scrollbarWidth)/2)+"px";a.sliderDiv.style.cursor=a.sliderCursor;a.sliderDiv.onmousedown=function(){a.MouseDrag.start(this);return false};if(a.buttons){a.buttonPreviousDiv.onclick=function(){a.MouseWheel.handle(1)};a.buttonNextDiv.onclick=function(){a.MouseWheel.handle(-1)}}var b=a.reflections===true?a.reflectionP+1:1;var c=a.imagesDiv.childNodes.length;var d=0;var e=null;for(var f=0;f<c;f++){e=a.imagesDiv.childNodes[f];if(e!==null&&e.nodeType==1&&e.nodeName=="IMG"){this.indexArray[d]=f;e.url=e.getAttribute("longdesc");e.xPosition=-d*a.xStep;e.i=d;if(a.firstRefresh){if(e.getAttribute("width")!==null&&e.getAttribute("height")!==null){e.w=e.getAttribute("width");e.h=e.getAttribute("height")*b}else{e.w=e.width;e.h=e.height}}if(e.w>e.h/(a.reflectionP+1)){e.pc=a.percentLandscape;e.pcMem=a.percentLandscape}else{e.pc=a.percentOther;e.pcMem=a.percentOther}if(a.imageScaling===false){e.style.position="relative";e.style.display="inline"}e.style.cursor=a.imageCursor;d++}}this.max=a.indexArray.length;if(a.imageScaling===false){e=a.imagesDiv.childNodes[a.indexArray[0]];this.totalImagesWidth=e.w*a.max;e.style.paddingLeft=a.imagesDivWidth/2+e.w/2+"px";a.imagesDiv.style.height=e.h+"px";a.navigationDiv.style.height=a.maxHeight-e.h+"px"}if(a.firstRefresh){a.firstRefresh=false;a.imageID=a.startID-1;if(a.imageID<0){a.imageID=0}if(a.circular){a.imageID=a.imageID+a.imageFocusMax}maxId=a.circular?a.max-a.imageFocusMax-1:a.max-1;if(a.imageID>maxId){a.imageID=maxId}if(a.glideToStartID===false){a.moveTo(-a.imageID*a.xStep)}if(a.startAnimation){a.moveTo(5e3)}}if(a.max>1){a.glideTo(a.imageID)}a.moveTo(a.current)};this.moveTo=function(b){this.current=b;this.zIndex=a.max;for(var c=0;c<a.max;c++){var d=a.imagesDiv.childNodes[a.indexArray[c]];var e=c*-a.xStep;if(a.imageScaling){if(e+a.maxFocus<a.memTarget||e-a.maxFocus>a.memTarget){d.style.visibility="hidden";d.style.display="none"}else{var f=(Math.sqrt(1e4+b*b)+100)*a.imagesM;var g=b/f*a.size+a.size;d.style.display="block";var h=d.h/d.w*d.pc/f*a.size;var i=0;switch(h>a.maxHeight){case false:i=d.pc/f*a.size;break;default:h=a.maxHeight;i=d.w*h/d.h;break}var j=a.imagesDivHeight-h+h/(a.reflectionP+1)*a.reflectionP;d.style.left=g-d.pc/2/f*a.size+"px";if(i&&h){d.style.height=h+"px";d.style.width=i+"px";d.style.top=j+"px"}d.style.visibility="visible";switch(b<0){case true:this.zIndex++;break;default:this.zIndex=a.zIndex-1;break}switch(d.i==a.imageID){case false:d.onclick=function(){a.glideTo(this.i)};break;default:this.zIndex=a.zIndex+1;if(d.url!==""){d.onclick=a.onClick}break}d.style.zIndex=a.zIndex}}else{if(e+a.maxFocus<a.memTarget||e-a.maxFocus>a.memTarget){d.style.visibility="hidden"}else{d.style.visibility="visible";switch(d.i==a.imageID){case false:d.onclick=function(){a.glideTo(this.i)};break;default:if(d.url!==""){d.onclick=a.onClick}break}}a.imagesDiv.style.marginLeft=b-a.totalImagesWidth+"px"}b+=a.xStep}};this.glideTo=function(b){var c,d;if(a.circular){if(b+1===a.imageFocusMax){d=a.max-a.imageFocusMax;c=-d*a.xStep;b=d-1}if(b===a.max-a.imageFocusMax){d=a.imageFocusMax-1;c=-d*a.xStep;b=d+1}}var e=-b*a.xStep;this.target=e;this.memTarget=e;this.imageID=b;var f=a.imagesDiv.childNodes[b].getAttribute("alt");if(f===""||a.captions===false){f=" "}a.captionDiv.innerHTML=f;if(a.MouseDrag.busy===false){if(a.circular){this.newSliderX=(b-a.imageFocusMax)*a.scrollbarWidth/(a.max-a.imageFocusMax*2-1)-a.MouseDrag.newX}else{this.newSliderX=b*a.scrollbarWidth/(a.max-1)-a.MouseDrag.newX}a.sliderDiv.style.marginLeft=a.newSliderX-a.sliderWidth+"px"}if(a.opacity===true||a.imageFocusM!==a.defaults.imageFocusM){a.Helper.setOpacity(a.imagesDiv.childNodes[b],a.opacityArray[0]);a.imagesDiv.childNodes[b].pc=a.imagesDiv.childNodes[b].pc*a.imageFocusM;var g=0;var h=0;var i=0;var j=a.opacityArray.length;for(var k=1;k<a.imageFocusMax+1;k++){if(k+1>j){g=a.opacityArray[j-1]}else{g=a.opacityArray[k]}h=b+k;i=b-k;if(h<a.max){a.Helper.setOpacity(a.imagesDiv.childNodes[h],g);a.imagesDiv.childNodes[h].pc=a.imagesDiv.childNodes[h].pcMem}if(i>=0){a.Helper.setOpacity(a.imagesDiv.childNodes[i],g);a.imagesDiv.childNodes[i].pc=a.imagesDiv.childNodes[i].pcMem}}}if(c){a.moveTo(c)}if(a.busy===false){a.busy=true;a.animate()}};this.animate=function(){switch(a.target<a.current-1||a.target>a.current+1){case true:a.moveTo(a.current+(a.target-a.current)/3);window.setTimeout(a.animate,a.animationSpeed);a.busy=true;break;default:a.busy=false;break}};this.glideOnEvent=function(b){if(a.slideshow){a.Slideshow.interrupt()}a.glideTo(b)};this.Slideshow={direction:1,init:function(){a.slideshowAutoplay?a.Slideshow.start():a.Slideshow.stop()},interrupt:function(){a.Helper.removeEvent(a.ImageFlowDiv,"click",a.Slideshow.interrupt);a.Slideshow.stop()},addInterruptEvent:function(){a.Helper.addEvent(a.ImageFlowDiv,"click",a.Slideshow.interrupt)},start:function(){a.Helper.setClassName(a.buttonSlideshow,"slideshow pause");a.buttonSlideshow.onclick=function(){a.Slideshow.stop()};a.Slideshow.action=window.setInterval(a.Slideshow.slide,a.slideshowSpeed);window.setTimeout(a.Slideshow.addInterruptEvent,100)},stop:function(){a.Helper.setClassName(a.buttonSlideshow,"slideshow play");a.buttonSlideshow.onclick=function(){a.Slideshow.start()};window.clearInterval(a.Slideshow.action)},slide:function(){var b=a.imageID+a.Slideshow.direction;var c=false;if(b===a.max){a.Slideshow.direction=-1;c=true}if(b<0){a.Slideshow.direction=1;c=true}c?a.Slideshow.slide():a.glideTo(b)}};this.MouseWheel={init:function(){if(window.addEventListener){a.ImageFlowDiv.addEventListener("DOMMouseScroll",a.MouseWheel.get,false)}a.Helper.addEvent(a.ImageFlowDiv,"mousewheel",a.MouseWheel.get)},get:function(b){var c=0;if(!b){b=window.event}if(b.wheelDelta){c=b.wheelDelta/120}else if(b.detail){c=-b.detail/3}if(c){a.MouseWheel.handle(c)}a.Helper.suppressBrowserDefault(b)},handle:function(b){var c=false;var d=0;if(b>0){if(a.imageID>=1){d=a.imageID-1;c=true}}else{if(a.imageID<a.max-1){d=a.imageID+1;c=true}}if(c){a.glideOnEvent(d)}}};this.MouseDrag={object:null,objectX:0,mouseX:0,newX:0,busy:false,init:function(){a.Helper.addEvent(a.ImageFlowDiv,"mousemove",a.MouseDrag.drag);a.Helper.addEvent(a.ImageFlowDiv,"mouseup",a.MouseDrag.stop);a.Helper.addEvent(document,"mouseup",a.MouseDrag.stop);a.ImageFlowDiv.onselectstart=function(){var b=true;if(a.MouseDrag.busy){b=false}return b}},start:function(b){a.MouseDrag.object=b;a.MouseDrag.objectX=a.MouseDrag.mouseX-b.offsetLeft+a.newSliderX},stop:function(){a.MouseDrag.object=null;a.MouseDrag.busy=false},drag:function(b){var c=0;if(!b){b=window.event}if(b.pageX){c=b.pageX}else if(b.clientX){c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft}a.MouseDrag.mouseX=c;if(a.MouseDrag.object!==null){var d=a.MouseDrag.mouseX-a.MouseDrag.objectX+a.sliderWidth;if(d<-a.newSliderX){d=-a.newSliderX}if(d>a.scrollbarWidth-a.newSliderX){d=a.scrollbarWidth-a.newSliderX}var e,f;if(a.circular){e=(d+a.newSliderX)/(a.scrollbarWidth/(a.max-a.imageFocusMax*2-1));f=Math.round(e)+a.imageFocusMax}else{e=(d+a.newSliderX)/(a.scrollbarWidth/(a.max-1));f=Math.round(e)}a.MouseDrag.newX=d;a.MouseDrag.object.style.left=d+"px";if(a.imageID!==f){a.glideOnEvent(f)}a.MouseDrag.busy=true}}};this.Touch={x:0,startX:0,stopX:0,busy:false,first:true,init:function(){a.Helper.addEvent(a.navigationDiv,"touchstart",a.Touch.start);a.Helper.addEvent(document,"touchmove",a.Touch.handle);a.Helper.addEvent(document,"touchend",a.Touch.stop)},isOnNavigationDiv:function(b){var c=false;if(b.touches){var d=b.touches[0].target;if(d===a.navigationDiv||d===a.sliderDiv||d===a.scrollbarDiv){c=true}}return c},getX:function(a){var b=0;if(a.touches){b=a.touches[0].pageX}return b},start:function(b){a.Touch.startX=a.Touch.getX(b);a.Touch.busy=true;a.Helper.suppressBrowserDefault(b)},isBusy:function(){var b=false;if(a.Touch.busy){b=true}return b},handle:function(b){if(a.Touch.isBusy&&a.Touch.isOnNavigationDiv(b)){var c=a.circular?a.max-a.imageFocusMax*2-1:a.max-1;if(a.Touch.first){a.Touch.stopX=(c-a.imageID)*(a.imagesDivWidth/c);a.Touch.first=false}var d=-(a.Touch.getX(b)-a.Touch.startX-a.Touch.stopX);if(d<0){d=0}if(d>a.imagesDivWidth){d=a.imagesDivWidth}a.Touch.x=d;var e=Math.round(d/(a.imagesDivWidth/c));e=c-e;if(a.imageID!==e){if(a.circular){e=e+a.imageFocusMax}a.glideOnEvent(e)}a.Helper.suppressBrowserDefault(b)}},stop:function(){a.Touch.stopX=a.Touch.x;a.Touch.busy=false}};this.Key={init:function(){document.onkeydown=function(b){a.Key.handle(b)}},handle:function(b){var c=a.Key.get(b);switch(c){case 39:a.MouseWheel.handle(-1);break;case 37:a.MouseWheel.handle(1);break}},get:function(a){a=a||window.event;return a.keyCode}};this.Helper={addEvent:function(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false)}else if(a.attachEvent){a["e"+b+c]=c;a[b+c]=function(){a["e"+b+c](window.event)};a.attachEvent("on"+b,a[b+c])}},removeEvent:function(a,b,c){if(a.removeEventListener){a.removeEventListener(b,c,false)}else if(a.detachEvent){if(a[b+c]===undefined){alert("Helper.removeEvent » Pointer to detach event is undefined - perhaps you are trying to detach an unattached event?")}a.detachEvent("on"+b,a[b+c]);a[b+c]=null;a["e"+b+c]=null}},setOpacity:function(b,c){if(a.opacity===true){b.style.opacity=c/10;b.style.filter="alpha(opacity="+c*10+")"}},createDocumentElement:function(b,c,d){var e=document.createElement(b);e.setAttribute("id",a.ImageFlowID+"_"+c);if(d!==undefined){c+=" "+d}a.Helper.setClassName(e,c);return e},setClassName:function(a,b){if(a){a.setAttribute("class",b);a.setAttribute("className",b)}},suppressBrowserDefault:function(a){if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}return false},addResizeEvent:function(){var b=window.onresize;if(typeof window.onresize!="function"){window.onresize=function(){a.refresh()}}else{window.onresize=function(){if(b){b()}a.refresh()}}}}}var domReadyEvent={name:"domReadyEvent",events:{},domReadyID:1,bDone:false,DOMContentLoadedCustom:null,add:function(a){if(!a.$$domReadyID){a.$$domReadyID=this.domReadyID++;if(this.bDone){a()}this.events[a.$$domReadyID]=a}},remove:function(a){if(a.$$domReadyID){delete this.events[a.$$domReadyID]}},run:function(){if(this.bDone){return}this.bDone=true;for(var a in this.events){this.events[a]()}},schedule:function(){if(this.bDone){return}if(/KHTML|WebKit/i.test(navigator.userAgent)){if(/loaded|complete/.test(document.readyState)){this.run()}else{setTimeout(this.name+".schedule()",100)}}else if(document.getElementById("__ie_onload")){return true}if(typeof this.DOMContentLoadedCustom==="function"){if(typeof document.getElementsByTagName!=="undefined"&&(document.getElementsByTagName("body")[0]!==null||document.body!==null)){if(this.DOMContentLoadedCustom()){this.run()}else{setTimeout(this.name+".schedule()",250)}}}return true},init:function(){function a(){domReadyEvent.run()}if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){domReadyEvent.run()},false)}setTimeout("domReadyEvent.schedule()",100);if(typeof addEvent!=="undefined"){addEvent(window,"load",a)}else if(document.addEventListener){document.addEventListener("load",a,false)}else if(typeof window.onload==="function"){var b=window.onload;window.onload=function(){domReadyEvent.run();b()}}else{window.onload=a}}};var domReady=function(a){domReadyEvent.add(a)};domReadyEvent.init();domReady(function(){var a=new ImageFlow;a.init({ImageFlowID:"menu",reflectionGET:"&bgc=ffffff&fade_start=45%"})})
