// Speed up the effect from the default time.
Effect.DefaultOptions.duration=0.3;

// Class: TextFader
TextFader = Class.create();
Object.extend(
	TextFader.prototype,
	{
		textId:			"textbar_text",
		pauseLength:	5000,
		timer:			0,
		currentItem:	0,
		items:			["Our 42nd year serving the scientific community.", "Specializes in HPLC systems components and accessories.", "Source for products for the analytical chemistry and life science laboratory.", "Provides expert sales and service for these and many other scientific products."],
		initialize:		function()
		{
			this.start()
		},
		start:function()
		{
			this.interval=setInterval(this.showNext.bind(this),this.pauseLength)
		},
		showNext:function()
		{
			if(this.currentItem < this.items.length-1)
			{
				this.currentItem = this.currentItem + 1
			}
			else
			{
				this.currentItem = 0
			}
			new Effect.Fade(
				this.textId,
				{
					afterFinish:function()
					{
						this.switchData();
						new Effect.Appear(this.textId)
					}.bind(this)
				}
			)
		},
		switchData:function()
		{
			if(this.items[this.currentItem])
			{
				$(this.textId).innerHTML=this.items[this.currentItem]
			}
		}
	}
);

// Create the object when the window loads, which will call the initialize
// function and start the fader.
Event.observe(window, "load", function(){var fader=new TextFader()} );
