(function(a){a.fn.extend({islider:function(c){var d={siftSpeed:4500,actionPause:8000,thumbsHeight:135,areaHeight:405,transitionSpeed:700},b=a.extend(d,c);return this.each(function(){var h=b,g=a(this).attr("id"),q=a("#"+g+" #gallery img"),p=a("#"+g+" #thumbs"),l=a("#"+g+" #thumbs img"),t=a("#"+g+" #thumbs ul"),m=a("#"+g+" #thumbs li"),f=a("#"+g+" a#next"),n=m.length-1,r,e;m.slice(0,1).clone().attr("rel","2").appendTo(t);m.slice(1,2).clone().attr("rel","2").appendTo(t);m.slice(2,3).clone().attr("rel","2").appendTo(t);for(i=0;i<l.length;i++){r=(q.length-i-1);a(q[i]).addClass("image-"+r)}t.children().each(function(u,o){t.prepend(o)});f.click(function(){k();clearInterval(o);var o=setTimeout(j,h.actionPause);return false});s(n);e=setInterval(function(){k()},h.siftSpeed);function k(o){if(o){n=o}if(n<l.length&&n>0){n-=1}else{n=l.length-1}s(n)}function s(o){q.fadeOut(h.transitionSpeed);a("#"+g+" img.image-"+o).stop().fadeIn(h.transitionSpeed);var u=(o*h.thumbsHeight)-h.areaHeight;if(u<400){u=u+h.areaHeight}if(o==m.length-1||o>m.length-4){p.stop().animate({scrollTop:u+h.thumbsHeight},-1).animate({scrollTop:u},h.transitionSpeed);console.log("number: "+o,", scrollPos: "+u+"+"+h.thumbsHeight,", duration: -1")}else{p.stop().animate({scrollTop:u},h.transitionSpeed)}}function j(){clearInterval(e);e=setInterval(function(){k()},h.siftSpeed)}})}})})(jQuery);
