function homepageHero(v1, v2, v3)
{
	var self = this;
	this.storiesContainer = false;
	this.stories = false;
	this.buttons = { };
	this.heroContainer = false;
	
	this.interval = false;
	this.timeout = false;
	this.playing = false;
	this.startTime = 8.0;
	this.reStartTime = 3.0;
	this.slideTime = 7.0;
	
	this.lastSlide = 0;
	
	this.count = 0;

	this.init = function(containerId, storiesContainerId, stories)
	{
		var self = this;
		this.stories = stories;
		this.storiesContainer = document.getElementById(storiesContainerId);
		this.storiesContainer.onmouseover = function() { self.pause(); };
		this.storiesContainer.onmouseout = function() { self.unpause(); };
		
		var container = document.getElementById(containerId);
		this.heroContainer = container;
		this.heroContainer.onmouseover = function() { self.pause(); };
		this.heroContainer.onmouseout = function() { self.unpause(); };
		var elements = container.getElementsByTagName("A");

		for(var i = 0; i < elements.length; i++)
		{
			this.buttons[i] = { };
			this.buttons[i].title = elements[i].parentNode.className
			this.buttons[i].elmt = elements[i];
			elements[i].section = elements[i].parentNode.className;
			elements[i].onclick = function() { self.set(this.section); return false; };
			this.count++;
		}
		this.set(this.stories.lastSection);
		this.play(true);
	}
	
	this.set = function(section)
	{
		for(key in this.buttons){
			if(this.buttons[key]['title'] == section){
				this.buttons[key]['elmt'].className = "on";
				this.lastSlide = parseInt(key);
			}
			else {
				this.buttons[key]['elmt'].className = "";
			}
		}
		this.storiesContainer.className = section;
		this.heroContainer.className = 'clearing '+ section;
		this.stories.set(section, 0);
	}
	
	this.play = function(first){
		if(!this.interval && !this.timeout){
			var self = this;
			this.timeout = setTimeout(function() { self.begin(); }, (first ? this.startTime : this.reStartTime) * 1000);
		}
		this.playing = true;
	}
	
	this.begin = function(){
		var self = this;
		this.timeout = false;
		//this.tweenNextSlide();
		console.log('Begin');
		this.interval = setInterval(function() {
		 //self.tweenNextSlide()
		 self.test();
		}, this.slideTime * 1000);
		
	}
	
	this.test = function(){
		if(this.count==this.lastSlide+1){
			this.set(this.buttons[0].title);
		}
		else {
			var i = parseInt(this.lastSlide)+1;
			this.set(this.buttons[i].title);
		}
	}
	
	this.pause = function(){
		if(this.interval)
		{
			clearInterval(this.interval);
			this.interval = false;
		}
		if(this.timeout)
		{
			clearTimeout(this.timeout);
			this.timeout = false;
		}
		console.log('Pause');
	}
	
	this.unpause = function(){
		if(this.playing)
			console.log('unpause');
			this.play(false);
			
	}

	this.init(v1, v2, v3);
}
