<script type="text/javascript">
<!--
var sn = 12; // Antal

var x, y; 
var fall, wind, rad; 
var i, width, height;
var mX, mY, mXo, mYo; 

x = new Array();
y = new Array();
fall = new Array();
wind = new Array();
rad = new Array();

snowflakesload(
'Snowflake1.png',
'Snowflake_Big1.gif',
'Snowflake_Small1.png'
)

function snowflakesload()
{
var args = snowflakesload.arguments;
document.snowflakes = new Array(args.length);
for (var i=0; i < args.length; i++)
{
document.snowflakes[i] = new Image;
document.snowflakes[i].src = args[i];
}
}

var ie = (document.all)?1:0;
var ns = (document.getElementById & & !document.all)?1:0;

if (ie) {
width = document.body.clientWidth;
height = document.body.clientHeight;
} else if (ns) {
width = self.innerWidth;
height = self.innerHeight;
}

for (i = 0; i < sn; i++) {
and motion values for each snowflakes
x[i] = Math.random()*(width-50);
y[i] = Math.random()*(height-50);
fall[i] = 1+Math.random()*2;
wind[i] = Math.random()*Math.PI-Math.PI;
rad[i] = 0;

document.write("<img id=\"snowflake"+ i +"\"
src=\"" + document.snowflakes[Math.floor(Math.random()*
document.snowflakes.length)].src + "\"
style=\"position: absolute; z-index: "+ i
+ "; visibility: hidden; top: 15px; left: 15px; filter:alpha(opacity=100); -moz-opacity: 1;\"
border=\"0\">");
}

function snow() {
var out = 0;

if (document.getElementById("fall").value == 'Stop') {
for (i = 0; i < sn; i++)
{
y[i] += fall[i];

if (document.getElementById("snowflake"+i).offsetLeft +
document.getElementById("snowflake"+i).offsetWidth >= width-3 ||
document.getElementById("snowflake"+i).offsetTop +
document.getElementById("snowflake"+i).offsetHeight >= height-3)
{out = 1} else {out = 0}; 

if (out) { 
x[i] = Math.random()*(width-50);
y[i] = 0;
fall[i] = 1+Math.random()*2;
wind[i] = Math.random()*Math.PI-Math.PI;
rad[i] = 0;
width = ns ? window.innerWidth : document.body.clientWidth;
height = ns ? window.innerHeight : document.body.clientHeight;

document.getElementById("snowflake"+i).src =
document.snowflakes[Math.floor(Math.random() * document.snowflakes.length)].src;
}

rad[i] += (wind[i]/180)*Math.PI;

if (document.getElementById("mouse").value == 'On')
{ 
x[i]+=mX;
y[i]+=mY;
}

document.getElementById("snowflake"+i).style.left = x[i] +
Math.cos(rad[i])*20;
document.getElementById("snowflake"+i).style.top = y[i];
}
}
}

function onoff()
{ 
document.getElementById("fall").value=='Start' ?
document.getElementById("fall").value='Stop' :
document.getElementById("fall").value='Start';

if (document.getElementById("fall").value=='Stop') {
snow();
snow_on=setInterval("snow()", 20);
} else { clearInterval(snow_on); }

document.getElementById("showhide").value='Hide';
for (i = 0; i < sn; i++) {
document.getElementById("snowflake"+i).style.visibility =
"visible"; } // sets visibility of all snowflakes to "visible"
}

function setopasity()
{
document.getElementById("opacity").value=='On' ?
document.getElementById("opacity").value='Off' :
document.getElementById("opacity").value='On';

for (i = 0; i < sn; i++)
{
if (document.getElementById("opacity").value=='On') {
if (ie){
document.getElementById("snowflake"+i).filters.alpha.opacity =
Math.floor(20+Math.random()*80); } else
if (ns){
document.getElementById("snowflake"+i).style.MozOpacity =
0.2+Math.random()*0.8; }
} else {
if (ie){
document.getElementById("snowflake"+i).filters.alpha.opacity =
100; } else
if (ns){
document.getElementById("snowflake"+i).style.MozOpacity = 1; }
}
}
}

function mouseon()
{
document.getElementById("mouse").value=='On' ?
document.getElementById("mouse").value='Off' :
document.getElementById("mouse").value='On';

mX = 0; 
mY = 0; 

mX0 = width/2; 
mY0 = height/2;

document.onmousemove = getMouse; 

function getMouse(e)
{ // get mouse pointer coordinates
if(ns) {
mX = e.pageX;
mY = e.pageY;
} else {
mX = event.x + document.body.scrollLeft;
mY = event.y + document.body.scrollTop;
}

// ändra X och Y led för snöflingorna
mX = (mX - mX0)/(200);
mY = (mY - mY0)/(600);

return true;
}
}

// visa / göm snöflingorna
function hidesnow()
{
document.getElementById("showhide").value=='Show' ?
document.getElementById("showhide").value='Hide' :
document.getElementById("showhide").value='Show';

for (i = 0; i < sn; i++)
{ 
document.getElementById("showhide").value=='Hide' ?
document.getElementById("snowflake"+i).style.visibility = "visible" :
document.getElementById("snowflake"+i).style.visibility = "hidden";
}
}
Action: <input id="fall" type="button" value="Start" onClick="onoff()">    
Opacity: <input id="opacity" type="button" value="Off" onClick="setopasity()">    
Mouse catching: <input id="mouse" type="button" value="Off" onClick="mouseon()">    
Visibility: <input id="showhide" type="button" value="Hide" onClick="hidesnow()">
//-->
</script>

Action: <input id="fall" type="button" value="Start" onClick="onoff()">    
Opacity: <input id="opacity" type="button" value="Off" onClick="setopasity()">    
Mouse catching: <input id="mouse" type="button" value="Off" onClick="mouseon()">    
Visibility: <input id="showhide" type="button" value="Hide" onClick="hidesnow()">