/*
 * JavaScript for Pngised v2
 * 
 * Copyright (c) 2009 Federico Pizzutto
 * Dual licensed under the MIT and GPL licenses.
 *
 * Date: 2009-03-01
 * 
 */


$(document).ready(function(){
	/* Portfolio functions */
	//$(".home .project a:first-child").not("h3 a").click(function(){return false;})
	//$(".project").hide();
	$(".project a:first-child img").hide();
	//$("ul.pagination").hide();
		
	// prevent bubbling
	$(".project a:first-child").bind("mouseenter",function(e){
			$(".project a span").show();
			// adding color variation
			$(this).siblings("h3").children().addClass("hover");
			//animate mouseover event
			$(this).children("img").animate({
			      top: "200px", opacity: 1
			    }, { duration: 500, queue: true });
		}).bind("mouseleave", function(e){
			// remove color variation
			$(this).siblings("h3").children().removeClass("hover");
			$(this).children("img").animate({
			      top: "0", opacity: 1
			    }, { duration: 500, queue: false });
	});
	
	// scroll to top
	$('a.top').click(function(){ $('html, body').animate({scrollTop:0}, 'slow'); return false;});
	
	// pagination
	$('li.disabled a').click(function(){return false;});
	
	var test = $("body#contact").length;
	if (test) {	$("#contactForm").validate(); };
	
});
// $(window).load(function() {
// 	$(".project a:first-child img").each(function(){
// 		$(this).fadeIn("slow");
// 	});
// });


$(function(){	
	// Grabs all the IMG and hides them,
	// then assigns the jQuery object with all the IMGs to the $projects variable
	// setting the i variable to 0
	var $projects = $(".project a:first-child img").hide() , i = 0;
	
	// define an anonymous function calling it immediately
	(function(){
		// Each time the anonymous function is called, it selects a single IMG from the jQuery object using $projects[i++].
		// That also increments the i variable so that it will get the next IMG the next time it's called.
		if (i < $projects.length) {
			$($projects[i++]).fadeIn(500,arguments.callee);
		}
		// arguments.callee is a reference to the current anonymous function that we are in.
		// So when the fadein is done it will call the same function, which will select the next IMG in $projects.
		// So it's kind of like a recursive call
	})();
});