// Moving Objects Script
// By Virtual_Max
// 
// Permission to use, copy, modify, and distribute this software and its documentation 
// for NON-COMMERCIAL purposes and  without fee is hereby granted provided that this 
// notice appears in all copies. 
//
// VIRTUAL MAX MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE 
// SOFTWARE, EITHER EXPRESS OR IMPLIED


var brOK=false;
var mie=false;
var aver=parseInt(navigator.appVersion.substring(0,1));
var aname=navigator.appName;

function checkbrOK()
{if(aname.indexOf("Internet Explorer")!=-1)
   {if(aver>=4) brOK=navigator.javaEnabled();
    mie=true;
   }
 if(aname.indexOf("Netscape")!=-1)  
   {if(aver>=4) brOK=navigator.javaEnabled();}
}

var vmin=2;
var vmax=5;
var timer1;
var speed = 30;

function Chip(chipname,width,height)
{this.named=chipname;
 this.vx=speed;
 this.vy=speed;
 //vmin+vmax*Math.random()
 this.w=width;
 this.h=height;
 this.xx=0;
 this.yy=110;
 this.timer1=null;
}

function movechip(chipname)
{
 if(brOK)
  {eval("chip="+chipname);
   if(!mie)
    {pageX=window.pageXOffset;
     pageW=(window.innerWidth-20);
     pageY=window.pageYOffset;
     pageH=(window.innerHeight-20);
    }
   else
    {pageX=window.document.body.scrollLeft;
     pageW=(window.document.body.offsetWidth-20);
     pageY=window.document.body.scrollTop;
     pageH=(window.document.body.offsetHeight-20);
    } 

   chip.xx = chip.xx+chip.vx;
   
    if (speed <= 8) {
		speed = 8;
	} else
		speed -= 3;
	
	
   chip.vx = speed; 

   if(chip.xx<=pageX)
     {chip.xx=pageX;
		chip.vx = speed;

     }
   if(chip.xx>=(pageX+pageW-chip.w)/2)
     {chip.xx=(pageX+pageW-chip.w)/2;
		chip.vx = 0;
		speed = 0;
     }

   if(document.layers)
      {eval('document.'+chip.named+'.top ='+chip.yy);
       eval('document.'+chip.named+'.left='+chip.xx);
      } 
   else if (document.all)
      {eval('document.all.'+chip.named+'.style.pixelLeft='+chip.xx);
       eval('document.all.'+chip.named+'.style.pixelTop ='+chip.yy); 
      }
   else if (document.getElementById)
      {document.getElementById(chip.named).style.left=chip.xx;
       document.getElementById(chip.named).style.top =chip.yy; 
      }
   chip.timer1=setTimeout("movechip('"+chip.named+"')",100);
  }
}


function stopme(chipname)
{if(brOK)
  {//alert(chipname)
   eval("chip="+chipname);
   if(chip.timer1!=null)
    {clearTimeout(chip.timer1)}
  }
}
