function Feature(id, data, inactiveClass, activeClass) {
	this.buttons = new Array();
	this.currentButton = -1;
	this.imageObj = null;
	this.newImageObj = null;
	this.linkObj = null;
	this.loaderObj = null;
	this.id = id;
	this.data = data
	this.slideshowTimeout = null;
	this.slideshowDelay = 5000;
	this.inactiveClass = inactiveClass;
	this.activeClass = activeClass;
	this.disabled = true;
	
	this.changeButtons = function(index) {
		this.buttons[this.currentButton].className = this.inactiveClass;
		this.buttons[index].className = this.activeClass;
		this.currentButton = index;
	}
	
	this.startAnimation = function(i,step) {
		switch (step) {
			case 1:
				this.newImageObj = document.createElement('img');
				this.newImageObj.feature = this;
				this.newImageObj.index = i;
				this.newImageObj.className = "new-feature";
				this.newImageObj.onload = function() {
					this.feature.startAnimation(this.index,2);
				}
				this.newImageObj.src = this.data[i].img;
				project.AnimationManager.setAlpha(this.newImageObj,0);
				
				this.imageObj.parentNode.appendChild(this.newImageObj);
				this.loaderObj.style.display = "block";
			break;
			case 2:
				this.linkObj.href = this.data[i].href;
				var o = this;
				project.AnimationManager.addAnimation(this.newImageObj,"alpha",0,10,0,1,0,true,0,100,function(){o.startAnimation(null,3);},this.id);
			break;
			case 3:
				this.loaderObj.style.display = "none";
				this.imageObj.parentNode.removeChild(this.imageObj);
				this.newImageObj.className = "";
				this.imageObj = this.newImageObj;
				this.newImageObj = null;	
				this.disabled = false;
				this.startSlideshow();
			break;
		}
	}
	
	this.manageChange = function(i) {
		if (!this.disabled && i!=this.currentButton) {
			this.disabled = true;
			if (this.slideshowTimeout != null) clearTimeout(this.slideshowTimeout);
			this.changeButtons(i);
			this.startAnimation(i,1);
		}
	}
	
	this.nextImage = function() {
		if (this.currentButton==this.buttons.length-1) var next = 0;
		else var next = this.currentButton+1;
		this.manageChange(next);
	}
	
	this.startSlideshow = function() {
		var o = this;
		this.slideshowTimeout = setTimeout(function(){o.nextImage();},this.slideshowDelay);
	}
	
	this.initialize = function() {
		this.imageObj = $(this.id+"_Image");
		this.linkObj = $(this.id+"_Link");
		this.loaderObj = $(this.id+"_Loader");
		
		var bH = $(this.id+"_Buttons");
		for (var i=0; i<bH.childNodes.length; i++) {
			var obj = bH.childNodes[i];
			if (obj.tagName == 'A') {
				obj.style.outline = "none";
				obj.index = this.buttons.length;
				obj.feature = this;
				obj.onclick = function(e) {
					this.feature.manageChange(this.index);
					if (e) e.preventDefault();
					else if (window.event) window.event.returnValue = false;
					return false;
				}
				this.buttons.push(obj);
			}
		}
		
		this.currentButton = 0;	
		this.buttons[this.currentButton].className = this.activeClass;
		this.disabled = false;
		this.startSlideshow();
	}
}
