﻿/************************************************************
 *  Watching Script v1.32_MOD_es-de-we                      *
 *  original von KnoedelDealer (http://knoedeldealer.de/)   *
 *  2007/12/17, MOD von es-de-we (http://es-de-we.net/)     *
 *  und Cheatah 2007/12/19                                  *
 *                                                          *
 *  licensed under the creative commons by-sa 3.0           *
 *  http://creativecommons.org/licenses/by-sa/3.0/          *
 ************************************************************/

var h = -150; /* Oberkante des Bildes in Relation zum Browserfenster. */
var h2 = 1;
var l = 100;
var ie = document.all && !window.opera; /* IE-Erkennung, dank Cheatah gefixt */
var ie7 = (navigator.userAgent.indexOf('MSIE 7.0') > -1);

/**
 * Cross browser event handling for IE5+, NS6+ an Mozilla/Gecko
 * @author Scott Andrew
 */
function addEvent( elm, evType, fn, useCapture )
{
        if( elm.addEventListener )
        { // Standard & Mozilla way:
                elm.addEventListener( evType, fn, useCapture );
                return true;
        }
        else if( elm.attachEvent )
        { // IE way:
                var r = elm.attachEvent( 'on'+evType, fn );
                return r;
        }
        else
        { // "dirty" way (IE Mac for example):
                // Will overwrite any previous handler! :((
                elm['on'+evType] = fn;
                return false;
        }
}

var watching_mouseover = false;

function watching() {
 var body = document.getElementsByTagName('body')[0];
 l = (body.offsetWidth - 140) * Math.random();
 var link = document.createElement('a');
 link.id = 'watchlink';
 link.href='http://www.vorratsdatenspeicherung.de/content/blogsection/9/77/lang,de'; /* Link auf Schäubles Kopf */
 var img = document.createElement('img');
 img.id = 'imgWatching';
 img.src = 'http://www.uhusnest.de/blog/media/head.gif';
 img.title = 'Mr. S. is watching you!';
 img.border = '0';
 img.style.display = 'none';
 addEvent( img, 'mouseover', function() {watching_mouseover=true;}, false );
 addEvent( img, 'mouseout', function() {watching_mouseover=false;}, false );
 link.appendChild(img);
 body.appendChild(link);
 
 if (!ie || ie7) {
      img.style.position = 'fixed';
   } else {
      img.style.position = 'absolute';
   }
 img.style.bottom = h + 'px';
 img.style.left = l + 'px';
 h2 = Math.random() / 3;
 window.setTimeout('moveUp();', 1000);
}

function moveUp() {
 if( watching_mouseover )
 {
   window.setTimeout('moveUp();', 100);
   return;
 }

 if (document.getElementById('imgWatching')) {
 var img = document.getElementById('imgWatching');
 if (img.style.display == 'none') {
 img.style.display = 'inline';
 }
 if (h < (0 - img.height * h2)) {
 h = h + 10;
 img.style.bottom = h + 'px';
 window.setTimeout('moveUp();', 50);
 } else {
 window.setTimeout('moveDown();', 1000 + 10000*Math.random());
 }
 }
}

function moveDown() {
 if( watching_mouseover )
 {
   window.setTimeout('moveDown();', 100);
   return;
 }

 if ((document.getElementById('imgWatching') && (document.getElementsByTagName('body').length > 0))) {
 var body = document.getElementsByTagName('body')[0];
 var img = document.getElementById('imgWatching');
 if (h > (0 - img.height)) {
 h = h - 10;
 img.style.bottom = h + 'px';
 window.setTimeout('moveDown();', 50);
 } else {
 img.style.display = 'none';
 l = (body.offsetWidth - 140) * Math.random();
 img.style.left = l + 'px';
 h2 = Math.random() / 3;
 window.setTimeout('moveUp();', 5000 + 50000*Math.random()); /* Zeit, in der Schäuble nach oben kommt in Millisekunden. Der Wert wird mittels math.random etwas zufälliger. */
 }
 }
}
// window.onload = watching;
addEvent( window, 'load', watching, false );
