// JavaScript Document
$(document).ready(function(){
	//Function that displays/hides the bubbles when hovering over the links
	$("a[rel^='bubble']").hover(
		function(){
			//Function that displays bubble
			$('.hover_bubbles').hide();
			var bubble_id = '#' + $(this).attr("rel");
			var xpos = $(this).offset().left;
			var ypos = $(this).offset().top;
			var b_width = $(bubble_id).width();
			
			$(bubble_id).css({
							"position":"absolute",
							"top": ypos + 25,
							"left": xpos - 10
							});
			
			/*EG: For top link */
			$('.hover_bubbles:first').css({
									"left": xpos - b_width + 100
									});
			$('.hover_bubbles:first').find('.topr').css({
									"background-image": "url(../img/bubble_top_bot.png)",
									"height":"25px",
									"background-position": "left -25px"
									});
			$('.hover_bubbles:first').find('.bottom').css({
									"background-image": "url(../img/bubble_top_bot.png)",
									"height":"25px",
									"background-position": "left -50px"
									});
			
			
			/* EG: For bottom link */
			$('.hover_bubbles:last').find('.topr').css({
									"background-image": "url(../img/bubble_top_bot.png)",
									"height":"25px",
									"background-position": "left -100px"
									});
			$('.hover_bubbles:last').find('.bottom').css({
									"background-image": "url(../img/bubble_top_bot.png)",
									"height":"25px",
									"background-position": "left -75px"
									});
			$('.hover_bubbles:last').find('.txt').css({
									"padding": "0px 15px 25px 15px"
									});
			$('.hover_bubbles:last').css({
									"left": xpos - b_width + 100,
									"top": ypos - $('.hover_bubbles').eq(3).height() - 5
									});
			/* EG: End customised code */
			
			$(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");
					
				}
			});
		}
	);
});

