4umi.com/web/javascript/eyes

Eyes

Mousetail Javascript

The classic pair of untiring eyes keeps a close watch on your every movement. Examine the script.

var loaded=false;
var brOK=parseInt(navigator.appVersion.charAt())>=4?1:0;
var ie=(document.all)?1:0;
var ex=0,ey=0,x0,y0,realx,realy,ae,le,re,tid;
function movens(e) {
  ex=e.pageX;
  ey=e.pageY;
  moveeye();
  return routeEvent(e);
}
function moveie() {
  if(brOK&&loaded) {
    ex=document.documentElement.scrollLeft+event.x;
    ey=document.documentElement.scrollTop+event.y;
    moveeye();
  }
}
function moveeye() {
  dy=ey-y0-20;
  dx1=ex-x0-20;
  dx2=ex-x0-60;
  r=Math.sqrt(dx1*dx1+dy*dy);
  if(r<20)
    r=20;
  dx1=dx1*10/r+x0+10;
  dy1=dy*10/r+y0+10;
  r=Math.sqrt(dx2*dx2+dy*dy);
  if(r<20)
    r=20;
  dx2=dx2*10/r+x0+50;
  ae.left=x0;
  ae.top=y0;
  le.left=dx1;
  le.top=dy1;
  re.left=dx2;
  re.top=dy1;
}
function setHandlers() {
  if(!ie) {
    y0=document.eyeballs.top;
    x0=document.eyeballs.left;
    ae=document.eyeballs;
    le=document.lefteye;
    re=document.righteye;
    window.captureEvents(Event.MOUSEMOVE);
    window.onMouseMove = movens;
  }else{
    y0=document.all.eyeballs.style.pixelTop;
    x0=document.all.eyeballs.style.pixelLeft;
    ae=document.all.eyeballs.style;
    le=document.all.lefteye.style;
    re=document.all.righteye.style;
    document.onmousemove = moveie;
  }
  realx=x0+0.1;
  realy=y0+0.1;
  moveall();
  loaded=true;
}
function moveall() {
  rx=realx+40;
  ry=realy+40;
  rx+=(ex-rx)*0.1;
  ry+=(ey-ry)*0.1;
  realx=rx-40;
  realy=ry-40;
  x0=Math.round(realx);
  y0=Math.round(realy);
  moveeye();
  tid = window.setTimeout('moveall();',100);
}
function placeeyes() {
 if( brOK ) {
  var x=-90, y=0,
   s = '<div id="eyeballs" style="position:absolute; top:'+y+'px; left:'+x+'px; width:80px; height:40px;">' +
    '<img src="/image/clip/eyeballs.gif" border="0"></div>' +
    '<div id="lefteye" style="position:absolute; top:'+(y+10)+'px; left:'+(x+10)+'px; width:20px; height:20px;">' +
    '<img src="/image/clip/eye.gif" border="0"></div>' +
    '<div id="righteye" style="position:absolute; top:'+(y+10)+'px; left:'+(x+50)+'px; width:20px; height:20px;">' +
    '<img src="/image/clip/eye.gif" border="0"></div>';
  document.write( s );
 } else {
  document.write( 'Sorry, your browser is too advanced for the script on this page. Please downgrade to Internet Explorer.' );
 }
}

window.onload = function() { if(brOK) { setHandlers(); } }
window.onunload = function() {if(tid) { window.clearTimeout(tid); } }
placeeyes();