var rx,ry;
var IE = document.all?true:false
function getMouseXY(e) {
  if(!e) e=event;
  rx = Event.pointerX(e);
  ry = Event.pointerY(e);
  recalc();
  return true
}
function recalc() {
  var w = jQuery(window).width();
  var h = jQuery(window).height();
  var x = rx + 10;
  var y = ry + 10;
  var top = jQuery(document).scrollTop();
  var boxh = jQuery("#ajaxbox").innerHeight();
  var oy = y;
  if(x>w/2) x -= 400 + 50;
  if(y+boxh>h+top) y -= boxh + 20;
  if(isNaN(x) || isNaN(y)) return;
  jQuery("#ajaxbox").css("left", x).css("top", y);
}

var lajax;

jQuery(function(){
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = getMouseXY;
	window.setInterval(function() {recalc();}, 333);
	jQuery("#ajaxbox").hide();
	jQuery("*[termajax]").each(function(k,t) {
		var id = jQuery(t).attr("termajax");
		jQuery(t).hover(function(){
			jQuery.ajax({
				url: "termekrepr.php",
				data: {"id": id},
				beforeSend: function(x) {
					lajax = x;
				},
				success: function(data) {
					jQuery("#ajaxbox").html(data).show();
					recalc();
				}
			});
		},function(){
			lajax.abort();
			jQuery("#ajaxbox").hide();
		});
	});
});
