function beginDrag() {
  if (event.button == 1) {
    if (!event.srcElement) return;
    dragThis = event.srcElement;
    while (dragThis.id.indexOf('Drag') == -1) {
      dragThis = dragThis.parentElement;
      if (dragThis == null) { return }
    }
    oldX = (event.clientX + document.body.scrollLeft);
    oldY = (event.clientY + document.body.scrollTop);
  }
}
function dragIt() {
  if (dragThis == null) return;
  newX = (event.clientX + document.body.scrollLeft);
  newY = (event.clientY + document.body.scrollTop);
  var distanceX = (newX - oldX);
  var distanceY = (newY - oldY);
  oldX = newX;
  oldY = newY;
  dragThis.style.pixelLeft += distanceX;
  dragThis.style.pixelTop += distanceY;
  event.returnValue = false;
}
function setDrag(ix, iy) {
  Drag.style.posLeft = ix;
  Drag.style.posTop = iy;
  document.onmousemove = dragIt;
  document.onmouseup   = endDrag;
  oldX = oldY = newX = newY = 0, dragThis = null;
}

function HL_Fix () {
  document.location = 'list.php?history_layer_show=1&hlpx='
     + Drag.style.posLeft + '&hlpy=' + Drag.style.posTop;
}
function HL_Float() {
  document.location = 'list.php?history_layer_show=0';
}

var history_layer_on = 0;
function ShowHistoryLayer(focus, fading) {
  if (history_layer_on) { HideHistoryLayer(fading); return; }
  if (fading) Drag.filters.blendTrans.apply();
  if (document.layers) document.layers.Drag.visibility = 'show';
  else document.getElementById('Drag').style.visibility = 'visible';
  if (fading) Drag.filters.blendTrans.play();
  history_layer_on = 1;
  if (focus) { document.searchform3.k.focus(); }
}
function HideHistoryLayer(fading) {
  if (fading) Drag.filters.blendTrans.apply();
  if (document.layers) document.layers.Drag.visibility = 'hide';
  else document.getElementById('Drag').style.visibility = 'hidden';
  history_layer_on = 0;
  if (fading) Drag.filters.blendTrans.play();
}
function SelectHistory(form) {
  ndx = form.history.selectedIndex;
  v = new String(form.history.options[ndx].value);
  tag = v.substring(0, 2);
  value = v.substring(2, v.length);
  if (tag == 's:') {
    url = 'search.php?k=' + value;
    document.location = url;
  } else if (tag == 'f:') {
    url = 'list.php?root=' + value;
    document.location = url;
  }
}
function ResizeWindow(wx, wy) {
  if (window.top.resizeTo) {
    window.top.resizeTo(wx, wy);
  }
}
