jImageScroller = function($object, imgs, starti){$object.empty();$object.css('margin-left', 0);this._$object = $object;this._imgs = imgs;this._object = {};this._imglop = [];this._lasti = 0;this._ofi = 0;this._oli = 0;this._ox = 0;this._otx = 0;this._ow = 0;this._osize = $object.width();this._ohang = this._osize;if (starti) {this._ofi = starti;this._oli = starti;this._lasti = starti;this.pick(starti);} else {this.pick(0);}this._ox = this._otx;this._update();var self = this;setInterval(function() {self._update();}, jQuery.fx.interval);};jImageScroller.prototype = {_getimagedata: function(i) {var img = this._imgs[Math.mod(i, this._imgs.length)];return {url: img[0], width: img[1]};},_createimage: function(i) {var img = this._getimagedata(i);var $img = $('<img>');$img.attr('src', img.url);$img.attr('width', img.width);$img.css('opacity', 0.3);if (i == this._lasti) {$img.fadeTo(200, 1.0);}var self = this;$img.mousedown(function(event) {if (event.which == 1) {event.preventDefault();self.onpick(i);self.pick(i);}});this._imglop[i] = $img;return $img;},_removeimage: function(i) {if (this._imglop[i]) {this._imglop[i].remove();this._imglop[i] = undefined;}},pick: function(i) {var x = this._getimagedata(i).width / 2 - this._osize / 2;if (i >= this._ofi) {for(var ii = this._ofi; ii < i; ii++) {x += this._getimagedata(ii).width;}} else {for(var ii = i; ii < this._ofi; ii++) {x -= this._getimagedata(ii).width;}}this._otx = x;if (i != this._lasti) {if (this._imglop[this._lasti]) {this._imglop[this._lasti].fadeTo(200, 0.5);}if (this._imglop[i]) {this._imglop[i].fadeTo(200, 1.0);}}this._lasti = i;},prev: function() {this.pick(this._lasti - 1);},next: function() {this.pick(this._lasti + 1);},_update: function() {if (Math.abs(this._otx - this._ox) < 0.5) {this._ox = this._otx;} else {this._ox += (this._otx - this._ox) / 5;}while (this._ox > this._ohang + this._getimagedata(this._ofi).width) {var img = this._getimagedata(this._ofi);this._removeimage(this._ofi);this._ox -= img.width;this._otx -= img.width;this._ow -= img.width;this._ofi++;}while (this._ow - this._ox < this._osize + this._ohang) {var img = this._getimagedata(this._oli);this._$object.append(this._createimage(this._oli));this._ow += img.width;this._oli++;}while (this._ox < this._ohang) {this._ofi--;var img = this._getimagedata(this._ofi);this._$object.prepend(this._createimage(this._ofi));this._ox += img.width;this._otx += img.width;this._ow += img.width;}while (this._ow - this._ox > this._osize + this._ohang + this._getimagedata(this._oli - 1).width) {this._oli--;var img = this._getimagedata(this._oli);this._removeimage(this._oli);this._ow -= img.width;}this._$object.css('margin-left', -this._ox + 'px');}};
