/*
 * jQuery FxQueues 2.0.3
 * Copyright 2009 Luciano German Panaro <contact@decodeuri.com>
 * Released under the MIT and GPL licenses.
 */

(function(c){var a=function(e){return{name:e,isFxQueue:true,paused:false,playing:null,shouldStart:function(){return(this.playing==null||!this.paused)},pause:function(){if(!this.playing){return false}((this.playing.isScope)?this.playing:this.playing.elem).stop();this.paused=true;return true},stop:function(){if(!this.playing){return false}((this.playing.isScope)?this.playing:this.playing.elem).stop();this.playing=null;this.paused=false;this.length=0;return true},start:function(){if(this.playing&&this.paused){this.playing();this.paused=false;return true}else{if(this.length&&!this.playing){this.playing=this[0];c(document).dequeue(this.name);return true}}return false},getScope:function(f){if(this.playing&&this.playing.isScope&&this.playing.called==f){return this.playing}for(var g=0;g<this.length;g++){if(this[g].isScope&&this[g].called==f){return this[g]}}return false},dequeue:function(g){if(!this.playing){return false}if(this.playing.isScope){var j=this.playing.items;for(var h=0;h<j.length;h++){if(g==j[h].elem[0]&&!j[h].finished){j[h].finished=true;this.playing.finishedItems++}}if(this.playing.finishedItems<j.length){return false}}else{if(this.playing.elem&&this.playing.elem[0]!=g){return false}}var f=this;setTimeout(function(){f.playing=f[0];c(document).dequeue(f.name)},this.playing.postDelay);return true}}};var b=function(e){var f=function(){for(var g=0;g<f.items.length;g++){f.items[g]()}};f.called=e;f.isScope=true;f.finishedItems=0;f.stop=function(){for(var g=0;g<f.items.length;g++){f.items[g].elem.stop()}};f.items=[];return f};var d=c.fn.animate;c.fn.animate=function(j,f,i,l){if(!this.length){return this}var o=(typeof f=="object")?f:c.speed(f,i,l);var e=c.extend({queue:"fx",position:"end",limit:-1,preDelay:0,postDelay:0,complete:null},o);if(!e.queue||e.queue=="fx"){return d.apply(this,arguments)}var g=e.queue;var h=c(document).queue(e.queue);if(!h.isFxQueue){c.extend(h,a(g))}e.queue=false;var k=function(){e.complete=function(){h.dequeue(this);if(c.isFunction(k.users_complete)){return k.users_complete.apply(this,arguments)}};setTimeout(function(){k.elem.animate(j,e)},k.preDelay)};k.elem=this;k.preDelay=e.preDelay||0;k.postDelay=e.postDelay||0;k.users_complete=f.complete||l;var n=h.getScope(e.scope);if(n){n.items.push(k);if(h.playing==n){k()}return this}if(e.limit<0||h.length<e.limit){var m=null;if(e.scope){m=b(e.scope);m.items.push(k)}else{m=k}if(e.position=="end"){h.push(m)}else{if(e.position=="front"){h.splice(1,0,m)}}if(h.shouldStart()){h.start()}return this}};c.extend({fxqueue:function(e){return c(document).queue(e)}})})(jQuery);