//
// (c) 2004 Stefan Ruettinger
// http://www.homepage-erfolg.de/
//
var agt      = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla') != -1) &&
               (agt.indexOf('spoofer') == -1) &&
               (agt.indexOf('compatible') == -1) &&
               (agt.indexOf('opera') == -1) &&
               (agt.indexOf('webtv') == -1) &&
               (agt.indexOf('hotjava') == -1));
var is_nav4 = (is_nav && (is_major <= 4));

var is_ie   = ((agt.indexOf("msie") != -1) &&
               (agt.indexOf("opera") == -1));
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) &&
              (agt.indexOf("msie 4")!=-1));
var is_ie5  = (is_ie && (is_major == 4) &&
              (agt.indexOf("msie 5")!=-1));

var box, inhalt;
var deltaX, deltaY;


function init( verzoegerung) {
  if (is_ie5) { box    = document.all.popup;
                inhalt = document.all.popup_inhalt; }
  else        { box    = document.getElementById('popup');
                inhalt = document.getElementById('popup_inhalt'); }

  setTimeout( "zeige_box()", verzoegerung);
}

function hole_left( div) {
  var x;

  if (is_ie5) { x = div.style.pixelLeft; }
  else        { x = parseInt( div.style.left); }

  return x;
}

function hole_top( div) {
  var y;

  if (is_ie5) { y = div.style.pixelTop; }
  else        { y = parseInt( div.style.top); }

  return y;
}

function hole_visibility( div) {
  return div.style.visibility;
}

function setze_visibility( div, v) {
  div.style.visibility = v;
}

function zeige_box() {
  if ((!is_nav4) && (!is_ie3) && (!is_ie4)) {
    setze_visibility( box, "visible");
    setze_visibility( inhalt, "visible");
  }
}

function schliesse_box() {
  setze_visibility( box, "hidden");
  setze_visibility( inhalt, "hidden");
}

function klappe_inhalt() {
  if (hole_visibility( inhalt) == "visible")
    setze_visibility( inhalt, "hidden");
  else
    setze_visibility( inhalt, "visible");
}

function setze_position( div, x, y) {
  if (is_ie5) { div.style.pixelLeft = x;
                div.style.pixelTop  = y; }
  else        { div.style.left = x + "px";
                div.style.top  = y + "px"; }
}

function position( e) {
  if (is_ie) { deltaX = event.clientX - hole_left( box);
               deltaY = event.clientY - hole_top( box); }
  else       { document.captureEvents( Event.MOUSEMOVE | Event.MOUSEUP); 
               deltaX = e.clientX - hole_left( box);
               deltaY = e.clientY - hole_top( box); }

 document.onmousemove = drag;
 document.onmouseup   = drop;

 return false;
}

function drag( e) {
  if (is_ie) {
    setze_position( box, event.clientX - deltaX,
                         event.clientY - deltaY);
  }
  else {
    setze_position( box, e.clientX - deltaX,
                         e.clientY - deltaY);
  }

  return false;
}

function drop() {
  if (!is_ie) {
    document.releaseEvents( Event.MOUSEMOVE | Event.MOUSEUP);
  }

  document.onmousemove = null;
  document.onmouseup   = null;
  box.onmousedown = null;
}

function schiebe_box() {
  box.onmousedown = position;
}

