// JavaScript Document
var speed=200;    //SPEED IN MILLISECONDS.
var change=800;   //TIME BETWEEN DIRECTION CHANGES IN MILLISECONDS. 
var xmax=15;      //MAX NUMBER OF PIXEL STEPS LEFT OR RIGHT.        
var ymax=15;      //MAX NUMBER OF PIXEL STEPS UP OR DOWN.
var isNS=(navigator.appName=="Netscape");
var _all='all.';
var _style='.style';
var _visible='visible';
var w_x, w_y, x, y, tx, ty, xo, yo, img1;
var incrx=2;
var incry=8;
var xdir=true;
var ydir=true;
if(isNS){
_all='';
_style='';
_visible='show';
}
function init(){
img1=eval('document.'+_all+'img1'+_style);
resize();
moveimg(w_x/2,w_y/2);
img1.visibility=_visible;
animate();
changedirs();
}

function resize(){
if(isNS){
w_x=window.innerWidth-document.f.image1.width;
w_y=window.innerHeight-document.f.image1.height;
}else{
w_x=document.body.clientWidth-document.f.image1.width;
w_y=document.body.clientHeight-document.f.image1.height;
}}

function changedirs(){
xdir=(Math.floor(Math.random()*2)==0);
ydir=(Math.floor(Math.random()*2)==0);
incrx=Math.floor(Math.random()*xmax);
incry=Math.floor(Math.random()*ymax);
setTimeout('changedirs()',change);
}

function animate(){
if(isNS){
tx=img1.left;
ty=img1.top;
xo=pageXOffset;
yo=pageYOffset;
}else{
tx=img1.pixelLeft;
ty=img1.pixelTop;
xo=document.body.scrollLeft;
yo=document.body.scrollTop;
}
if(ydir){
if((ty+incry)>(w_y+yo)){ ydir=false; moveimg(0,-incry); }else{ moveimg(0,incry); }
}else{
if((ty-incry)<yo){ ydir=true; moveimg(0,incry); }else{ moveimg(0,-incry); }
}
if(xdir){
if((tx+incrx)>(w_x+xo)){ xdir=false; moveimg(-incrx,0); }else{ moveimg(incrx,0); }
}else{
if((tx-incrx)<xo){ xdir=true; moveimg(incrx,0); }else{ moveimg(-incrx,0); }
}
setTimeout('animate()',speed);
}

function moveimg(dx,dy){
if(isNS){
img1.moveBy(dx,dy);
}else{
img1.pixelTop+=dy;
img1.pixelLeft+=dx;
}}
