
var BajaxScroller = Class.create(); var BajaxScrollerAuto = Class.create(); function DisableScrollerEvent(effect) {
var t = effect.element.scroller; t.disable((t.direction == 'right') ? t.right : t.left); }
function DisableScrollerEvent2(effect) {
var t = effect.element.scroller; t.direction = ('left' == t.direction) ? 'right' : 'left'; t.move(null); }
BajaxScrollerAuto.prototype = {
initialize: function(_scrollobj) {
this.scrollobj = $(_scrollobj); this.scrollobj.scroller = this; this.direction = 'right'; this.start = parseFloat(this.scrollobj.getStyle('left') || 0); this.move(null); },
move: function(event) {
var foo = $(this.scrollobj); if (Object.isUndefined(foo)) {
foo = $(event.element()); if (!foo.match('.scroller-container')) foo = foo.up('.scroller-container'); }
var width = parseFloat(foo.down('table').getWidth()); var area = parseFloat(foo.up('div').getWidth()); var current = parseFloat(foo.getStyle('left') || 0); var scrolled = foo.scroller.start - current; var amount = scrolled; if (foo.scroller.direction == 'right') amount = -(width - area - scrolled); var dur = .035 * Math.abs(amount); foo.scroller.stop(event); foo.scroller.effect = new Effect.MoveBy(foo, 0, amount,
{
duration: dur,
delay: 0,
afterFinish: DisableScrollerEvent2,
transition: Effect.Transitions.linear,
fps: 15
}); },
stop: function(event) {
if (this.effect) {
this.effect.cancel(); var s = this.scrollobj; var func = function(event) {
if (!event.element().match('#' + $(s).identify() + ' *')) {
Event.stopObserving(document, 'mouseover', func); }
}; Event.observe(document, 'mouseover', func); }
}
}; BajaxScroller.prototype = {
reset: function() {
var width = parseFloat(this.scrollobj.down('table').getWidth()); var area = parseFloat(this.scrollobj.up('div').getWidth()); if (width < area) {
this.disable(this.left); this.disable(this.right); return true; } else {
this.disable(this.left); this.enable(this.right); return false; }
},
initialize: function(scrollobj2, left2, right2) {
this.scrollobj = scrollobj2; this.scrollobj.scroller = this; this.direction = ''; this.left = left2.down("img"); this.right = right2.down("img"); this.start = parseFloat(this.scrollobj.getStyle('left') || 0); this.left.observe('mouseover', this.move); this.right.observe('mouseover', this.move); this.left.scroller = this; this.right.scroller = this; this.left.observe('mouseout', this.stop); this.right.observe('mouseout', this.stop); this.disable(this.left); },
move: function(event) {
if (this.scroller.reset()) { return; }
var obj = event.element(); var width = parseFloat(this.scroller.scrollobj.down('table').getWidth()); var area = parseFloat(this.scroller.scrollobj.up('div').getWidth()); var current = parseFloat(this.scroller.scrollobj.getStyle('left') || 0); var scrolled = this.scroller.start - current; var amount = scrolled; if (obj == this.scroller.right) amount = -(width - area - scrolled); if (amount == 0) {
this.scroller.disable(obj); return; }
this.scroller.direction = (obj == this.scroller.right) ? 'right' : 'left'; var dur = .009 * Math.abs(amount); this.scroller.stop(event); this.scroller.scroller = new Effect.MoveBy(this.scroller.scrollobj, 0, amount,
{
duration: dur,
delay: 0.4,
afterFinish: DisableScrollerEvent
}); this.scroller.enable(this.scroller.left); this.scroller.enable(this.scroller.right); },
disable: function(obj) {
if (Prototype.Browser.IE) {
obj.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=1)'; }
new Effect.Opacity(obj, {
duration: 0.5,
transition: Effect.Transitions.linear,
from: obj.getStyle('opacity'),
to: 0.3
}); },
enable: function(obj) {
new Effect.Opacity(obj, {
duration: 0.5,
transition: Effect.Transitions.linear,
from: obj.getStyle('opacity'),
to: 1.0
}); if (Prototype.Browser.IE) {
obj.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=0)'; }
},
stop: function(event) {
var obj = event.element(); if (obj.scroller.scroller) obj.scroller.scroller.cancel(); }
}; 
