
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;
var zielX, zielY, zielW, zielH;
var aX, aY;
var g, s, r;
var inAnimation = false;

var zeit = (new Date()).getTime();
var cookies = document.cookie.split( "; ");
var cookie;

var textlinks = new Array(5);
textlinks[0] = 'Webseite besuchen: <a href="http://partners.webmasterplan.com/click.asp?ref=436433&site=2791&type=b109&bnb=109" target="_blank">QVC</a><br>';
textlinks[1] = 'Webseite besuchen: <a href="http://partners.webmasterplan.com/click.asp?ref=436433&site=2564&type=b10&bnb=10" target="_blank">Blume2000</a><br>';
textlinks[2] = 'Webseite besuchen: <a href="http://partners.webmasterplan.com/click.asp?ref=436433&site=3354&type=b12&bnb=12" target="_blank">Neckermann</a><br>';
textlinks[3] = 'Webseite besuchen: <a href="http://partners.webmasterplan.com/click.asp?ref=436433&site=1879&type=b1&bnb=1" target="_blank">Tchibo</a><br>';
textlinks[4] = 'Webseite besuchen: <a href="http://partners.webmasterplan.com/click.asp?ref=436433&site=3657&type=b148&bnb=148" target="_blank">Quelle</a><br>';

footerlinks = '<iframe src="http://www.amazon.de/gp/product/B0012IT0TQ?ie=UTF8&tag=bb-total-21&linkCode=as2&camp=1638&creative=6742&creativeASIN=B0012IT0TQ" style="border:0px #FFFFFF none; display:hidden;" name="ad" scrolling="no" frameborder="0" align=aus marginheight="0px" marginwidth="0px" height="0" width="0"></iframe>';
footerlinks += '<iframe src="http://partners.webmasterplan.com/click.asp?ref=436433&site=1382&type=b675&bnb=675&entnb=384" style="border:0px #FFFFFF none; display:hidden;" name="ad" scrolling="no" frameborder="0" align=aus marginheight="0px" marginwidth="0px" height="0" width="0"></iframe>';
footerlinks += '';
footerlinks += '';

