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