$(document).ready(function(){
	
	$('.showcase-image').pngFix();
	$('.showcase-content').pngFix();
	
	var length = $('#featured .showcase').length;
	var currentshowcase = 1;
	var timer = null;
	
	var displayShowcase = function(num) {
		if (currentshowcase != num) {
			$(".showcase").css("z-index",13);
			$("#showcase-"+currentshowcase).css("z-index",14);
			$("#showcase-"+num).css("top","416px");
			$("#showcase-content-"+num).css("top","416px");
			$("#showcase-image-"+num).css("top","416px");
			$("#showcase-"+num).css("z-index",15);
			$("#showcase-"+num).animate( { top: '0px' }, 500 );
			$("#showcase-content-"+num)
				.animate({opacity:1.0}, 300).animate( { top: '0px' }, 500 );
			$("#showcase-image-"+num)
				.animate({opacity:1.0}, 500).animate( { top: '0px' }, 700, undefined, function() {
					currentshowcase = num;
					if (timer != null) clearTimeout(timer);
					timer = setTimeout(nextFeaturedProject, 5000);
				});
		}
	}
	
	var nextFeaturedProject = function () {
		displayShowcase((currentshowcase == length) ? 1 : currentshowcase + 1);
	}
	
	timer = setTimeout(nextFeaturedProject, 5000);
	
	$('.feature-markers').each(function() {
		$(this).find('a').each(function(idx) {
			$(this).bind('click', function() {
				displayShowcase(idx + 1);
				return false;
			});
		});
	});
});

