
var Rotator = new Class(
{
	initialize: function()
	{
		this.index = 0;
		
		$('animation').setStyle('opacity', 0);
		
		this.whatif = $$('img.whatif')[0];
		//this.whatif.setStyle('opacity', 0);
		
		this.wewant = $$('h3')[0];
		//this.wewant.setStyle('opacity', 0);
		
		this.txt = $$('img.txt')[0];
		//this.txt.setStyle('opacity', 0);
		
		this.images = [
		               {alt:'women influenced halh of corporate decisions?', src:'img/whatif1.gif', width:306, height:109},
		               {alt:'women had a say in creating every Ohio companys vision?', src:'img/whatif2.gif', width:363, height:117},
		               {alt:'corporate board leaders were diverse, too? ', src:'img/whatif3.gif', width:299, height:114}
		              ];
		
		//this.tween1 = new Fx.Tween(this.whatif,{duration:600});
		this.tween2 = new Fx.Tween(this.txt, {duration:600});
		//this.tween3 = new Fx.Tween(this.wewant, {duration:600});
		
		
		(function()
		{
			$('animation').tween('opacity',1);
		}).delay(350);
		
		this.fadeOut.delay(4500, this);
		//this.fadeIn();
	},
	
	fadeOut: function()
	{	
		//this.tween1.start('opacity', 0);
		this.tween2.start('opacity', 0);
		//this.tween3.start('opacity', 0);
		
		this.index++;
		if (this.index >= this.images.length) this.index = 0;
		
		this.fadeIn.delay(1000, this);
	},
	
	fadeIn: function()
	{
		this.txt.setProperty('alt', this.images[this.index].alt);
		this.txt.setProperty('src', this.images[this.index].src);
		this.txt.setProperty('width', this.images[this.index].width);
		this.txt.setProperty('height', this.images[this.index].height);
		
		//this.show(this.tween1).chain(this.show2.bind(this));
		
		this.tween2.start('opacity', 1);
		this.fadeOut.delay(4500, this);
	},
	
	show: function(tween)
	{
		return tween.start('opacity', 1);
	},
	
	show2: function()
	{
		this.show(this.tween2).chain(this.show.bind(this,this.tween3));
	}
});

window.addEvent('domready', function()
{
	new Rotator();
});
