/**
 * JavaScript file which causes the phrases on the left side of the
 * home page image to slowly slide into view.
 *
 * Requires
 *  - prototype.js >= 1.6.0
 *  - effects.js >= 1.8.1 (from scriptaculous library)
 */
 
var CHomeAnimation = Class.create();

CHomeAnimation.prototype = {

	initialize : function() {
		// First, hide all of the divs
		$$('#home-image-left-text div').each(
			function(oDiv, iIdx) {
				oDiv.hide();
			}
		);
		
		if ($('home-image-center-text')) {
			$('home-image-center-text').hide();
		}
	},
	
	start : function() {
		this._recursivelyAnimateBullet($('home-image-left-text').down('div'));
	},
	
	_animateCenter : function() {
		Effect.BlindDown(
			'home-image-center-text',
			{
				duration: 1.5
			});
	},
	
	_recursivelyAnimateBullet : function(oDiv) {
		if (!oDiv) {
			if ($('home-image-center-text')) {
				this._animateCenter();
			}
			return;
		}
		Effect.BlindDown(
			oDiv,
			{
				duration: 1.5,
				afterFinish: function() {
					this._recursivelyAnimateBullet(oDiv.next('div'));
				}.bind(this)
			});
	}

};

// Run the link animator when the DOM is loaded
FastInit.addOnLoad(function() { new CHomeAnimation().start() });