
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=5;
var vmax=5;
var vr=2;
var timer1;
var count=0;

	

function Chip(chipname,width,height)
{
 
 this.named=chipname;
 this.vx=-5;
 this.vy=vmin;
 this.w=width;
 this.h=height;
 this.xx=0;
 this.yy=0;
 this.timer1=null;
}

function movechip(chipname)
{
    if(brOK){
		eval("chip="+chipname);
        if(!mie){
			pageX=window.pageXOffset;
     		pageW=window.innerWidth-20;
			pageCenter=(window.innerWidth-240)/2;
     		pageY=window.pageYOffset;
     		pageH=window.innerHeight-20;
    	}else{
			pageX=window.document.body.scrollLeft;
     		pageW=window.document.body.offsetWidth-20;
			pageCenter=(window.document.body.offsetWidth-240)/2;
     		pageY=window.document.body.scrollTop;
     		pageH=window.document.body.offsetHeight-20;
    	} 
		chip.xx=chip.xx+ chip.vx;
   		if(chip.xx<=pageX){
			chip.xx=pageX;
      		chip.vx=5;
		}
   		if(chip.xx>=pageX+pageW-chip.w){
			chip.xx=pageCenter;
      		chip.vx=-5;
		}
   
   	if(chip.xx<pageCenter && count<3){
   		if(document.layers){
       		eval('document.'+chip.named+'.left='+chip.xx);
      	}else if (document.all){
			eval('document.all.'+chip.named+'.style.pixelLeft='+chip.xx);
      	}else if (document.getElementById){
			document.getElementById(chip.named).style.left=chip.xx;
      	}
		
	}
   	if(chip.xx<=0){
		count=count+1;
		
	}
   	if(count<3){
   		chip.timer1=setTimeout("movechip('"+chip.named+"')",50);
	}else if(count<4){
	  chip.timer1=setTimeout("movechip('"+chip.named+"')",8);
	}else{
		stopme(chip.named);
		hiddenme(chip.named);
	}
  }
}

function hiddenme(chip){
   	if(brOK){
		if(document.layers){
       		document.layers[chip].visibility='hidden';
    	}else if (document.all){
			document.all[chip].style.visibility='hidden';
    	}else if (document.getElementById){
			document.getElementById(chip).style.visibility='hidden';
    	}
	}
}
function stopme(chipname)
{if(brOK)
  {//alert(chipname)
   eval("chip="+chipname);
   if(chip.timer1!=null)
    {clearTimeout(chip.timer1)}
  }
}
