/*
 Tooltip script 
 powered by jQuery (http://www.jquery.com)
 written by Alen Grakalic (http://cssglobe.com)
 for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 */

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = -15;
		yOffset = 12;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<div id='tooltip'><p id='tooltipX'>"+ this.t +"</p></div>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
	
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? this.t : "";
		$("body").append("<div id='screenshot'><p id='screenshotX'><span>"+ c +"</span><img src='"+ this.rel +"' alt='url preview' /></p></div>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			

};

	
$(document).ready(function(){

	tooltip();

	$(".tabdiv").hide();

	$(".tabdiv:first").show();

	$("#work").height($("#work").height()-20);
	$("#social").height($("#social").height()-10);
	$("#networks li a").hover(
		function () {
			$(this).animate({ backgroundColor: '#1E1F20' },{queue:false}, "normal" );
		}, 
		function () {
			$(this).animate({ backgroundColor: '#131415' },{queue:false}, "normal" );
		}
    );



	$("#navigation li a").click(function(){
	    $("#navigation li a").removeClass("selected");
		$("#navigation li a span").removeClass("selected2");

		$(this).addClass("selected");
		$(this).children().addClass("selected2");

		var current = $(this).attr("href");

		$(".tabdiv:visible").hide();

		$(current).fadeIn("slow");

		$("#content").animate({"height":$(current).height()});

		return false;

		//$("#footer p").text("Current: " + $(current).height() + " Content:" + $("#content").height()); 

	});

});