function callback(a,c){var b=Array.prototype.slice.call(arguments).slice(2);if(typeof a=="function")return a.apply(c||this,b)}function galleryObject(a){this.name="Gallery Object";this.windowEle=a.windowEle;this.slideEle=this.windowEle.find("ul:first");this.li=this.slideEle.find("li");this.btn_l=a.button_l;this.btn_r=a.button_r;this.groups=a.groups||1;this.showNum=a.showNum||1}
galleryObject.prototype={cv:0,origin:0,end:0,isOrigin:function(a){return a>this.origin?true:false},isEnd:function(a){return a<this.end?true:false},init:function(){var a=this;this.inShowArea();this.setUlWidth();this.end=-this.allWidth()+this.liWidth();this.btn_l.click(function(){callback(function(){this.scroll("l")},a);return false});this.btn_r.click(function(){callback(function(){this.scroll("r")},a);return false})},liWidth:function(){return this.li.first().width()},liLen:function(){return this.li.size()},
allWidth:function(){return this.liWidth()*this.liLen()},setUlWidth:function(){this.slideEle.css("width",this.allWidth())},distance:function(){return this.liWidth()*this.groups},durPx:function(a){return a=="l"?this.cv+this.distance():this.cv-this.distance()},scroll:function(a,c){var b=this.durPx(a),d=this;if(this.isOrigin(b)==true)b=0;if(this.isEnd(b)==true)b=this.end;this.slideEle.animate({marginLeft:c||b},1E3,function(){d.cv=parseInt($(this).css("marginLeft"))})},findCurr:function(){return this.li.filter(".nowstyle")},
getcurrEq:function(){return this.li.index(this.findCurr())},inShowArea:function(){var a=-this.getcurrEq()*this.liWidth(),c=parseInt(this.slideEle.css("marginLeft")),b=c-this.showNum*this.liWidth();if(a<=b||a>c)this.scroll("r",a)}};var galler=new galleryObject({windowEle:$("#thumbs-wrap"),button_l:$("#button-l"),button_r:$("#button-r"),groups:1,showNum:5});galler.init();
