$(document).ready(function(){
	//Ensure that the newsticker items and bubbles are not displayed
	$('.newsHeadline').hide();
	$('.newsHeadline').eq(0).show();
	$('.bubbles').hide();
	
	//Function that displays/hides the bubbles when hovering over the links
	$("a[rel^='bubble']").hover(
		function(){
			//Function that displays bubble
			$('.bubbles').hide();
			var bubble_id = '#' + $(this).attr("rel");
			var xpos = $(this).offset().left;
			var ypos = $(this).offset().top;
			
			$(bubble_id).css({
							"position":"absolute",
							"top": ypos + 19,
							"left": xpos -206
							});
			
			$(bubble_id).show();
		},
		function(){
			//Function that hides bubble
			var bubble_id = '#' + $(this).attr("rel");
			var b_height = $(bubble_id).height();
			var b_width = $(bubble_id).width();
			var b_startx = $(bubble_id).offset().left;
			var b_starty = $(bubble_id).offset().top;
			
			$(document).bind("mousemove", function(e) {
				if (!(((e.pageX >= b_startx) && (e.pageX <= (b_startx + b_width))) &&
					((e.pageY >= b_starty) && (e.pageY <= (b_starty + b_height))))) {
					$(bubble_id).hide();
					$(document).unbind("mousemove");
					
				}
			});
		}
	);
	
 });
