$(document).ready(function() {
	menuAnimation();
	blockShadow();
	imageHover();
	tooltip();
});


function menuAnimation() {
	
	$("#menu ul li").each(function() {
		
		$linkText = $(this).html();
		$linkTextClass = $($linkText).addClass("white");
		
		$(this).append($linkTextClass);
		
		$(this).append("<span></span>");
		
		$('.white').css({ opacity: 0 });
		
	});
	
	$("#menu ul li a, #menu ul li span, #menu ul li .white").hover(function() {
		
		$(this).parents("li").children("span").stop().animate({ left: 0 }, 200);
		$(this).parents("li").children("a.white").stop().animate({ opacity: 1 }, 100);
		
	}, function() {
		
		$(this).parents("li").children("span").stop().animate({ left: "180px" }, 200);
		$(this).parents("li").children("a.white").stop().animate({ opacity: 0 }, 100);
		
	});
	
}

function blockShadow() {
	
	$(".block:not(.top)").each(function() {
		
		$(this).append('<div class="shadow"></div>');
		
	});
	
	$(".top").each(function() {
		
		$(this).append('<div class="shadow-inverse"></div>');
		
	});
	
}

function imageHover() {
	
	$(".img-preview").hover(function() {
		
		$(this).children("a:not(.title)").prepend('<div class="pink_hover"></div>');
		$(this).children("a:not(.title)").children(".pink_hover").css({ display: "block", opacity: 0 }).stop().animate({ opacity: "0.5" }, 300);
		
	}, function() {
		
		$(this).children("a:not(.title)").children(".pink_hover").stop().animate({ opacity: 0 }, 150, function() {
														     
			$(this).remove();
														     
		});
		
	});
	
}

function tooltip() {	
	/* CONFIG */
		
		xOffset = 3;
		yOffset = 150;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$(".tooltip_c").hover(function(e){
		$("body").append("<p id='screenshot' class='tooltip'>"+ this.rel +"</p>");								 
		$(".tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$(".tooltip").remove();
    });	
	$(".tooltip_c").mousemove(function(e){
		$(".tooltip")
			.css("top",(e.pageY - 8) + "px")
			.css("left",(e.pageX + 20) + "px");
	});			
};