var $j = jQuery.noConflict();

$j(function(){

	//Opacity References
	$j("#references a").hover(
		function(){
			$j(this).stop().animate({opacity:"0.7"},200);
		},
		function(){
			$j(this).stop().animate({opacity:"1"},100);
		}
	);
	
	//Opacity Contact
	$j("#contact a").hover(
		function(){
			$j(this).stop().animate({opacity:"0.7"},200);
		},
		function(){
			$j(this).stop().animate({opacity:"1"},100);
		}
	);
	
	//Opacity Menu
	$j("#menu a").hover(
		function(){
			$j(this).stop().animate({opacity:"0"},200);
		},
		function(){
			$j(this).stop().animate({opacity:"1"},100);
		}
	);
	
	
	//Menu ScrollTo
	$j("#menu a").each(function(){
		$j(this).click(function(e){
			e.preventDefault();
			thisSrc = $j(this).attr("href");
			scrollTo = $j(thisSrc).position();
			scrollTo2 = scrollTo.top;
			
			if(thisSrc == "#references"){
				$j("html, body").animate({scrollTop: 400});
			} else {
				$j("html, body").animate({scrollTop: scrollTo2});
			}
		});
	});
	
	//Tooltips
	
	$j("#references ul a, #contact ul a").each(function(){
		$j(this).hover(
			function(){
				thisContent = $j(this).attr("title");
				thisPosition = $j(this).position();
				thisTop = thisPosition.top -50;
				thisWidth = $j(this).width();
				thisLeft = thisPosition.left -20;
			
				$j("body").append("<div class='tooltip'><p>"+thisContent+"</p><div class='arrow'></div></div>");
				tooltipWidth = $j(".tooltip").width();
			
				thisLeft2 = (thisWidth - tooltipWidth)/2;
				thisLeft3 = thisLeft + thisLeft2;
			
				$j(".tooltip").css({top:thisTop+"px", left:thisLeft3+"px"}).animate({opacity:0.7});
			},
			function(){
				$j(".tooltip").remove();
			}
		);
	});

	
	
});
