// Meine Sammlung von JavaScript Funktionen

<!--

// ------------------------------------------------------------------------
// SEND REFERRER
// ------------------------------------------------------------------------

function SendReferrer()
{ 
  // SendReferrer
  var a = top.document.referrer.toLowerCase(); 
  var b = "";

  // Prüfe Delasiava
  if (a.search(/delasiava/) < 0) {

    // Wenn nicht Delasiava prüfe Schwerelos Webring
    if ((a.search(/schwerelos/) > -1) && (a.search(/webring/) > -1)) {
      b= "http:++schwerelos+webring";
    }
    else {
      // Wenn nicht Webring schicke den Referrer zu Goweb
      for (i = 0; i < a.length; i++) {
        if (a.substring(i, i+1) == "/")  {
          b = b + "+"; 
        } 
        else  {
          b = b + a.substring(i, i+1); 
        }
      }
    }

    // Sende Referrer
    document.writeln("<img src=","http://webcounter.goweb.de/129280REF"+b+""," width=1 height=1 alt=' '>");

    // Sende Bildschirmauflösung
    document.write("<img src='http://webcounter.goweb.de/129280WINSIZE"+screen.width+"x"+screen.height+"' border=0>");
  }
}

function GetVisits()
{
  var a= top.document.referrer.toLowerCase(); 
  var counter= 0;

  //Cookie lesen 
  if (document.cookie) {

    var start= document.cookie.indexOf("=") + 1;
    var ende=  document.cookie.indexOf(";");

    if (ende == -1) ende= document.cookie.length;

    visits=  document.cookie.substring(start, ende);
    counter= parseInt(visits);
  }

  // Cookie inkrementieren und schreiben
  counter += 1;
  if (counter == 10000) counter = 0;

//  document.cookie= "Counter=" + counter;

  return counter;
}

// ------------------------------------------------------------------------
// PingPong Funktionen
// ------------------------------------------------------------------------

var marginleft=   0
var margintop=    0
var marginright
var marginbottom

var timer

var pic1Width=  15
var pic1Height= 15
var pic2Width=  15
var pic2Height= 15

//Hier können Sie das Tempo einstellen
var tempo=50

//Parameter für Verschieben in x- und y-Richtung
var delta1_x= 1
var delta1_y= 7
var delta2_x= 3
var delta2_y= 4

function Grundeinstellungen() 
{
  var firsttimer= setTimeout("Einstellungen()", 2000)
}

function Einstellungen() {

  if (document.all) {

    marginbottom= document.body.clientHeight
    marginright=  document.body.clientWidth

    document.all.ball1.style.posLeft= 10
    document.all.ball1.style.posTop=  10
    document.all.ball2.style.posLeft= marginright -  pic2Width
    document.all.ball2.style.posTop=  marginbottom - pic2Height
  }
	
  if (document.layers) {

    marginbottom= window.innerHeight
    marginright=  window.innerWidth

    document.ball1.left= 10
    document.ball1.top=  10
    document.ball2.left= marginright  -  pic2Width
    document.ball2.top=  marginbottom - pic2Height
  }

  BallinBewegung()
}

function GetDistance()
{
  if (document.all) {
    var x1= document.all.ball1.style.posLeft + pic1Width  / 2
    var x2= document.all.ball2.style.posLeft + pic2Width  / 2
    var y1= document.all.ball1.style.posTop  + pic1Height / 2
    var y2= document.all.ball2.style.posTop  + pic2Height / 2
  }

  if (document.layers) {
    var x1= document.ball1.left + pic1Width  / 2
    var x2= document.ball2.left + pic2Width  / 2
    var y1= document.ball1.top  + pic1Height / 2
    var y2= document.ball2.top  + pic2Height / 2
  }

  var dx= Math.abs(x1 - x2)
  var dy= Math.abs(y1 - y2)

  return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2))
}


function Zufallsfaktor(range) {		
  rand= Math.floor(range * Math.random())
  return rand
}

function BallinBewegung() {

  var help

  if (GetDistance() < 15) {
    help=     delta1_y
    delta1_y= delta2_y
    delta2_y= help

    help=     delta1_x
    delta1_x= delta2_x
    delta2_x= help
  }
    
  wobinich()

  if (document.all) {
    document.all.ball1.style.posLeft += delta1_x
    document.all.ball1.style.posTop  += delta1_y
    document.all.ball2.style.posLeft += delta2_x
    document.all.ball2.style.posTop  += delta2_y
  }

  if (document.layers) {
    document.ball1.left += delta1_x
    document.ball1.top  += delta1_y
    document.ball2.left += delta2_x
    document.ball2.top  += delta2_y
  }
  
  timer= setTimeout("BallinBewegung()", tempo)
}

function wobinich() {

  if (document.all) {

    if ((document.all.ball1.style.posTop + delta1_y) <= margintop) {
      document.all.ball1.style.posTop= margintop
      delta1_y *= -1
    }

    if ((document.all.ball2.style.posTop + delta1_y) <= margintop) {
      document.all.ball2.style.posTop= margintop
      delta2_y *= -1
    }

    if (document.all.ball1.style.posLeft <= marginleft) {
      document.all.ball1.style.posLeft= marginleft
      delta1_x *= -1
    }	

    if (document.all.ball2.style.posLeft <= marginleft) {
      document.all.ball2.style.posLeft= marginleft
      delta2_x *= -1
    }	

    if ((document.all.ball1.style.posTop + pic1Height) >= marginbottom) {
      document.all.ball1.style.posTop= marginbottom - pic1Height
      delta1_y *= -1
    }

    if ((document.all.ball2.style.posTop + pic2Height) >= marginbottom) {
      document.all.ball2.style.posTop= marginbottom - pic2Height
      delta2_y *= -1
    }

    if ((document.all.ball1.style.posLeft + pic1Width) >= marginright) {
      document.all.ball1.style.posLeft= marginright - pic1Width
      delta1_x *= -1
    }

    if ((document.all.ball2.style.posLeft + pic2Width) >= marginright) {
      document.all.ball2.style.posLeft= marginright - pic2Width
      delta2_x *= -1
    }
  }

  if (document.layers) {

    if ((document.ball1.top + delta1_y) <= margintop) {
      document.ball1.top= margintop
      delta1_y *= -1
    }

    if ((document.ball2.top + delta1_y) <= margintop) {
      document.ball2.top= margintop
      delta2_y *= -1
    }

    if (document.ball1.left <= marginleft) {
      document.ball1.left= marginleft
      delta1_x *= -1
    }	

    if (document.ball2.left <= marginleft) {
      document.ball2.left= marginleft
      delta2_x *= -1
    }	

    if ((document.ball1.top + pic1Height) >= marginbottom) {
      document.ball1.top= marginbottom - pic1Height
      delta1_y *= -1
    }

    if ((document.ball2.top + pic2Height) >= marginbottom) {
      document.ball2.top= marginbottom - pic2Height
      delta2_y *= -1
    }

    if ((document.ball1.left + pic1Width) >= marginright) {
      document.ball1.left= marginright - pic1Width
      delta1_x *= -1
    }

    if ((document.ball2.left + pic2Width) >= marginright) {
      document.ball2.left= marginright - pic2Width
      delta2_x *= -1
    }
  }
}

//-->