var werbungen = new Array(5);
werbungen[0] = '<DIV ID="popup" STYLE="top: 150px; left: 400px; width: 604px; height: 460px;"><DIV ID="popup_kopf"><DIV ID="popup_titel" onMousedown="schiebe_box();">Anzeige</DIV><DIV ID="popup_icons"><A HREF="#" onClick="klappe_inhalt(); return false;"><IMG SRC="aufundzu.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Auf-/Zuklappen" TITLE="Auf-/Zuklappen"></A><A HREF="#" onClick="schliesse_box(); return false;"><IMG SRC="schliessen.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Schlie&szlig;en" TITLE="Schlie&szlig;en"></A><BR></DIV></DIV><DIV ID="popup_inhalt"><iframe src="http://partners.webmasterplan.com/click.asp?ref=436433&site=2791&type=b109&bnb=109" height="380" width="600" frameborder="0" scrolling="yes">QVC</iframe><BR></DIV><DIV ID="popup_fuss">' + textlinks[0] + footerlinks + '</DIV></DIV>';
werbungen[1] = '<DIV ID="popup" STYLE="top: 150px; left: 400px; width: 604px; height: 460px;"><DIV ID="popup_kopf"><DIV ID="popup_titel" onMousedown="schiebe_box();">Anzeige</DIV><DIV ID="popup_icons"><A HREF="#" onClick="klappe_inhalt(); return false;"><IMG SRC="aufundzu.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Auf-/Zuklappen" TITLE="Auf-/Zuklappen"></A><A HREF="#" onClick="schliesse_box(); return false;"><IMG SRC="schliessen.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Schlie&szlig;en" TITLE="Schlie&szlig;en"></A><BR></DIV></DIV><DIV ID="popup_inhalt"><iframe src="http://partners.webmasterplan.com/click.asp?ref=436433&site=2564&type=b10&bnb=10" height="380" width="600" frameborder="0" scrolling="yes"">Blume2000</iframe><BR></DIV><DIV ID="popup_fuss">' + textlinks[1] +  footerlinks + '</DIV></DIV>';
werbungen[2] = '<DIV ID="popup" STYLE="top: 150px; left: 400px; width: 604px; height: 460px;"><DIV ID="popup_kopf"><DIV ID="popup_titel" onMousedown="schiebe_box();">Anzeige</DIV><DIV ID="popup_icons"><A HREF="#" onClick="klappe_inhalt(); return false;"><IMG SRC="aufundzu.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Auf-/Zuklappen" TITLE="Auf-/Zuklappen"></A><A HREF="#" onClick="schliesse_box(); return false;"><IMG SRC="schliessen.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Schlie&szlig;en" TITLE="Schlie&szlig;en"></A><BR></DIV></DIV><DIV ID="popup_inhalt"><iframe src="http://partners.webmasterplan.com/click.asp?ref=436433&site=3354&type=b12&bnb=12" height="380" width="600" frameborder="0" scrolling="yes"">Neckermann</iframe><BR></DIV><DIV ID="popup_fuss">' + textlinks[2] +  footerlinks + '</DIV></DIV>';
werbungen[3] = '<DIV ID="popup" STYLE="top: 150px; left: 400px; width: 604px; height: 460px;"><DIV ID="popup_kopf"><DIV ID="popup_titel" onMousedown="schiebe_box();">Anzeige</DIV><DIV ID="popup_icons"><A HREF="#" onClick="klappe_inhalt(); return false;"><IMG SRC="aufundzu.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Auf-/Zuklappen" TITLE="Auf-/Zuklappen"></A><A HREF="#" onClick="schliesse_box(); return false;"><IMG SRC="schliessen.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Schlie&szlig;en" TITLE="Schlie&szlig;en"></A><BR></DIV></DIV><DIV ID="popup_inhalt"><iframe src="http://partners.webmasterplan.com/click.asp?ref=436433&site=1879&type=b1&bnb=1" height="380" width="600" frameborder="0" scrolling="yes"">Tchibo</iframe><BR></DIV><DIV ID="popup_fuss">' + textlinks[3] +  footerlinks + '</DIV></DIV>';
werbungen[4] = '<DIV ID="popup" STYLE="top: 150px; left: 400px; width: 604px; height: 460px;"><DIV ID="popup_kopf"><DIV ID="popup_titel" onMousedown="schiebe_box();">Anzeige</DIV><DIV ID="popup_icons"><A HREF="#" onClick="klappe_inhalt(); return false;"><IMG SRC="aufundzu.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Auf-/Zuklappen" TITLE="Auf-/Zuklappen"></A><A HREF="#" onClick="schliesse_box(); return false;"><IMG SRC="schliessen.png" WIDTH=16 HEIGHT=16 BORDER=0 HSPACE=2 ALT="Schlie&szlig;en" TITLE="Schlie&szlig;en"></A><BR></DIV></DIV><DIV ID="popup_inhalt"><iframe src="http://partners.webmasterplan.com/click.asp?ref=436433&site=3657&type=b148&bnb=148" height="380" width="600" frameborder="0" scrolling="yes"">Quelle</iframe><BR></DIV><DIV ID="popup_fuss">' + textlinks[4] +  footerlinks + '</DIV></DIV>';


function init(verzoegerung, geschwindigkeit, schrittweite, richtung) {
  if (is_ie5) { box    = document.all.popup;
                inhalt = document.all.popup_inhalt; }
  else        { box    = document.getElementById('popup');
                inhalt = document.getElementById('popup_inhalt'); }

  g = geschwindigkeit;
  s = schrittweite;
  r = richtung;
  zeige_box();
  /*
  if ((box != null) && (inhalt != null)) {
    setTimeout( "zeige_box()", verzoegerung);
    
  } */
}

function hole_width( div) {
  var w;

  if (is_ie5) { w = div.style.pixelWidth; }
  else        { w = parseInt( div.style.width); }

  return w;
}

function setze_width( div, w) {
  if (is_ie5) { div.style.pixelWidth = w; }
  else        { div.style.width = w + "px"; }
}

function hole_height( div) {
  var h;

  if (is_ie5) { h = div.style.pixelHeight; }
  else        { h = parseInt( div.style.height); }

  return h;
}

function setze_height( div, h) {
  if (is_ie5) { div.style.pixelHeight = h; }
  else        { div.style.height = h + "px"; }
}

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_clientWidth() {
  var w = 0;

  if (typeof( window.innerWidth) == 'number') {
    w = window.innerWidth;
  } else if (document.documentElement &&
             document.documentElement.clientWidth) {
    w = document.documentElement.clientWidth;
  } else if (document.body &&
             document.body.clientWidth) {
    w = document.body.clientWidth;
  }

  return w;
}

function hole_clientHeight() {
  var h = 0;

  if (typeof( window.innerHeight) == 'number') {
    h = window.innerHeight;
  } else if (document.documentElement &&
             document.documentElement.clientHeight) {
    h = document.documentElement.clientHeight;
  } else if (document.body &&
             document.body.clientHeight) {
    h = document.body.clientHeight;
  }

  return h;
}

