jQuery().ready(function()
{
	if($('.thumbs').length > 0)
	{
		var left = 0;
		var top = 0;
		var width = $('.thumbs').width();
		var height = $('.thumbs').height();
		var mouseOver = false;
		changeHover = function()
		{
			$('.lastHover').children('.overlay').stop().animate({ opacity: 1 }, 500, function()
			{
				$(this).parent().removeClass('lastHover');
			});
		}
		$('.thumbs .thumb').each(function()
		{
			$(this).append('<div class="overlay"></div>');
		});
		$('.thumbs .thumb').mouseover(function()
		{
			mouseOver = true;
			activeProject = this;
			left = $(this).position().left + 119;
			top = $(this).position().top;
			if(left >= width - 119)
			{
				left = (left - 357);
			}
			if(top >= height - 119)
			{
				top = (top - 119);
			}
			$('.thumbs .project_tekst').attr('href', $(this).attr('href')).stop().html($(this).html()).show().animate({ opacity: 1, left: left, top: top }, 500).children('img').remove();
			$(this).children('.overlay').stop().animate({ opacity: 0 }, 500);
			$(this).removeClass('lastHover');
			changeHover();
			$(this).addClass('lastHover');
		});
		$('.thumbs .project_tekst').mouseover(function()
		{
			mouseOver = true;
		});
		$('.thumbs').mouseout(function()
		{
			mouseOver = false;
			setTimeout(function()
			{
				if(!mouseOver)
				{
					changeHover();
					$('.thumbs .project_tekst').stop();
					$('.thumbs .project_tekst').animate({ opacity: 0 }, 500, function()
					{
						$('.thumbs .project_tekst').hide();
					});
				}
			}, 100);
		});
	}
});
