

var TestimonialTicker = new Class({

	Implements: [Options, Events],

	options: {
	
	},

	_insertionPoint: null,
	_storage: null,
	
	initialize: function(insertionPoint, storage)
	{
		this._insertionPoint = $(insertionPoint);
		this._storage = $(storage);
		var list = this._storage.getElements("blockquote");
		list.each(function(element) {
			element.setStyle("display", "none");
		});
		this._storage.setStyle("display", "none");
		this._moveStart();
	},

	_moveStart: function()
	{
		// get any item currently in the container
		if (this._insertionPoint.getNext("blockquote"))
		{
			this._insertionPoint.getNext("blockquote").setStyle("display", "none");
			this._insertionPoint.getNext("blockquote").fade("in");
			// append to the end of storage
			this._insertionPoint.getNext("blockquote").inject(this._storage.getFirst("div"), "bottom");
		}
		// get the first item from the storage
		var item = this._storage.getFirst("div").getFirst("blockquote");
		item.setStyle("display", "block");
		item.setStyle("margin-top", "300px");
		//item.setStyle("opacity", 1);
		//item.setStyle("filter", "alpha(opacity=100)");
		item.inject(this._insertionPoint, "after");
		var morph = new Fx.Morph(item, {transition: Fx.Transitions.Linear, duration: 3000});
		morph.addEvent("complete", this._moveCompleted.bindWithEvent(this));
		morph.start({"margin-top": [300, 0]});
	},

	_moveCompleted: function()
	{
		this._fadeStart.delay(3000, this);
	},

	_fadeStart: function()
	{
		var item = this._insertionPoint.getNext("blockquote");
		// fade out the item
		var morph = new Fx.Morph(item, {transition: Fx.Transitions.Linear, duration: 1000});
		var coords = item.getCoordinates();
		var newTop = 0 - coords.height;
		morph.addEvent("complete", this._moveStart.bindWithEvent(this));
		morph.start({"margin-top": [0, newTop]});
	}

});
