/*!
 * jQuery Outin plugin.
 * 
 * Copyright 2011, Veselin Todorov
 * 
 * Licensed under the MIT License.
 */(function(a){function b(a,b){this.init(a,b),this.config.autoStart===!0&&this.start()}b.version="1.0.1",b.defaults={autoStart:!0,controls:!0,duration:1e3,interval:4e3},b.html={controls:"outin-controls",control:"outin-controls-current"},b.prototype.init=function(c,d){this.config=a.extend(b.defaults,d);if(this.config.duration>this.config.interval)throw new Error("The interval must be greater than the duration.");this.base=a(c),this.controls=null,this.step=0,this.interval=null,this.busy=!1,this.base.find("li").not(":first").hide(),this.config.controls===!0&&this.appendControls()},b.prototype.start=function(){var a=this,b=function(){a.next()};this.interval=setInterval(b,this.config.interval)},b.prototype.stop=function(){clearInterval(this.interval)},b.prototype.next=function(){var a=this.step+1;this.base.find("li").eq(a).length||(a=0),this.show(a)},b.prototype.show=function(a){if(a===this.step||this.busy===!0)return;var b=this.base.find("li").eq(this.step),c=this.base.find("li").eq(a);b.css("z-index",99),c.css("z-index",98).show(),this.busy=!0,this.control(a);var d=this;b.fadeOut(this.duration,function(){d.step=a,d.busy=!1})},b.prototype.appendControls=function(){this.controls=a("<ul>").addClass(b.html.controls).insertAfter(this.base);var c=a("<li>").append('<a href="#"></a>'),d=this;this.base.find("li").each(function(){c.clone().appendTo(d.controls)}),this.control(0),this.controls.find("li").bind("click",function(b){b.preventDefault(),d.show(a(this,this.base).index()),d.stop()})},b.prototype.control=function(a){this.controls.find("li").removeClass(b.html.control),this.controls.find("li").eq(a).addClass(b.html.control)},a.fn.outin=function(a){return this.each(function(){new b(this,a)})}})(jQuery)

