//Top left corner hit.
if((ts==ls)&&(ts&&ls<rs&&bs)){Y=TOP-B;X=LEFT-B;D=225}
//Top right corner hit.
if((ts==rs)&&(ts&&rs<ls&&bs)){Y=TOP-B;X=RIGHT;D=315}
//Bottom left corner hit.
if((bs==ls)&&(bs&&ls<ts&&rs)){Y=BOTTOM;X=LEFT-B;D=135}
//Bottom right corner hit.
if((bs==rs)&&(bs&&rs<ls&&ts)){Y=BOTTOM;X=RIGHT;D=45}
//Top hit.
if ((ts<ls)&&(ts<rs)&&(ts<bs)){Q=TOP-(Y+B);Y=TOP-B;X=X+Q*Math.cos(D*Math.PI/180);D=HB;ts=0;Q=0}
//Left hit.
if ((ls<ts)&&(ls<rs)&&(ls<bs)){Q=LEFT-(X+B);Y=Y+Q*Math.sin(D*Math.PI/180);X=LEFT-B;D=VB;ls=0;Q=0}
//Bottom hit.
if ((bs<ls)&&(bs<rs)&&(bs<ts)){Q=BOTTOM-Y;Y=BOTTOM;X=X-Q*Math.cos(D*Math.PI/180);D=HB;bs=0;Q=0}
//Right hit.
if ((rs<ts)&&(rs<ls)&&(rs<bs)){Q=RIGHT-X;Y=Y-Q*Math.sin(D*Math.PI/180);X=RIGHT;D=VB;rs=0;Q=0}
}
}
//Paddle rebounds.
pty=(ie)?pt.pixelTop:parseInt(pt.top);
ptx=(ie)?pt.pixelLeft:parseInt(pt.left);
if ((Y<pty+2)&&(X+B>=ptx)&&(X<=ptx+20)){Y=pty+2;D=135-Math.random()*45}
if ((Y<pty+2)&&(X+B>=ptx+20)&&(X<=ptx+40)){Y=pty+2;D=45+Math.random()*45}
if (Y<pty){Restart()}
pby=(ie)?pb.pixelTop:parseInt(pb.top);
pbx=(ie)?pb.pixelLeft:parseInt(pb.left);
if ((Y+B>pby)&&(X+B>=pbx)&&(X<=pbx+20)){Y=pby-B;D=225+Math.random()*45}
if ((Y+B>pby)&&(X+B>=pbx+20)&&(X<=pbx+40)){Y=pby-B;D=270+Math.random()*45}
if (Y>pby){Restart()}
pry=(ie)?pr.pixelTop:parseInt(pr.top);
prx=(ie)?pr.pixelLeft:parseInt(pr.left);
if ((X+B>prx)&&(Y+B>=pry)&&(Y<=pry+40)){X=prx-B;D=VB}
if (X+B>prx){Restart()}
ply=(ie)?pl.pixelTop:parseInt(pl.top);
plx=(ie)?pl.pixelLeft:parseInt(pl.left);
if ((X<plx)&&(Y+B>=ply)&&(Y<=ply+40)){X=plx;D=VB}
if (X<plx){Restart()}