/*
 * jQuery UI Ringce SLider
 * version: 0.1b (2009-10-24)
 * @requires jQuery v1.3.1 or later
 * @requires jQuery UI v1.7 or later

 * Examples and documentation at: http://code.ringce.com
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */                                                                        
 
(function($) { 
$.widget("ui.ringceSlider",{

    _init: function(){     
        var widget = this;
        $(this.options.items).hide();
        $(this.element).addClass('playing');
        this.select();    
        timer = setInterval(function(){widget.select();}, widget.options.pause);                                                                             
        $(this.element).unbind('click') .bind('click', function(e){
           if($(widget.element).hasClass('playing')){
               clearInterval(timer);
               $(widget.element).removeClass('playing');
           } else {
              $(widget.element).addClass('playing');                                                                          
              timer = setInterval(function(){widget.select();}, widget.options.pause);    
           }
        });
    },                    
    select: function(){                
       var nowShowing = $(this.options.items + ":visible");
       var next = nowShowing.next();  
       if (next.length == 0){
           next = $(this.options.items + ":first");
       }
       var atts = {height:'toggle',  opacity:'toggle'};
       widget = this;      
       nowShowing.animate(atts, {queue:false, 
           easing:this.options.hideAnimation, duration:this.options.hideDuration,
              complete:function(){
                  $(this).hide();
              }});  
       next.animate(atts, {queue:false, 
           easing:this.options.showAnimation, 
           duration:this.options.showDuration,
              complete:function(){
                  $(this).show();                   
              }});               
              

    }
});      
    
$.extend($.ui.ringceSlider, {
   defaults: {
       items: '.items',
       hideAnimation: 'easeOutExpo',  
       hideDuration: 200,
       showAnimation: 'easeInQuad',    
       showDuration: 1000,
       pause: 8000
   }
 });          
})(jQuery);
