﻿var nDots=7,Xpos=0,Ypos=0,DELTAT=.01,SEGLEN=10,SPRINGK=10,MASS=1,XGRAVITY=0,YGRAVITY=50,RESISTANCE=10,STOPVEL=.1,STOPACC=.1,DOTSIZE=11,BOUNCE=.75,isNetscape=navigator.appName=="Netscape",followmouse=true,dots=[];init();function init(){var a=0;for(a=0;a<nDots;a++)dots[a]=new dot(a);if(!isNetscape);for(a=0;a<nDots;a++){dots[a].obj.left=dots[a].X;dots[a].obj.top=dots[a].Y}if(isNetscape)startanimate();else setTimeout("startanimate()",1e3)}function dot(i){this.X=Xpos;this.Y=Ypos;this.dx=0;this.dy=0;if(isNetscape)this.obj=eval("document.dot"+i);else this.obj=eval("dot"+i+".style")}function startanimate(){setInterval("animate()",20)}function setInitPositions(b){var c=document.all.tags("LI"),a=0;for(a=0;a<c.length&&a<nDots-1;a++){b[a+1].X=c[a].offsetLeft;c[a].offsetParent.offsetLeft-DOTSIZE;b[a+1].Y=c[a].offsetTop+c[a].offsetParent.offsetTop+2*DOTSIZE}b[0].X=b[1].X;b[0].Y=b[1].Y-SEGLEN}function MoveHandler(a){Xpos=a.pageX;Ypos=a.pageY;return true}function MoveHandlerIE(){Xpos=window.event.x+document.body.scrollLeft;Ypos=window.event.y+document.body.scrollTop}if(isNetscape){document.captureEvents(Event.MOUSEMOVE);document.onMouseMove=MoveHandler}else document.onmousemove=MoveHandlerIE;function vec(a,b){this.X=a;this.Y=b}function springForce(f,g,e){var b=dots[f].X-dots[g].X,c=dots[f].Y-dots[g].Y,a=Math.sqrt(b*b+c*c);if(a>SEGLEN){var d=SPRINGK*(a-SEGLEN);e.X+=b/a*d;e.Y+=c/a*d}}function animate(){var f=0;if(followmouse){dots[0].X=Xpos;dots[0].Y=Ypos;f=1}for(i=f;i<nDots;i++){var b=new vec(0,0);if(i>0)springForce(i-1,i,b);if(i<nDots-1)springForce(i+1,i,b);var e=new vec(-dots[i].dx*RESISTANCE,-dots[i].dy*RESISTANCE),c=new vec((b.X+e.X)/MASS+XGRAVITY,(b.Y+e.Y)/MASS+YGRAVITY);dots[i].dx+=DELTAT*c.X;dots[i].dy+=DELTAT*c.Y;if(Math.abs(dots[i].dx)<STOPVEL&&Math.abs(dots[i].dy)<STOPVEL&&Math.abs(c.X)<STOPACC&&Math.abs(c.Y)<STOPACC){dots[i].dx=0;dots[i].dy=0}dots[i].X+=dots[i].dx;dots[i].Y+=dots[i].dy;var a,d;if(isNetscape){a=window.innerHeight+window.pageYOffset;d=window.innerWidth+window.pageXOffset}else{a=document.body.clientHeight+document.body.scrollTop;d=document.body.clientWidth+document.body.scrollLeft}if(dots[i].Y>=a-DOTSIZE-1){if(dots[i].dy>0)dots[i].dy=BOUNCE*-dots[i].dy;dots[i].Y=a-DOTSIZE-1}if(dots[i].X>=d-DOTSIZE){if(dots[i].dx>0)dots[i].dx=BOUNCE*-dots[i].dx;dots[i].X=d-DOTSIZE-1}if(dots[i].X<0){if(dots[i].dx<0)dots[i].dx=BOUNCE*-dots[i].dx;dots[i].X=0}dots[i].obj.left=dots[i].X;dots[i].obj.top=dots[i].Y}}
