// Bubbles Javascript// copyright 23rd February 2006, by Stephen Chapman// permission to use this Javascript on your web page is granted// provided that all of the code in this script (including these// comments) is used without any alteration// you can change the number of bubbles if you likevar num_bubbles = 4;var bubbles = ["http://www.omoriginals.com/images/bubble3.gif","http://www.omoriginals.com/images/bubble4.gif","http://www.omoriginals.com/images/bubble5.gif"];// window size testsfunction findLivePageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:700;}function findLivePageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:500;}function posX() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}function posY() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}// make bubblesvar speed = 50;var movw = new Array();var move = new Array();var stepw = new Array();var posw = new Array();var posh = new Array();var dir = new Array();var winWidth;var winHeight;function setSize() {winWidth = findLivePageWidth()-50;winHeight = findLivePageHeight()-50;}function startBubbles() {setSize(); var content = ''; for (var i = 0; i < num_bubbles; i++){move[i] = 0;movw[i] = 11+ Math.random()*4;posw[i] = Math.random()*(winWidth-35)+12;posh[i] = Math.random()*winHeight;stepw[i] = 0.02 + Math.random()/10;dir[i] = (Math.random()>0.5)?1:-1;content += '<div id="bub'+ i +'" style="position: absolute; z-index: '+ i +'; visibility:hidden;" onclick="posh['+i+']=-50;"><img src="'+bubbles[Math.floor(Math.random()*bubbles.length)]+ '" border="0"></div>';} document.getElementById('bubble').innerHTML = content;setTimeout("moreBubbles()", speed);}function moreBubbles() {for (var i = 0; i < num_bubbles; i++) {if (posh[i] < 0) {posw[i] = 10+ Math.random()*(winWidth-movw[i]-30);posh[i] = winHeight;dir[i]=(Math.random()<0.5)?1:-1;stepw[i] = 0.02 + Math.random()/9;} move[i] += stepw[i] *dir[i];  posh[i]-=1; if (Math.abs(move[i]) > 3) {dir[i]=-dir[i];posw[i]+=movw[i]*move[i]; move[i]=0;} objstyle = document.getElementById('bub'+i).style; objstyle.left = posX()+posw[i] + movw[i]*move[i]; objstyle.top = posY()+posh[i] - 1;objstyle.visibility = 'visible';} setTimeout("moreBubbles()", speed);}window.onload = startBubbles; window.onresize = setSize;
