var HomeBanner = new Class({
	Implements: Options,
	options: {
		imageId: 'home_banner',
		gdStyle: 'home_banner',
		gdLinkStyle: 'home_banner_link',
		gdScript: 'http://www.sutter-group.com/assets/dtr/font.php',
		loop: true,
		leaveLast: true, 
		fadeInTime: 800,
		fadeOutTime: 800,
		timeOpen: 4000,
		waitTime: 1000,
		delayTime: 500
	},
	_phraseArray: [],
	_totalPhrases: 0,
	_currentIndex: 0,
	_element: '',
	_fadeIn: '',
	_fadeOut: '',
	initialize: function(element_id, options) {
		this.setOptions(options);
		this._phraseArray = $$('#' + element_id + ' p');
		this._totalPhrases = this._phraseArray.length;
		this._element = $(element_id);
		this._element.setStyle('opacity', 0);
		this._fadeIn = new Fx.Morph(this._element, {duration:this.options.fadeInTime, link:'cancel', transition:Fx.Transitions.Sine.easeIn});
		this._fadeOut = new Fx.Morph(this._element, {duration:this.options.fadeOutTime, link:'cancel', transition:Fx.Transitions.Sine.easeOut});
		
		if (this._totalPhrases > 0)
		{(function(){this.transition(this._currentIndex);}).delay(this.options.delayTime, this);
		}
		
		if (Browser.Engine.webkit == true)
		{
			this._element.setStyle('margin-top', -10);
		}
	},
	transition: function(index) {
		this._phraseArray[this._currentIndex].removeClass("hidden");
		this._phraseArray[this._currentIndex].setStyle('color', '#ffffff');
		this._fadeIn.start({'opacity': 1});
		if ( (this.options.loop == false) && (this._currentIndex == this._totalPhrases - 1) && (this.options.leaveLast == true) )
		{return;}
		else
		{
			(function(){ this._fadeOut.start({'opacity': 0 }); }).delay(this.options.fadeInTime + this.options.timeOpen, this);
			(function(){this.nextTransition();}).delay(this.options.fadeInTime + this.options.timeOpen + this.options.fadeOutTime + this.options.waitTime, this);
		}
	},
	nextTransition: function() {
		this._phraseArray[this._currentIndex].addClass("hidden");
		if (this._currentIndex + 1 >= this._totalPhrases)
		{
			if ( this.options.loop == false )
			{return;}
			this._currentIndex = 0;	
		}
		else
		{this._currentIndex++;}
		this.transition(this._currentIndex);
	},
	redirect: function() {}});