// Copyright © 2009 Gabriel Somoza, Aycron - IT Solutions
// gabriel.somoza@aycron.com / somoza_gabriel@hotmail.com
var initialTop = -210; // if you want to change this, change it also in the popup css.

hideParams = {
	opacity: "hide",
	top: initialTop
}

showParams = {
	opacity: "show",
	top: initialTop + 10
}

clickX = 0;
clickY = 0;

$(document).ready(function() {
    $(".popup a").each(function() {
		$(this).click(function(e) {
			if ($.browser.msie){
				$(this).next("div").stop(true, true).show();
			}else{
				$(this).next("div").stop(true, true).animate(showParams, "slow");
			}
			clickX = e.pageX;
			clickY = e.pageY;
		});
	});
	$(".bubble").each(function(){		
		$(this).parent().mousemove(function(e){
			fadeOut = false;
			//If mouse moved more than 20px sideways
			if(Math.abs(e.pageX - clickX) > 20)
				fadeOut = true;
			if(Math.abs(e.pageY - clickY) > 20)
				fadeOut = true;
			if(fadeOut){
				 if ($.browser.msie)
				 	$(this).hide();
				 else
					$(this).animate(hideParams, "normal");
			}
		});
		$(this).parent().mouseout(function(){
		    if ($.browser.msie)
				$(this).hide()
			else
				$(this).animate(hideParams, "normal");
		});
	});
});
