var quotes = new function() {
	this.change_delay = 10000;
	this.animate_delay = 500;
	this.container = '#quotes';
	this.child_prefix = '#quote-';
	
	this.container_style =
		{
			'position' : 'relative'
		};
	this.child_style =
		{
			'position' : 'absolute',
			'top' : 20,
			'left' : 20,
			'right' : 10
		};
	this.child_current_style =
		{
			'z-index' : 10,
			'display' : 'block',
			'opacity' : 1
		};
	this.child_next_style =
		{
			'z-index' : 9,
			'display' : 'block',
			'opacity' : 1
		};

	this.current = 1;

	this.count = 0;
	this.timer = 0;
	
	this.tick = function() {
		var next = this.current + 1;
		if (next > this.count)
			next = 1;
		
		var current_quote = jQuery(this.child_prefix + this.current);
		var next_quote = jQuery(this.child_prefix + next);		
		
		current_quote.css(this.child_style).css(this.child_current_style);
		next_quote.css(this.child_style).css(this.child_next_style);

		var height = next_quote.height();
		jQuery(this.container).animate({'height':height}, this.animate_delay);
		
		current_quote.fadeOut(this.animate_delay);
		
		this.current = next;
	};
	
	this.setup = function() {
		this.count = jQuery(this.container).children().length;
		
		this.timer = setInterval("quotes.tick()",this.change_delay);
		
		var height = jQuery(this.child_prefix + this.current).height();
		jQuery(this.container).css(this.container_style).animate({'height':height}, this.animate_delay);
	};
};

jQuery(document).ready(function(){
	quotes.setup();
});
