var hovered= false;
var currentHover= 0;

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   	return this.animate({opacity: 'toggle'}, speed, easing, callback);
}; 

jQuery(document).ready(function($)
{
	if ( $("body").hasClass("projects") )
	{
		$("#content").gridLayout('.block', {col_width: 184, min_cols: 2}); 
				
		var total= $(".block").size();
		var rows= total / 5;
				
		if (rows * 5 != total)
			rows++;
				
		$("#content").height($(".block").height() * rows);
	}
				
				$(".download .img").hover(
					function()
					{
						$(this).parent().removeClass("small").addClass("big");
						$(this).children(".info").show();
					},
					function()
					{
						$(".info").hide();
						$(".download").removeClass("big").addClass("small");
					}
				);

				$(".block").mousemove(
							function(e)
							{
								var posX = e.pageX - $(this).offset().left;
    							var posY = e.pageY - $(this).offset().top;
    							
    							$(this).children(".info").css({ "top": posY - 30 + "px", "left": posX + 20 + "px" });
							}
				);
				
				$(".download").mousemove(
							function(e)
							{
								var posX = e.pageX - $(this).offset().left;
    							var posY = e.pageY - $(this).offset().top;
    							
    							$(this).children().children(".info").css({ "top": posY - 30 + "px", "left": posX + 20 + "px" });
							}
				);
				
				$(".block").hover(
					function(e)
					{
						hovered= true;
						var thisIndex= $(".block").index(this);
						
						$(this).addClass("block-hover");
						
						$(this).children(".hover").hide();
						$(this).children(".info").show();
						
						currentHover= thisIndex;
						
						if ( $(this).hasClass("last") )
						{
							$(this).addClass("active-last");
							$(this).css("left", "644px");
						}
						
						var posX = e.pageX - $(this).offset().left;
    					var posY = e.pageY - $(this).offset().top;
    					$(this).children(".info").css({ "top": posY - 30 + "px", "left": posX + 20 + "px" });
						
						$(this).width(276).height(210);
					},
					function()
					{
						$(this).removeClass("active-last");
						$(this).removeClass("block-hover");
						$(this).children(".info").hide();
						
						if ( $(this).hasClass("last") )
						{
							$(this).css("left", "736px");
						}
						
						$(this).width(184).height(140);
					}
				);
			});