/**
 * @author Alec Hill
 */
var Ah={};Ah.DetachableEvents=new Class({detachableEvents:new Hash(),detachEvent:function(A){var B=this.detachableEvents.get(A);B.obj.removeEvent(B.type,B.fn);return this;},addDetachableEvent:function(A,D,C,B){D.addEvent(C,B);this.detachableEvents.set(A,{obj:D,type:C,fn:B});return this;},removeDetachableEvents:function(){this.detachableEvents.each(function(B,A){this.detach(A);},this);this.detachableEvents.empty();}});Element.implement({previousValue:null,observe:function(C,A,B){var A=A||500;this.previousValue=this.get("value");(function(D){var E=this.get("value");if(E!=this.previousValue&&E!=""){C.attempt(D);this.previousValue=E;}}).periodical(A,this,B);}});Element.implement({show:function(){this.setStyle("display","block");},hide:function(){this.setStyle("display","none");},visible:function(){this.setStyle("visibility","visible");},invisible:function(){this.setStyle("visibility","hidden");}});Ah.Collection=new Class({Implements:[Events,Ah.DetachableEvents],name:"Collection",items:null,pointer:null,options:{rotate:true},initialize:function(A,B){this.pointer=0;this.items=new Hash();this.items.merge(A);this.setOptions(B);this.fireEvent("onInitialize");},setRotate:function(A){this.options.rotate=A;return this;},key:function(){return this.items.getKeys()[this.pointer];},current:function(){return this.items.get(this.key());},firstKey:function(){return this.items.getKeys()[0];},lastKey:function(){return this.items.getKeys()[this.items.getLength()-1];},nextKey:function(){return this.items.getKeys()[this.pointer+1];},previousKey:function(){return this.items.getKeys()[this.pointer-1];},f:function(){if(this.pointer!=0){this.pointer=0;this.onChange();}return this;},l:function(){var A=this.items.getLength()-1;var B=this.pointer;this.pointer=(A>=0)?A:0;if(this.pointer!=B){this.onChange();}return this;},n:function(){var A=this.nextKey();if($defined(A)){this.pointer++;this.onChange();}else{if(this.options.rotate){this.f();}}return this;},p:function(){var A=this.previousKey();if($defined(A)){this.pointer--;this.onChange();}else{if(this.options.rotate){this.l();}}return this;},t:function(B){var A=this.getKeys().indexOf(B);if(A!=-1){this.pointer=A;this.onChange();}return this;},first:function(){this.f();return this.current();},last:function(){this.l();return this.current();},next:function(){this.n();return this.current();},previous:function(){this.p();return this.current();},to:function(A){this.t(A);return this.current();},onChange:function(){this.fireEvent("onChange",{key:this.key(),value:this.current()});},getLength:function(){return this.items.getLength();},forEach:function(A,B){return this.items.forEach(A,B);},getClean:function(){return this.items.getClean();},has:function(A){return this.items.has(A);},keyOf:function(A){return this.items.keyOf(A);},hasValue:function(A){return this.items.hasValue(A);},extend:function(A){this.items.extend(A);return this;},merge:function(A){this.items.merge(A);return this;},remove:function(A){this.items.remove(A);return this;},get:function(A){return this.items.get(A);},set:function(A,B){this.items.set(A,B);return this;},empty:function(){this.items.empty();this.pointer=0;return this;},include:function(A,B){return this.items.include(A,B);},map:function(A,B){return this.items.map(A,B);},filter:function(A,B){return this.items.filter(A,B);},every:function(A,B){return this.items.every(A,B);},some:function(A,B){return this.items.some(A,B);},getKeys:function(){return this.items.getKeys();},getValues:function(){return this.items.getValues();},toQueryString:function(){return this.items.toQueryString();},indexOf:function(A){return this.keyOf(A);},contains:function(A){return this.hasValue(A);},erase:function(A){return this.remove(A);},each:function(A,B){return this.forEach(A,B);}});
