var snow_no = 11; // snow number var snow_speed = 15; // smaller number moves the snow faster var snow_flakes = new Array("http://shared.guweb.com/bgfx/stars/stern09.gif"); var snow_reverse = 0; /* Basic script for all snow-like background animations Original script source unknown, but found as public domain code on a JavaScript site Many modifications by NOVASYS. Distribution prohibited. --- This new version should be included in the HTML page AFTER some JavaScript variables have been initialized. These are: var snow_no = 10; // number of "snow flakes" var snow_speed = 15; // moving speed (smaller value=faster) var snow_flakes = array(...) // array with flake images (min. 1 item) var snow_reverse = 1; // set if "flakes" should fly upwards snow_speed is simply the update interval in milliseconds. */ if (!snow_reverse) var snow_reverse=0; var ns4up = (document.layers) ? 1 : 0; // browser sniffer var ie4up = (document.all) ? 1 : 0; var dx, xp, yp; // coordinate and position variables var am, stx, sty; // amplitude and step variables var i, doc_width = 800, doc_height = 600; /* if (ns4up) { doc_width = self.innerWidth; doc_height = self.innerHeight; } else if (ie4up) { doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } */ // This method works regardless of browser brand: doc_width = self.innerWidth; doc_height = self.innerHeight; if (!doc_width) { doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } var bgfxint; dx = new Array(); xp = new Array(); yp = new Array(); am = new Array(); stx = new Array(); sty = new Array(); var flakeid=0; var code=""; for (i = 0; i < snow_no; ++ i) { dx[i] = 0; // set coordinate variables xp[i] = Math.random()*(doc_width-50); // set position variables yp[i] = Math.random()*doc_height; am[i] = Math.random()*20; // set amplitude variables stx[i] = 0.02 + Math.random()/10; // set step variables sty[i] = 0.7 + Math.random(); // set step variables snowflake = snow_flakes[flakeid]; if (ns4up) { // set layers document.write(""); } else /*if (ie4up)*/ { // this method is used for any browser... code += '
' + '
'; } flakeid++; if (flakeid >= snow_flakes.length) flakeid=0; } var mydiv; if (document.getElementById) mydiv = document.getElementById("bgfxdiv"); if (mydiv) { mydiv.innerHTML = code; } else { alert('document.write: '+code); document.write('
' + code + '
'); } function snowNS() { // Netscape main animation function for (i = 0; i < snow_no; ++ i) { // iterate for every dot yp[i] += sty[i]; if (yp[i] > doc_height-50 ) { xp[i] = Math.random()*(doc_width-am[i]-30); yp[i] = 0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = self.innerWidth; doc_height = self.innerHeight; } dx[i] += stx[i]; if (snow_reverse) document.layers["dot"+i].top = doc_height - yp[i] + window.pageYOffset - 50; else document.layers["dot"+i].top = yp[i] + window.pageYOffset; document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]) + window.pageXOffset; } bgfxint = setTimeout("snowNS()", snow_speed); } function snowIE() { // IE main animation function for (i = 0; i < snow_no; ++ i) { // iterate for every dot yp[i] += sty[i]; if (yp[i] > doc_height-50) { xp[i] = Math.random()*(doc_width-am[i]-30); yp[i] = 0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } dx[i] += stx[i]; if (snow_reverse) document.all["dot"+i].style.pixelTop = doc_height - yp[i] + document.body.scrollTop - 50; else document.all["dot"+i].style.pixelTop = yp[i] + document.body.scrollTop; document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]) + document.body.scrollLeft; } bgfxint = setTimeout("snowIE()", snow_speed); } function snowOther() { // last resort animation function (used for FireFox, for example) ofsX = document.body.scrollLeft; ofsY = document.body.scrollTop; if (!ofsX) { ofsX = window.pageXOffset; if (!ofsX) ofsX=0; } if (!ofsY) { ofsY = window.pageYOffset; if (!ofsY) ofsY=0; } for (i = 0; i < snow_no; ++ i) { // iterate for every dot yp[i] += sty[i]; if (yp[i] > doc_height-50) { xp[i] = Math.random()*(doc_width-am[i]-30); yp[i] = 0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } dx[i] += stx[i]; dot = document.getElementById("dot"+i); if (snow_reverse) newY = doc_height - yp[i] + ofsY - 50; else newY = yp[i] + ofsY; if (dot.style) { if (dot.style.pixelTop) { dot.style.pixelTop = newY; dot.style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]) + ofsX; } else { dot.style.top = newY; dot.style.left = xp[i] + am[i]*Math.sin(dx[i]) + ofsX; } } else return; // interrupt animation (browser not supported) } bgfxint = setTimeout("snowOther()", snow_speed); } if (ns4up) { snowNS(); } else if (ie4up) { snowIE(); } else { // check if we can find the snow if (document.getElementById) { anysnow = document.getElementById('dot0'); if (anysnow) snowOther(); } } function bgfx_stop() { if (bgfxint) { clearTimeout(bgfxint); } if (document.getElementById) mydiv = document.getElementById("bgfxdiv"); if (mydiv) mydiv.innerHTML=""; }