/**
 * Document   : Rotator.js
 * Created on : May 15, 2010, 7:50:18 PM
 * @author Jeremy Wischusen
 */
/**
 * Comment
 */
function Rotator(contentNode) {
    this.elem = jQuery(contentNode);
    this.items = this.elem.children();
    this.elem.children().hide();
    this.elem.children().addClass('rotated');
    this.speed = 5000;
     jQuery(this.items[0]).fadeIn(this.speed)
    this.timer = null
    this.index =0;
    this.seconds = 10;
}

Rotator.prototype.start = function(){
    var thisClass = this
    this.timer = setInterval (function (){
        thisClass.next();
    }, this.seconds * 1000)
}

Rotator.prototype.next= function(){
    jQuery(this.items[this.index]).fadeOut(this.speed)
    if(this.index>=(this.items.length-1)){
        this.index = 0;
    }else{
        this.index++
    }
    jQuery(this.items[this.index]).fadeIn(this.speed)
}

Rotator.prototype.stop= function (){
    if (!this.timer){
        return;
    }
    clearInterval(this.timer);
    this.timer = null;
}

