var vmin=2;
var vmax=5;
var timer1;

function iecompattest(){
   return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body
}

function Chip(chipname,width,height,xx,yy){
  //#me alignment
    this.named=chipname;
    this.vx=vmin+vmax;
    this.vy=vmin+vmax;
    this.w=width+20;
    this.h=height;
    this.xx=xx;
    this.yy=yy;
    //this.xx=852;     //first position
    //this.yy=150;     //first position
    this.timer1=null;
}

function movechip(chipname){
  if (document.getElementById){
    eval("chip="+chipname);
    if (window.innerWidth || window.opera){
      pageX=window.pageXOffset;
      pageW=window.innerWidth-40;
      pageY=window.pageYOffset;
      pageH=window.innerHeight-10;
    }else if (document.body){
      pageX=iecompattest().scrollLeft;
      pageW=iecompattest().offsetWidth-40;
      pageY=iecompattest().scrollTop;
      pageH=iecompattest().offsetHeight-10;
    }
    chip.vx=pageX;
    chip.vy=pageY;    
    if(chip.yy<=pageY+pageH-chip.h){
      //follow on up
      chip.yy+=pageY;
    }
    if(chip.yy>=pageY+pageH-chip.h){
      //follow on down
      chip.yy=pageY+pageH-chip.h;
    }
    document.getElementById(chip.named).style.left=chip.xx+"px";
    document.getElementById(chip.named).style.top=chip.yy+"px";
    chip.timer1=setTimeout("movechip('"+chip.named+"')",100);
  }
}