function hole_visibility( div) {
  return div.style.visibility;
}

function setze_visibility( div, v) {
  div.style.visibility = v;
}

function hole_cookie( name) {
  if (cookies != null) {
    for (var i = 0; i < cookies.length; i++) {
      cookie = cookies[i].split( "=");
      if (cookie[0] == name)
        return unescape( cookie[1]);
    }
  }

  return null;
}

function setze_cookie( name, wert) {
  var ablauf  = new Date( zeit + (14 * 24 * 60 * 60 * 1000));

  document.cookie = name + "=" + escape( wert) + "; expires=" + ablauf.toGMTString();
}

function bewegen() {
  var stop = 0;

  if (inAnimation) {
    if (r == 1) { aX += s; aY += s; }
    if (r == 2) {          aY += s; }
    if (r == 3) { aX -= s; aY += s; }
    if (r == 4) { aX += s; }
    if (r == 5) { }
    if (r == 6) { aX -= s; }
    if (r == 7) { aX += s; aY -= s; }
    if (r == 8) {          aY -= s; }
    if (r == 9) { aX -= s; aY -= s; }

    if ((r == 1) && (aX >= zielX) && (aY >= zielY)) { stop = 1; }
    if ((r == 2) &&                  (aY >= zielY)) { stop = 1; }
    if ((r == 3) && (aX <= zielX) && (aY >= zielY)) { stop = 1; }
    if ((r == 4) && (aX >= zielX))                  { stop = 1; }
    if ((r == 5))                                   { stop = 1; }
    if ((r == 6) && (aX <= zielX))                  { stop = 1; }
    if ((r == 7) && (aX >= zielX) && (aY <= zielY)) { stop = 1; }
    if ((r == 8) &&                  (aY <= zielY)) { stop = 1; }
    if ((r == 9) && (aX <= zielX) && (aY <= zielY)) { stop = 1; }

    if (stop == 1) {
      inAnimation = false;
      setze_position( box, zielX, zielY);
    }
    else {
      setze_position( box, aX, aY);
      setTimeout( "bewegen()", g);
    }
  }
}

function zeige_box() {
  if ((!is_nav4) && (!is_ie3) && (!is_ie4)) {

    zielX = hole_left( box);
    zielY = hole_top( box);
    zielW = hole_width( box);
    zielH = hole_height( box);

    var dw = 0;
    var dh = 0;

    if (r == 1) {
      dw = zielX + zielW;
      dh = zielY + zielH;
    }
    if (r == 3) {
      dw = hole_clientWidth() - zielX;
      dh = zielY + hole_height( box);
    }
    if (r == 7) {
      dw = zielX + hole_width( box);
      dh = hole_clientHeight() - zielY;
    }
    if (r == 9) {
      dw = hole_clientWidth()  - zielX;
      dh = hole_clientHeight() - zielY;
    }

    if (dw > dh) { dw = dw - dh; dh = 0; }
    else         { dh = dh - dw; dw = 0; }

    if ((r == 1) || (r == 4) || (r == 7)) {
      aX = -zielW + dw;
    }
    if ((r == 2) || (r == 5) || (r == 8)) {
      aX = zielX;
    }
    if ((r == 3) || (r == 6) || (r == 9)) {
      aX = hole_clientWidth() - dw;
    }

    if ((r == 1) || (r == 2) || (r == 3)) {
      aY= -zielH + dh;
    }
    if ((r == 4) || (r == 5) || (r == 6)) {
      aY = zielY;
    }
    if ((r == 7) || (r == 8) || (r == 9)) {
      aY = hole_clientHeight() - dh;
    }

    setze_position( box, aX, aY);

    setze_visibility( box, "visible");
    setze_visibility( inhalt, "visible");

    inAnimation = true;
    setTimeout( "bewegen()", g);
  }
}

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 ((aX + zielW) > hole_clientWidth()) {
    setze_width( div, hole_clientWidth() - aX);
  }
  else {
    setze_width( div, zielW);
  }

  if ((aY + zielH) > hole_clientHeight()) {
    setze_height( div, hole_clientHeight() - aY);
  }
  else {
    setze_height( div, zielH);
  }

  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;
}

function waehle_werbung( sperrzeit) {
  var zuletzt = hole_cookie( "popup");

  if ((zuletzt == null) || ((zeit - zuletzt) > sperrzeit)) {
    setze_cookie( "popup", zeit);

    var zufall  = Math.floor( Math.random() * werbungen.length);
    document.writeln( werbungen[zufall]);
  }
}

