$(document).ready(function(){
 
 	// Create the definition div if it doesn't exis
	
	// Setup the hovering action for each definition term
	$(".google-search").hover(
		function() {
		 
		 	// Populate the results
		 	var urlsafe = $(this).text().replace(/ /g, "+");
		 	
		 	// Our AJAX Request to get the definition
		 	$.ajax({
				type:"POST",
				url:"google-getter.php",
				data:"string="+urlsafe,
				success:function(html){
				 
				 	// Get the contents of the first List Item within the Unordered List having a classname of "std"
					var resultList = $(html).find("ul.std li:first").text();
					$("div.results-content").html("<p>" + resultList + "</p>");
					
				}
			});
		 
		 	// Show our definition
			$("div.results").fadeIn();
			
		}, 
		function() {
		 	
		 	// Fade out our definition box
			$("div.results").fadeOut("normal", function(){
			 
			 	// Replace the definition with our loading animation
				$("div.results-content").html("<img src='loading.gif' />");
				
			});
		}
	);
	
	// Code to position our results box
	$(".google-search").mousemove(function(e){
	 
	 	// Position our definition box to just beneath our mouse
		$("div.results").css("top", (e.pageY + 25));
		$("div.results").css("left", (e.pageX ));
//		$("div.results").css("left", (e.pageX - ( $("div.results").width()/2 )));
		
	});
	
});