var currentImage = 0;

function animateQuote(){
	$("html").css({
		overflow: 'hidden'
	});
	$(".animate").css({
		right: '-1300px',
		display: 'block'
	}).animate({
		right: '8px'
	}, 1000, "swing", function(){
		$("html").css({
			overflow: 'auto'
		})
	});
}

function animateSplash(){
	$("#overlay").animate({
		opacity: '0'
	}, 2000, function(){
		$("#overlay").remove();
	})
}

function cycleImage(){
	(currentImage >= $(".image").length - 1) ? currentImage = 0 : currentImage++;
	$(".image").each(function(){
		if ($(this).get(0) == $(".image").get(currentImage)) {
			$(this).css({
				display: 'block'
			}).animate({
				opacity: 1
			}, 2000)
		}
		else {
			$(this).animate({
				opacity: 0
			}, 2000)
		}
	})
}

$(document).ready(function(){
	if ($(".animate").length == 0) {
		$(".bottomquote").css({
			display: 'block'
		})
	}
	if ($(".image").length > 1) {
		$(".image:not(:first)").css({display: 'none'})
	}
})

$(window).load(function(){

	if ($("#overlay").length > 0) {
		window.setTimeout("animateSplash()", 4000)
		$("#overlay").click(function(){
			animateSplash();
		})
	}
	
	if ($(".animate").length > 0) {
		animateQuote();
	}
	
	if ($(".image").length > 1) {
		window.setInterval("cycleImage()", 4000);
	}
	
})

