//------------------------------------------------------
//         Watching Eyes Script (Second edition)
//              script by Virtual_Max 
// Please, check my site for latest edition of this script
//      http://www.geocities.com/siliconvalley/lakes/8620    
// This script can be used/modified free without special permission 
// until this notice presents unchanged in all copies and derivatives.             
//------------------------------------------------------

function moveObject(ex,ey,objectid)
{if(document.layers)
                 {document[objectid].top = ey;
                  document[objectid].left = ex;
                 }
 if(document.all){document.all[objectid].style.pixelTop = ey;
                  document.all[objectid].style.pixelLeft = ex;
                 }
}

var mx=200;
var my=200;
var rx=0;
var ry=-200;
var eyetimer=null;

function mymousemoved(ex,ey)
{mx=ex; my=ey;}

function movestart()
{rx+=(mx-rx-40)*0.1;
 ry+=(my-ry-60)*0.1; 
 dy=my-ry-20;
 dx1=mx-rx-20;
 dx2=mx-rx-60;
 r=Math.sqrt(dx1*dx1+dy*dy);
 if(r<20) r=20
 dx1=dx1*10/r+rx+10;
 dy1=dy*10/r+ry+10;
 r=Math.sqrt(dx2*dx2+dy*dy);
 if(r<20) r=20
 dx2=dx2*10/r+rx+50;
 moveObject(Math.floor(rx),Math.floor(ry),"eyeballs");
 moveObject(Math.floor(dx1),Math.floor(dy1),"lefteye");
 moveObject(Math.floor(dx2),Math.floor(dy1),"righteye");
 eyetimer=setTimeout("movestart()",100);
}

function myhandler(e)
{if(e)
  {ex=e.pageX; 
   ey=e.pageY;
   mymousemoved(ex,ey);
   return routeEvent(e);
  }
 if(event)
  {ex=event.clientX+window.document.body.scrollLeft;
   ey=event.clientY+window.document.body.scrollTop;
   mymousemoved(ex,ey);
  }
 return null;  
}

function clearmytimer()
 {if(eyetimer!=null) clearTimeout(eyetimer);
 }

function setupeyes(href,eyeballs,eye)
{if(document.layers)
   {window.captureEvents(Event.MOUSEMOVE);
    window.onMouseMove=myhandler;
    window.onresize=new Function('history.go(0)');
   }
 if(document.all)
   {document.onmousemove=myhandler;}

 window.onunload = clearmytimer;
 s='<style type=text/css>';
 s+='    .eyes {position:absolute; top:200; left:200; width:1;}';
 s+='</style>';
 document.writeln(s);
 s ='<div ID="eyeballs" CLASS="eyes">'
 if(href) s+='<A HREF="http://come.to/vmax">'
 s+='<IMG SRC="'+eyeballs+'" border=0>'
 if(href) s+='</A>'
 s+='</div><div ID="lefteye"  CLASS="eyes">'
 if(href) s+='<A HREF="http://come.to/vmax">'
 s+='<IMG SRC="'+eye+'" border=0>'
 if(href) s+='</A>'
 s+='</div><div ID="righteye" CLASS="eyes">'
 if(href) s+='<A HREF="http://come.to/vmax">'
 s+='<IMG SRC="'+eye+'" border=0>'
 if(href) s+='</A>'
 s+='</div>';
 document.writeln(s);
 movestart();
}

