var Quotes = {
	
	objQuoteDisplayedIndex : null,
	objRotationId : null,
	intFadeLength : 800, /* milliseconds */
	intRotationLength : 4000, /* milliseconds */
	intNumQuotes : null,
	
	init : function () {
		Quotes.objQuoteDisplayedIndex = 0;
		Quotes.intNumQuotes = jQuery('#quotes p').size(0);
		Quotes.startRotation();
	},
	
	displayQuote : function ( objQuoteIndex, intFadeLength) {
		var intFadeLength = typeof(intFadeLength) != 'undefined' ? intFadeLength : Quotes.intFadeLength;
		jQuery('#quotes p').fadeOut(intFadeLength);
		jQuery('#quotes p').eq(objQuoteIndex).fadeIn(intFadeLength);
	},
	
	displayNextQuote : function () {
		if (Quotes.objQuoteDisplayedIndex == Quotes.intNumQuotes-1) {
			Quotes.objQuoteDisplayedIndex = 0;
		} else {
			Quotes.objQuoteDisplayedIndex += 1;
		}
		
		Quotes.displayQuote(Quotes.objQuoteDisplayedIndex);
	},
	
	startRotation : function () {
		Quotes.objRotationId = setInterval (Quotes.displayNextQuote, Quotes.intRotationLength);
	}
}

if (jQuery && document.getElementById) {
	jQuery(document).ready( function() {
		Quotes.init();
	});
}