Pagination = Class.create({ initialize: function (container, options){ this.container = $(container); this.options = Object.extend({ afterPaginate: Prototype.emptyFunction }, options || {}); }, attachHandlers: function(aElements){ aElements.invoke('observe', 'click', function(evt){ var eltURI = evt.element().href; if(eltURI.include('/shop/asp/')) { eltURI +='/ajax/yes'; } else { eltURI = eltURI + "&ajax=yes"; } this.doPaginate(eltURI); Event.stop(evt); return false; }.bindAsEventListener(this)); }, doPaginate: function(url){ new Ajax.Updater(this.container, url, { evalScripts: true, method: 'get', onLoading: function () { $('sandglass').show(); }.bind(this), onComplete: function(){ this.container.hide(); Effect.Appear(this.container, {duration: 1.0}); this.notify('afterPaginate'); $('sandglass').hide(); }.bindAsEventListener(this) }); }, notify: function(event_name){ try{ if(this.options[event_name]) return [this.options[event_name].apply(this.options[event_name],$A(arguments).slice(1))]; }catch(e){ if(e != $break) throw e; else return false; } } });