// JavaScript Document
var quoteIndex = 0;
function quoteSwitch()	{
	jQuery('blockquote p.last-active').removeClass('last-active');
	jQuery('blockquote p.active').addClass('last-active');
	jQuery('blockquote p.active').next().addClass('next-active');

	jQuery('blockquote p.active').fadeOut('slow', function(){
		if(quoteIndex > (jQuery('blockquote p').length -1)){
			quoteIndex = 0;
			jQuery('blockquote p:first-child').addClass('next-active');

			jQuery('blockquote p.next-active').fadeIn('slow', function(){
				jQuery('blockquote p.active').removeClass('active');
				jQuery(this).addClass('active');
				jQuery(this).removeClass('next-active');
			});
		}else{
			jQuery('blockquote p.next-active').fadeIn('slow', function(){
				jQuery('blockquote p.active').removeClass('active');
				jQuery(this).addClass('active');
				jQuery(this).removeClass('next-active');
			});
		}
	});
	quoteIndex = quoteIndex + 1;
	fixHeight();
}

function fixHeight(){
	var pageHeight = $('#wrap').height();
	var footerAlign = 10;
	var pageItems = $('#header').outerHeight(true) + $('#menu').outerHeight(true) + mainHeight + $('#footer').outerHeight(true) + $('#page').outerHeight(true);
	var footStretch = $(window).height() - (pageItems + footerAlign);

	if ($(window).height() >= pageItems){
		$('#footer').css({top: footStretch});
	}
	if ( $(window).height() >= pageHeight ){
		$('#wrap').css({height: $(window).height()});
	}
}

jQuery(document).ready(function($) {
	$('blockquote p:first-child').addClass('active home');
	$('blockquote p:not(p.active)').hide();
	// Add Block-quotes
	$('blockquote p').prepend('&#8220;');
	$('blockquote p').append('&#8221;');
	
	setInterval( "quoteSwitch()", 5000 );
});
