// CREDITS: // Snowmaker Copyright (c) 2003 Peter Gehrig. All rights reserved. 
// Distributed by http://www.hypergurl.com
// Permission given to use the script on webpages provided that this notice remains as is.
// Set the number of snowflakes (more than 30 - 40 not recommended)
var snowmax=0;
// Set the colors for the sn
// Add as many colors as you like
var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD") 
// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS") // Set the letter that creates your snowflake (recommended:*)
var snowletter="*" // Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed=2.0 // Set the maximal-size of your snowflaxes
var snowmaxsize=30 // Set the minimal-size of your snowflaxes
var snowminsize=2
// Set the snowing-zone
// Set 1 for all-over-snowing, set 2 for left-side-snowing 
// Set 3 for center-snowing, set 4 for right-side-snowing
// 5 custom area
var snowingzone=5 /////////////////////////////////////////////////////////////////////////// 
// CONFIGURATION ENDS HERE /////////////////////////////////////////////////////////////////////////// 
// Do not edit below this line
var snow=new Array()
var marginbottom
var marginright 
var timer
var i_snow=0
var x_mv=new Array();
var crds=new Array();
var lftrght=new Array();
var browserinfos=navigator.userAgent
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/) 
var ns6=document.getElementById&&!document.all
var opera=browserinfos.match(/Opera/) 
var browserok=ie5||ns6||opera

function randommaker(range) {
	rand=Math.floor(range*Math.random()) 
	if(rand < 0)
		rand = rand * -1;
	return rand
	//return 1;
}

function initsnow() {
	contestbox = document.getElementById('contest-box');
	snowmax = contestbox.title;
	for (i=0;i<=snowmax;i++) 
	{
		var snowflake
		snowflake = document.getElementById('contest-box').appendChild((typeof document.createElementNS != 'undefined') ? document.createElementNS('http://www.w3.org/1999/xhtml', 'img') : document.createElement('img'));
		snowflake.src = '/images/sf.gif';
		snowflake.style.zIndex = String(randommaker(2)+2);
		snowflake.style.position = 'absolute';
		snowflake.style.top = snowmaxsize + 'px';
		//snowflake.innerHTML = snowletter; 
		snowflake.id = 's'+i;
		snowflake.title = snowflake.style.zIndex;
	}
	var snowsizerange=snowmaxsize-snowminsize
	for (i=0;i<=snowmax;i++)
	{
		crds[i] = 0;
		x_mv[i] = 0.03 + Math.random()/10;
		snow[i]=document.getElementById("s"+i);
		//snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)] 
		//snow[i].size=randommaker(snowsizerange)+snowminsize
		//snow[i].size=parseInt(snow[i].style.zIndex * 10 - Math.random()*10);
		if(snow[i].style.zIndex < 0)
			snow[i].style.zIndex = '2';
		snow[i].size=String(((parseInt(snow[i].style.zIndex-2)*15) +Math.random()*15));
		if(snow[i].size > 100)
			snow[i].size = String(snow[i].size * 0.1); // prevent the anomalous vast smowflakes
		//alert(snow[i].size);
		//snow[i].style.fontSize=snow[i].size + 'px';
		snow[i].style.width=snow[i].size + 'px';
		snow[i].style.height=snow[i].size + 'px';
		snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
		snow[i].sink=sinkspeed*snow[i].size/15;
		snow[i].posx=randommaker((300)-snow[i].size); 
		snow[i].posy= randommaker(250-snow[i].size)-50;
		snow[i].style.left=snow[i].posx + 'px';
		snow[i].style.top=snow[i].posy + 'px';
		lftrght[i] = Math.random()*10+snow[i].size/2;
		if(snow[i].size > 10)
		{ snowflake.style.zIndex = '10'; }
		else { snowflake.style.zIndex = '-10'; }
	}
	movesnow();
}

function movesnow() {
	for (i=0;i<=snowmax;i++) 
	{
		// make these local to reduce DOM calls
		var tempsize;
		var posx = snow[i].posx;
		var posy = snow[i].posy;
		var sink = snow[i].sink;
		var size = snow[i].size;
		var crdsi = crds[i]; 
		crdsi += x_mv[i] % 1;
		posy += sink;
		if (posy>=150) {
			posx=randommaker(300-size) 
			posy=-50;
		}
		snow[i].style.left=posx+lftrght[i]*Math.sin(crdsi) + 'px'; 
		snow[i].style.top = posy + 'px';
		snow[i].posx = posx;
		snow[i].posy = posy;
		// vary the size a bit too		
		tempsize = Math.round(parseInt(size) + ((parseInt(size) / 4) * Math.cos(crdsi))); 
		snow[i].style.width=tempsize + 'px';
		snow[i].style.height=tempsize + 'px'; 
		crds[i] = crdsi; 
	}
	var timer=setTimeout("movesnow()",50)
	//alert("moving");
}
//if (browserok) { window.onload=initsnow;}
initsnow();