var Loader=function(){var g;var d;var j;var k;var h;var i;var e;var b;var c;g=this;j=0;k=0;h=j;i=k;e=true;b=false;g.setList=function(m){g.stop();d=m};g.getList=function(){return d};g.setIndex=function(m){j=m;k=0;if(d&&j>d.length/2){e=false}else{e=true}};g.getIndex=function(){return h};g.start=function(){if(d){if(b){g.stop()}b=true;a()}};g.pause=function(){if(c){clearTimeout(c);c=null}if(d){var m=d[j];if(m.obj){m.obj.unbind("error load",l)}}b=false};g.resume=g.start;g.stop=function(){if(b){g.pause();g.setIndex(0)}};g.isLoading=function(){return b};function a(){h=j;i=k;var m=d[h];if(m.obj){f()}else{m["~obj"]=jQuery("<img></img>").one("error load",l);m["~obj"].attr("src","/"+m.galleryImage)}}function l(n){var m=d[h];if(n.type.match(/load/i)){m.obj=m["~obj"]}delete m["~obj"];jQuery(g).triggerHandler("complete",[h]);c=setTimeout(f,50)}function f(){c=null;if(j==h&&k==i){k++;if(k<d.length){if(e){if(k>=d.length-j){j--}else{j+=k;e=!e}}else{if(k>j){j++}else{j-=k;e=!e}}a()}else{g.stop()}}else{a()}}};var Slideshow=function(o,e,r,m,f){var u;var g;var x;var y;var b;var l;var d;var p;var v;var w;var h;var a;u=this;var k=jQuery("#"+o).empty().css("overflow","hidden").bind("click",i);g=k.width();x=k.height();y=jQuery("<div></div>").css({position:"relative",width:"100%",height:x+"px"}).appendTo(k);b=y.clone(false).css({top:(-x)+"px",opacity:"0"}).appendTo(k);l=jQuery("<div></div>").addClass("textcontainer").appendTo(b);d=y.clone(false).css("top",(-x*2)+"px").appendTo(k);p=jQuery("<img></img>").attr("src",f).css({position:"absolute",left:"50%",top:"50%"}).load(j).appendTo(d);_navigation=jQuery("<div></div>").addClass("navigation").appendTo(d);jQuery.getJSON(e+"/em_amfphp/ajax/["+r+', "'+m+'"]/Extension_Em_Amfphp_Classes_Lib_Services/getMediaGalleryElements',t);u.setIndex=function(B){clearTimeout(a);var A=v.getList();if(A&&B>=0&&B<A.length){_navigation.children("#item-"+w).removeClass("selected");w=B;_navigation.children("#item-"+w).addClass("selected");var z=A[w];if(z.obj){p.css("display","none");if(z.caption&&z.caption.length>0){l.html(z.caption);if(!b.data("visible")){b.data("visible",true).animate({opacity:"1"},1000)}}else{if(b.data("visible")){b.data("visible",false).animate({opacity:"0"},1000)}}z.obj.css("opacity","0").appendTo(y).animate({opacity:"1"},1000,s)}else{p.css("display","block");v.setIndex(w)}}};u.getIndex=function(){return w};u.previous=function(A){var z=w-1;if(z<0){z=v.getList().length}u.setIndex(z)};u.next=function(A){var z=w+1;if(z>=v.getList().length){z=0}u.setIndex(z)};function t(z){if(z&&z.length>0){for(var A=0;A<z.length;A++){jQuery("<a></a>").attr({href:"#",id:"item-"+A}).addClass("navigationitem").bind("click",A,c).appendTo(_navigation)}v=new Loader();jQuery(v).bind("complete",n);v.setList(z);w=0;h=false;v.start()}}function j(z){p.css({marginLeft:(-p.width()/2)+"px",marginTop:(-p.height()/2)+"px"})}function n(B,z){var A=v.getList()[z];if(A.obj){A.obj.css({position:"absolute",MsInterpolationMode:"bicubic",width:g+"px",height:x+"px"});if(z==w){u.setIndex(w)}}}function s(){jQuery(this).prevAll().remove();if(!h){q()}}function i(z){clearTimeout(a);h=true;a=setTimeout(q,4000)}function q(){clearTimeout(a);h=false;a=setTimeout(u.next,2000)}function c(z){if(z.data!=w){u.setIndex(z.data)}return false}};
