Equens.ContentBanner = function(node) {
	this.rootNode = node;
	this.items = new Array();
	this.currentItemIndex = 0;
	this.timer =  null;
	this.timerSec = 8000;
	this.init();
}

Equens.ContentBanner.prototype.init = function() {
	var _this = this;
	this.items = $('.banner-panel', this.rootNode);
	var l = this.items.length;
	for (var i = l; i--;) {
		if (i != 0) {
			$(this.items[i]).hide();
		}
		$(this.items[i]).bind("mouseover", function(){_this.onMouseOver(); return false;});
		$(this.items[i]).bind("mouseout", function(){_this.onMouseOut(); return false;});
	}
	this.timer = setTimeout(function(){_this.runTimer()},this.timerSec);
}

Equens.ContentBanner.prototype.runTimer = function(e) {
	this.loadItem();
	var _this = this;
	this.timer = setTimeout(function(e){_this.runTimer()},this.timerSec);
}

Equens.ContentBanner.prototype.loadItem = function() {
	var _this = this;
	var l = this.items.length;
	var currentItemIndex = this.currentItemIndex;
	var newIndex = currentItemIndex+1 < l ? currentItemIndex+1 : 0;
	$(this.items[currentItemIndex]).css("z-index", "0");
	$(this.items[newIndex]).css("z-index", "1").fadeIn(1000, function(){$(_this.items[currentItemIndex]).hide()});
	this.currentItemIndex = newIndex;
}

Equens.ContentBanner.prototype.onMouseOver = function() {
	clearTimeout(this.timer);
}
Equens.ContentBanner.prototype.onMouseOut = function() {
	var _this = this;
	this.timer = setTimeout(function(e){_this.runTimer()},this.timerSec);
}