heroCycle = function() {

	// Hidden slide into left view
	$("div#slide-4").show().animate({ left: '-20px', top: '42px', opacity: '1' }, 200, function() {
	    $(this).animate({ left: '20px'}, 200, function() {$(this).attr("id","slide-2");});
	});

	// Left slide to the center
	$("div#slide-2").animate({ left: '221px', top: '0px', width: '546px', height: '340px' }, 400);
	$("div#slide-2 img").animate({ width: '546px', height: '340px' }, 400, function() {$(this).parent().attr("id","slide-1");});

	// Main slide to the right
	$("div#slide-1 img").animate({ width: '411px', height: '256px' }, 400);		
	$("div#slide-1").animate({ left: '760px', top: '42px', width: '411px', height: '256px' }, 400, function() {
		$(this).attr("id","slide-3").animate({ left: '560px'}, 200);
	});
	 
	// Right slide out of view
	$("div#slide-3").animate({ left: '660px', top: '42px', opacity: '0' }, 500, function() {
		// Move second hidden slide up in order
		$("div#slide-5").attr("id","slide-4").css({"left" : "20px","top" : "42px"});
		$(this).attr("id","slide-5").css({"left" : "20px","top" : "42px"});
		
		// Push slide nav
		next = parseInt($("ul.slide-nav a.current").attr("id").substring(6,7)) + 1;
		if(next == 6) { next = 1};
		next = $("ul.slide-nav a#slide-" + next + "-nav");
		$("ul.slide-nav a").removeClass("current");
		$(next).addClass("current");
	});
	
};


$(document).ready(function() {

	// Initiate hidden slides
	$("div#slide-4, div#slide-5").animate({ opacity: '0' }, 0, function() {$(this).show();});
	
	// Start slide
	function startInterval() {
		heroInterval = setInterval("heroCycle()",4000);		
	};
	startInterval();
	
	// Pause button
	$("a.pause-btn").click(function() {
		if($(this).html() == "Pause") {
			clearInterval(heroInterval);
			$(this).html("Play");		
		} else {
			startInterval();
			$(this).html("Pause");
		}
	});
	
    $("#resume-form").validate();
 });
