//Old functions
var nStories = 10;
var currentDiv = 0;
var animeDiv = null;

function animateContent(frameName, id){
	clearTimeout(animeDiv);
	var lastDiv = currentDiv;
	if((currentDiv+id) >= nStories){
		currentDiv = 0;
	}else{
		if((currentDiv+id) < 0){
			currentDiv = nStories-1;
		}else{
			currentDiv += id;
		}
	}
	var fader1 = new Fadomatic(document.getElementById(frameName+lastDiv), 10, 100);
	var fader2 = new Fadomatic(document.getElementById(frameName+currentDiv), 10, 0);
	fader1.fadeOut();
	fader2.fadeIn();	
	animeDiv = setTimeout('animateContent(\'' + frameName + '\', 1)', 10000);
}

function pauseContent(){
	clearTimeout(animeDiv);
}

function initStories(frameName){
	for(i=1; i < nStories; i++){
		var fader = new Fadomatic(document.getElementById(frameName+i), 5,0);
	}
	animeDiv = setTimeout('animateContent(\'' + frameName + '\', 1)', 10000);
}
//New functions
function EditorialFeature(frame, nStories)
{
    this.frame = frame;
    this.nStories = nStories;
    this.currentDiv = 0;
    for (i = 1; i < this.nStories; i++){
        fader = new Fadomatic(document.getElementById(this.frame + i), 5,0);
    }
    thisObj = this;
    this.animeDiv = setTimeout(function()
                               {
                                   thisObj.animateContent();
                               }, 10000);
}

EditorialFeature.prototype.animateContent = function(plus)
{
    if (typeof plus == "undefined") {
        plus = 1;
    }
    clearTimeout(this.animeDiv);
    lastDiv = this.currentDiv;
    if ((this.currentDiv + plus) >= this.nStories) {
        this.currentDiv = 0;
    } else if ((this.currentDiv + plus) < 0) {
        this.currentDiv = this.nStories - 1;
    } else {
        this.currentDiv += plus;
    }
    fader1 = new Fadomatic(document.getElementById(this.frame + lastDiv), 10, 100);
    fader2 = new Fadomatic(document.getElementById(this.frame + this.currentDiv), 10, 0);
    fader1.fadeOut();
    fader2.fadeIn();    
    this.animeDiv = setTimeout(function()
                               {
                                   thisObj.animateContent();
                               }, 10000);
};

EditorialFeature.prototype.pauseContent = function()
{
    clearTimeout(this.animeDiv);
}


