
$(document).ready( function() {

	// options
	var distance = 10;
	var time = 250;
	var hideDelay = 50;
	
	var hideDelayTimer = null;
	
	// tracker
	var beingShown = false;
	var shown = false;
	
	var trigger = $('.trigger', this);
	var popup = $('.popup', this).css('opacity', 0);
	
	$('.popupinfo').livequery( function() {

		$(this).hover(
		    function () {
		    
			    if (hideDelayTimer) clearTimeout(hideDelayTimer);
		
			    // don't trigger the animation again if we're being shown, or already visible
			    if (beingShown || shown) {
					return;
				} else {
					beingShown = true;
					$(this).children().next().next().show();
				}
				
		    },
		    function () {
		    
				// reset the timer if we get fired again - avoids double animations
				if (hideDelayTimer) clearTimeout(hideDelayTimer);

					hideDelayTimer = null;
					beingShown = false;
					shown = false;
					$(this).children().next().next().hide();

				
		    }
		);

	});
	
});
