(function(a){a.fn.slides=function(b){b=a.extend({},a.fn.slides.option,b);return this.each(function(){function x(g,h,i){if(!p&&o){p=true;switch(g){case"next":l=n;k=n+1;k=e===k?0:k;r=f*2;g=-f*2;n=k;break;case"prev":l=n;k=n-1;k=k===-1?e-1:k;r=0;g=0;n=k;break;case"pagination":k=parseInt(i,10);l=a("."+b.paginationClass+" li.current a",c).attr("href").match("[^#/]+$");if(k>l){r=f*2;g=-f*2}else{r=0;g=0}n=k;break}if(h==="fade"){b.animationStart();if(b.crossfade){d.children(":eq("+k+")",c).css({zIndex:10}).fadeIn(b.fadeSpeed,function(){if(b.autoHeight){d.animate({height:d.children(":eq("+k+")",c).outerHeight()},b.autoHeightSpeed,function(){d.children(":eq("+l+")",c).css({display:"none",zIndex:0});d.children(":eq("+k+")",c).css({zIndex:0});b.animationComplete(k+1);p=false})}else{d.children(":eq("+l+")",c).css({display:"none",zIndex:0});d.children(":eq("+k+")",c).css({zIndex:0});b.animationComplete(k+1);p=false}})}else{b.animationStart();d.children(":eq("+l+")",c).fadeOut(b.fadeSpeed,function(){if(b.autoHeight){d.animate({height:d.children(":eq("+k+")",c).outerHeight()},b.autoHeightSpeed,function(){d.children(":eq("+k+")",c).fadeIn(b.fadeSpeed)})}else{d.children(":eq("+k+")",c).fadeIn(b.fadeSpeed,function(){if(a.browser.msie){a(this).get(0).style.removeAttribute("filter")}})}b.animationComplete(k+1);p=false})}}else{d.children(":eq("+k+")").css({left:r,display:"block"});if(b.autoHeight){b.animationStart();d.animate({left:g,height:d.children(":eq("+k+")").outerHeight()},b.slideSpeed,function(){d.css({left:-f});d.children(":eq("+k+")").css({left:f,zIndex:5});d.children(":eq("+l+")").css({left:f,display:"none",zIndex:0});b.animationComplete(k+1);p=false})}else{b.animationStart();d.animate({left:g},b.slideSpeed,function(){d.css({left:-f});d.children(":eq("+k+")").css({left:f,zIndex:5});d.children(":eq("+l+")").css({left:f,display:"none",zIndex:0});b.animationComplete(k+1);p=false})}}if(b.pagination){a("."+b.paginationClass+" li.current",c).removeClass("current");a("."+b.paginationClass+" li:eq("+k+")",c).addClass("current")}}}function w(){if(b.pause){clearTimeout(c.data("pause"));clearInterval(c.data("interval"));pauseTimeout=setTimeout(function(){clearTimeout(c.data("pause"));playInterval=setInterval(function(){x("next",i)},b.play);c.data("interval",playInterval)},b.pause);c.data("pause",pauseTimeout)}else{v()}}function v(){clearInterval(c.data("interval"))}a("."+b.container,a(this)).children().wrapAll('<div class="slides_control"/>');var c=a(this),d=a(".slides_control",c),e=d.children().size(),f=d.children().outerWidth(),g=d.children().outerHeight(),h=b.start-1,i=b.effect.indexOf(",")<0?b.effect:b.effect.replace(" ","").split(",")[0],j=b.effect.indexOf(",")<0?i:b.effect.replace(" ","").split(",")[1],k=0,l=0,m=0,n=0,o,p,q,r,s,t;if(e<2){return}if(h<0){h=0}if(h>e){h=e-1}if(b.start){n=h}if(b.randomize){d.randomize()}a("."+b.container,c).css({overflow:"hidden",position:"relative"});d.children().css({position:"absolute",top:0,left:d.children().outerWidth(),zIndex:0,display:"none"});d.css({position:"relative",width:f*3,height:g,left:-f});a("."+b.container,c).css({display:"block"});if(b.autoHeight){d.children().css({height:"auto"});d.animate({height:d.children(":eq("+h+")").outerHeight()},b.autoHeightSpeed)}if(b.preload&&d.find("img").length){a("."+b.container,c).css({background:"url("+b.preloadImage+") no-repeat 50% 50%"});var u=d.find("img:eq("+h+")").attr("src")+"?"+(new Date).getTime();if(a("img",c).parent().attr("class")!="slides_control"){t=d.children(":eq(0)")[0].tagName.toLowerCase()}else{t=d.find("img:eq("+h+")")}d.find("img:eq("+h+")").attr("src",u).load(function(){d.find(t+":eq("+h+")").fadeIn(b.fadeSpeed,function(){a(this).css({zIndex:5});c.css({background:""});o=true})})}else{d.children(":eq("+h+")").fadeIn(b.fadeSpeed,function(){o=true})}if(b.bigTarget){d.children().css({cursor:"pointer"});d.children().click(function(){x("next",i);return false})}if(b.hoverPause&&b.play){d.children().bind("mouseover",function(){v()});d.children().bind("mouseleave",function(){w()})}if(b.generateNextPrev){a("."+b.container,c).after('<a href="#" class="'+b.prev+'">Prev</a>');a("."+b.prev,c).after('<a href="#" class="'+b.next+'">Next</a>')}a("."+b.next,c).click(function(a){a.preventDefault();if(b.play){w()}x("next",i)});a("."+b.prev,c).click(function(a){a.preventDefault();if(b.play){w()}x("prev",i)});if(b.generatePagination){c.append('<div class="zeitenzahl"><ul class='+b.paginationClass+"></ul></div>");d.children().each(function(){a("."+b.paginationClass,c).append('<li><a href="#'+m+'">'+(m+1)+"</a></li>");m++})}else{a("."+b.paginationClass+" li a",c).each(function(){a(this).attr("href","#"+m);m++})}a("."+b.paginationClass+" li:eq("+h+")",c).addClass("current");a("."+b.paginationClass+" li a",c).click(function(){if(b.play){w()}q=a(this).attr("href").match("[^#/]+$");if(n!=q){x("pagination",j,q)}return false});a("a.link",c).click(function(){if(b.play){w()}q=a(this).attr("href").match("[^#/]+$")-1;if(n!=q){x("pagination",j,q)}return false});if(b.play){playInterval=setInterval(function(){x("next",i)},b.play);c.data("interval",playInterval)}})};a.fn.slides.option={preload:false,preloadImage:"/img/loading.gif",container:"slides_container",generateNextPrev:false,next:"next",prev:"prev",pagination:true,generatePagination:true,paginationClass:"pagination",fadeSpeed:550,slideSpeed:350,start:1,effect:"fade",crossfade:false,randomize:false,play:0,pause:0,hoverPause:false,autoHeight:false,autoHeightSpeed:350,bigTarget:false,animationStart:function(){},animationComplete:function(){}};a.fn.randomize=function(b){function c(){return Math.round(Math.random())-.5}return a(this).each(function(){var d=a(this);var e=d.children();var f=e.length;if(f>1){e.hide();var g=[];for(i=0;i<f;i++){g[g.length]=i}g=g.sort(c);a.each(g,function(a,c){var f=e.eq(c);var g=f.clone(true);g.show().appendTo(d);if(b!==undefined){b(f,g)}f.remove()})}})}})(jQuery)
