setconfig("http://www.fallingobjects.info/gifs/1202980849581.gif",100,2); var oldwindoww,oldwindowh,windoww,windowh,whichbrowser,picture,total,speed,oldhiddentop,hiddentop,moving; window.onresize = windowsize; window.onscroll = scrollcheck; function browsertype() { if(!document.all) { if(document.getElementById) whichbrowser=1; } else whichbrowser=2; } function windowsize() { if(whichbrowser=="") browsertype(); if(whichbrowser==1) { if(oldwindoww=="") oldwindoww=window.innerWidth; else oldwindoww=windoww; windoww=window.innerWidth; if(oldwindowh=="") oldwindowh=window.innerHeight; else oldwindowh=windowh; windowh=window.innerHeight+hiddentop; } else { if(oldwindoww=="") oldwindoww=document.body.clientWidth; else oldwindoww=windoww; windoww=document.body.clientWidth; if(oldwindowh=="") oldwindowh=document.body.clientHeight; else oldwindowh=windowh; windowh=document.body.clientHeight+hiddentop; } if(moving) { var averagediff = (windoww-oldwindoww)/oldwindoww; var averagediff2 = (windowh-oldwindowh)/oldwindowh; for(i=1;i<=total;i++) { var checkleft = parseInt(document.getElementById("movingobject"+i).style.left); var newleft = parseInt(checkleft+averagediff*checkleft); if(newleft<0) newleft=0; if(newleft>(windoww-70)) newleft = windoww-70; document.getElementById("movingobject"+i).style.left = newleft; var checktop = parseInt(document.getElementById("movingobject"+i).style.top); var newtop = parseInt(checktop+averagediff2*checktop); if(newtop>(windowh-50)) newtop=Math.round(Math.random()*(-600)-100); document.getElementById("movingobject"+i).style.top = newtop; } } } function scrollcheck(){ if(whichbrowser=="") browsertype(); if(whichbrowser==1) { oldhiddentop=hiddentop; hiddentop = window.pageYOffset; } else { oldhiddentop=hiddentop; hiddentop = document.body.scrollTop; } //alert(hiddentop+ " "+oldhiddentop); if(moving) { oldwindowh=windowh; windowh=windowh+(hiddentop-oldhiddentop); for(i=1;i<=total;i++) { var checktop = parseInt(document.getElementById("movingobject"+i).style.top); var newtop = parseInt(checktop+(hiddentop-oldhiddentop)); document.getElementById("movingobject"+i).style.top = newtop; } } } function setconfig(temppicture,temptotal,tempspeed) { if(tempspeed>3) tempspeed=3; if(tempspeed<1) tempspeed=1; if(temptotal<10) temptotal=10; if(temptotal>100) temptotal = 100; oldhiddentop=0; hiddentop=0; picture = temppicture; total = temptotal; speed = tempspeed; browsertype(); windowsize(); scrollcheck(); populate(); move(); } function populate() { var randleft; var randtop; for(i=1;i<=total;i++) { randleft = Math.round(Math.random()*(windoww-100)+30); randtop = Math.round(Math.random()*(-600)-100); if(randleft<0) randleft=0; document.write(""); } } function move() { var movedown; var moveleft; var currenttop; var currentleft; var newtop; var newleft; moving = 1; for(i=1;i<=total;i++) { movedown = Math.round(Math.random()*speed+speed) currenttop = parseInt(document.getElementById("movingobject"+i).style.top); newtop = parseInt(currenttop+movedown); if(newtop>(windowh-50)) { document.getElementById("movingobject"+i).style.top=hiddentop; continue; } currentleft = parseInt(document.getElementById("movingobject"+i).style.left); moveleft = Math.round(Math.cos(Math.random()*Math.PI)*1.5); if(parseInt(currentleft+moveleft)<(windoww-70)) newleft = parseInt(currentleft+moveleft); else newleft = parseInt(currentleft-moveleft); document.getElementById("movingobject"+i).style.top= newtop; document.getElementById("movingobject"+i).style.left= newleft; } setTimeout("move()",90/speed); }