function show_popup(auction_id, event) {
   if (!event) {
     var event = window.event;
   }
   ajaxoryg('/ppup.php?aid='+auction_id, prepare_popup, true);
   move_popup(event);
}

var _popupX = 400;
var _popupY = 400;
function create_popup() {
   var el = document.getElementById('popup');
   if (el) return el;
   
   var bdy = document.body;//getElementById('body');
   el = document.createElement('div');
   el.id            = 'popup';
   el.style.left    = '361px';
   el.style.top     = '550px';
   el.style.display = 'none';
   
   bdy.appendChild(el);
   return document.getElementById('popup');
}

function prepare_popup(resp) {
	var elem = document.getElementById('popup');
	elem.style.display = 'block';
	elem.innerHTML = resp;
}

function getWidth() {
return ( typeof( window.innerWidth ) == 'number' ) ? window.innerWidth : document.documentElement.clientWidth;
}

function getHeight() {
return ( typeof( window.innerHeight ) == 'number' ) ? window.innerHeight : document.documentElement.clientHeight;
}

function move_popup(event) {
   if (!event) { var event = window.event; }
   
   var scrollTop = document.documentElement.scrollTop;
   var innerH     = window.innerHeight;
   var outerH     = getHeight();
   var windowH    = 400; //wysokosc okienka
   
   var el = create_popup();
   var XX = event.clientX + document.documentElement.scrollLeft + 10 ;
   var YY = event.clientY + document.documentElement.scrollTop  + 10 ;
   
   //zachowanie minimalnej odleglosci od dolnej krawedzi
   var minBottom = scrollTop + innerH;
   //zachowanie minimalnej odleglosci od gornej krawedzi
   var maxTop    = scrollTop;

   //sprawdzenie warunkow granicznych
   if (YY < maxTop) YY = scrollTop;
   if (YY > minBottom - windowH) YY = minBottom - windowH;
   
   //if (_XX > 0) XX -= _XX;
   //if (_YY > 0) YY -= _YY;
   el.style.left = XX + 'px';
   el.style.top  = YY + 'px';
}

function hide_popup() {
   var x = Math.random();
   var e = document.getElementById('popup');
   if (e) e.style.display = 'none';
}

//uwzglednienie mychy
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = setMouseXY;

// Temporary variables to hold mouse x-y pos.s
var mouseX = 0
var mouseY = 0

// Main function to retrieve mouse x-y pos.s
function setMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
      mouseX = event.clientX + document.body.scrollLeft
      mouseY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
      mouseX = e.pageX
      mouseY = e.pageY
  }  
    // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}  
  
  return true
}
                              

