var a=[],b=Math,G='length',X='x.fillStyle="rgb(',S=150,d=c=O=K=E=y=0,e=1,$=300,f,g,h,i,j,k,l,m,c={};l=[];n=b.random,o=b.round,p=b.PI,q=b.floor;with(document.body.children.c){width=height=$;x=getContext("2d")}x.font="200px Times";setInterval('{g=o(n()*48)+1;if(y<6&!(g in c)){'+X+'2,0,0)";x.fillText(g,S-x.measureText(g).width/2,257);h=x.getImageData(0,0,$,$).data;j=[];for(f=0;f<h[G];f+=4)h[f]==2&n()>.9&&j.push([f/4%$,q(f/1600)]);l.push([g,j]);c[""+g]=1;y++}'+X+'200,200,200)";x.fillRect(0,0,$,$);'+X+'1,0,0)";j=l[K][1];for(g=0;g<1E3;g++){E||a.push([{x:S,y:S,a:q(n()*16)},{x:150,y:150}]);k=a[g][0];m=a[g][1];i=j[g%j[G]];k.d=i[0];k.c=i[1];x.beginPath();x.moveTo(k.x,k.y);x.lineTo(m.x,m.y);x.stroke();m.x=k.x;m.y=k.y;i=k.a*p/8;k.x+=b.sin(i)*2;k.y-=b.cos(i)*2;if(e){i=o(8*b.atan((k.x-k.d)/(k.c-k.y))/p);i+=k.y<k.c?24:16;i%=16;if(i==k.a)k.b=1;else if(n()>.8){if(i<k.a)i+=16;k.b=i-k.a<8?2:0}}else{i=n();k.b=i<.3?0:i<.6?2:1}k.a+=!k.b?15:k.b==2?17:16;k.a%=16}if(++E>100){if(d%3){e=!e;if(d%2){K++;K%=6}}d++;E=0}}',20)
var bugs=[],s=16,M=Math,t=c=O=K=E=y=0,D=1,i,n,img,r,dest,head,luckyNumbers,tail,numBugs=1200,h=300,f=150,c={},luckyNumbers=[];
rand=M.random,round=M.round,P=M.PI,floor=M.floor,startStr='rgb(';
with(document.body.children.c)width=height=h,x=getContext('2d');
x.font = '200px Times';
setInterval(function(){
//get lottery numbers, in number and image form..
n = round(rand()*48)+1;
if(y<6 & !(n in c)){
x.fillStyle=startStr+'2,0,0)';
x.fillText(n, f-x.measureText(n).width/2,257);
img = x.getImageData(0,0,h,h).data;
dest = [];
for(i=0;i<img.length;i+=4){
if(img[i] == 2 & rand() > .9)
dest.push([(i/4) % h, floor(i/1600)]);
}
luckyNumbers.push([n, dest]);
c[''+n]=1;
y++;
}
//reset the canvas..
x.fillStyle=startStr+'200,200,200)';
x.fillRect(0,0,h,h);
x.fillStyle=startStr+'1,0,0)';
dest = luckyNumbers[K][1];
for(n = 0; n < numBugs; n++){
if(!E) bugs.push([{
x: f,
y: f,
angle:floor(rand()*s)
},{x:f,y:f}]);
//draw the bug..
head = bugs[n][0];
tail = bugs[n][1];
//set dest to be the correct thing..
r=dest[n%dest.length]
head.destX = r[0];
head.destY = r[1];
x.beginPath();
x.moveTo(head.x, head.y);
x.lineTo(tail.x, tail.y);
x.stroke();
//update it's position..
tail.x = head.x;
tail.y = head.y;
r=head.angle*P/8;
head.x += M.sin(r) * 2;
head.y -= M.cos(r) * 2;
//update angle/operation..
//only change if with low prop..
if(D){
r = round(8*M.atan((head.x-head.destX)/(head.destY-head.y))/P);
r += (head.y < head.destY) ? 24: s;
r%=s;
//turn towards the desired angle..
if(r == head.angle){
head.op = 1;
} else if(rand() > .8){
if(r < head.angle) r+=s;
head.op = (r - head.angle < 8) ? 2 : 0;
}
} else {
r = rand();
head.op = (r < 0.3) ? 0 : (r < 0.6) ? 2 : 1;
}
head.angle +=(!head.op)?15:(head.op==2)? 17 : s;
head.angle %= s;
}
if(++E>100){
if(t%3){
D=!D;
if(t%2){
K++;
K %= 6;
}
}
t++;
D!=D
E=0;
}
},20);