var dom=YAHOO.util.Dom;var move={v:{gallery_id:"gallery",gallery_canvas_id:"gallery_canvas",stop:false,mouseX:null,mitte:null,canvas_width:null,timeout:100,_timeoutId:null,movetimeout:null,anim:null,attrLeft:0,rightborder:null},init:function(){var A=dom.getRegion(move.v.gallery_canvas_id);move.v.canvas_width=A.right-A.left;move.v.mitte=move.v.canvas_width/2+dom.getX(move.v.gallery_canvas_id);move.v.movetimeout=move.v.timeout/1000;move.v.rightborder=-(move.sumLis()-move.v.canvas_width);YAHOO.util.Event.addListener("gallery_mousein","mousemove",move.setMouseX);YAHOO.util.Event.addListener("gallery_mousein","mouseout",move.stop);move.toImg()},checkForLi:function(A){if(A.tagName=="LI"){return true}return false},sumLis:function(){var B=dom.getChildrenBy(dom.get(move.v.gallery_id),move.checkForLi);var A=parseInt(dom.getStyle(B[0],"margin-right"));var D=-A;for(var C=0;C<B.length;C++){D+=dom.getRegion(B[C]).width+A}return D},setMouseX:function(A){move.v.mouseX=YAHOO.util.Event.getPageX(A);move.v.stop=false;clearTimeout(move.v._timeoutId);move.v._timeoutId=setTimeout(move._process,move.v.timeout)},_process:function(){var C=(move.v.mitte-move.v.mouseX)/move.v.canvas_width;var A=3*C;var D=parseInt(Math.tan(A)*10);var B=10;move.v.attrLeft=parseInt(dom.getStyle(move.v.gallery_id,"left"));if(D<0){B=(move.v.rightborder-move.v.attrLeft)/D}else{B=Math.abs(move.v.attrLeft)/D}if(move.v.anim!=null){move.v.anim.stop(false)}move.v.anim=new YAHOO.util.Anim(move.v.gallery_id,{left:{by:D*B}},move.v.movetimeout*B);move.v.anim.onTween.subscribe(function(){move.v.attrLeft=this.getAttribute("left");if((move.v.attrLeft>0&&D>0)||(move.v.attrLeft<move.v.rightborder&&D<0)){move.stop()}});move.v.attrLeft=parseInt(dom.getStyle(move.v.gallery_id,"left"));if((move.v.attrLeft>=0&&D>0)||(move.v.attrLeft<=move.v.rightborder&&D<0)){move.stop()}if(!move.v.stop){move.v.anim.animate()}},stop:function(){if(move.v.anim==null){return }move.v.stop=true;move.v.anim.stop(false)},toImg:function(A){if(A=="undefined"){A=parseInt(location.hash.split("#",2)[1])}if(isNaN(A)){setImgById(1)}move.v.attrLeft=parseInt(dom.getStyle(move.v.gallery_id,"left"));var C=dom.getX("img"+A)-move.v.attrLeft-200;var B=move.v.canvas_width/2;if(C>B){C-=B}else{C=0}if(-C<move.v.rightborder){C=-move.v.rightborder}(new YAHOO.util.Anim(move.v.gallery_id,{left:{to:-C}},move.v.movetimeout,YAHOO.util.Easing.easeOut)).animate();setImgById(A)},slideshow:function(){move.v.mouseX=0.205*move.v.canvas_width-move.v.mitte;move._process()}};YAHOO.util.Event.on(window,"resize",function(){clearTimeout(move.v._timeoutId);move.v._timeoutId=setTimeout(move.init,500)});var xy=null;getElByXY=function(A){el_xy=YAHOO.util.Dom.getRegion(A);if(xy[0]>el_xy.left&&xy[0]<el_xy.right&&xy[1]>el_xy.top&&xy[1]<el_xy.bottom){return true}return false};transparentOperation=function(B){xy=YAHOO.util.Event.getXY(B);var A=YAHOO.util.Dom.getElementBy(getElByXY,"A","gallery");if(A!=""){setImg(A.href,A.title);slideshowStop()}};YAHOO.util.Event.addListener("gallery_mousein","mousedown",transparentOperation);function setImgById(A){try{a_el=dom.get("img"+A);setImg(a_el.href,a_el.title)}catch(B){return false}}var fade_out=null;function setImg(B,A){var C="main_img";dom.get(C).src=B;dom.get("image_index").innerHTML=A;location.hash=A;dom.getElementsByClassName("active","img","gallery",function(D){dom.removeClass(D,"active")});dom.addClass(dom.get("bild"+A),"active");dom.get("main_imageinfo").innerHTML=dom.get("imageinfo"+A).innerHTML}function getActualIndex(){var A=parseInt(location.hash.split("#",2)[1]);if(isNaN(A)){return 1}return A}function setPrevImg(){slideshowStop();var A=getActualIndex();A=A-1;move.toImg(A)}function setNextImg(){slideshowStop();setNextImgInc()}function setNextImgInc(){var A=getActualIndex();A=A+1;move.toImg(A)}var slidestop=false;var isSliding=false;var slideTimeoutId=null;function slideshowStop(){if(isSliding){slidestop=true}YAHOO.util.Event.purgeElement(dom.get("slideshow"));YAHOO.util.Event.addListener("slideshow","click",slideshow)}function slideshow(){var B=getActualIndex();var A=dom.getChildrenBy(dom.get(move.v.gallery_id),move.checkForLi).length;if(B<A&&!slidestop){isSliding=true;setNextImgInc();clearTimeout(slideTimeoutId);slideTimeoutId=setTimeout(slideshow,2000)}else{slidestop=false;isSliding=false;return false}YAHOO.util.Event.purgeElement(dom.get("slideshow"));YAHOO.util.Event.addListener("slideshow","click",slideshowStop)}YAHOO.util.Event.addListener("slideshow","click",slideshow);
