/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 3.0.0pr2
*/
YUI.add("queue",function(A){A.Queue=function(){var B=this instanceof A.Queue?this:new A.Queue();B.q=[];return B.add.apply(B,arguments);};A.Queue.prototype={id:0,run:function(){var E=this.q[0],C;if(!E){this.fire("end");return this;}else{if(this.id){return this;}}C=E.fn||E;if(typeof C==="function"){var B=E.timeout||0,D=this;if(B<0){this.id=B;if(E.until){for(;!E.until();){this._exec(C,E);}}else{if(E.iterations){for(;E.iterations-->0;){this._exec(C,E);}}else{this._exec(C,E);}}this._shift();this.id=0;return this.run();}else{if(E.until){if(E.until()){this._shift();return this.run();}}else{if(!E.iterations||!--E.iterations){this._shift();}}this.id=setTimeout(function(){D._exec(C,E);if(D.id){D.id=0;D.run();}},B);}}return this;},_exec:function(B,C){this.fire("beforeCallback",{fn:B,callback:C});B.call(this);this.fire("afterCallback",{fn:B,callback:C});},_shift:function(){this.fire("shiftCallback",this.q.shift());},add:function(){var B=A.Array(arguments,0,true);this.q.splice.apply(this.q,[this.q.length,0].concat(B));this.fire("addCallback",B);return this;},pause:function(){clearTimeout(this.id);this.id=0;this.fire("pause");return this;},stop:function(){this.pause();this.q=[];this.fire("stop");return this;}};A.augment(A.Queue,A.Event.Target);},"3.0.0pr2",{requires:["event"]});