NAV=navigator.appName;
//alert(NAV);
max_h=300;
min_h=0;
READY=0;
LENGTH=0;
u_width=screen.availWidth;



if(NAV=='Microsoft Internet Explorer')
{
u_width-=36;
}

else
{
u_width-=40;
}

//u_width-=50;
//alert(u_width);
INC=15;



function count_flakes()
{
	f_count_w=Math.round(u_width/45);
	f_count_h=5;
	
	generate(f_count_w,f_count_h);
}

function generate(f_count_w,f_count_h)
{
	var node=null;
	var index=null;
	var w=null;
	for(i=0;i<f_count_w;i++)
	{
	node=document.createElement("img");
	node.setAttribute('src','snowflake.gif');
	index=80+i;
	node.style.zIndex=index;
	node.style.position='absolute';
	
	w=Math.floor(Math.random()*u_width);
	
	if(w>(u_width-12))
	{
	//w=Math.abs(Math.floor(Math.random()*u_width-(Math.random()*10)));
	//w=Math.abs((u_width-100)-(Math.random()*100));
	
	w=Math.abs(Math.floor((u_width-100)-(Math.random()*300)));
	
	//alert("dépassement d'écran");
	}	
	node.style.left=w+'px';
	//alert("l="+node.style.Left)
	var h=Math.floor(Math.random()*max_h+i);
	if(h<min_h)
	{
	h=min_h+1;
	}
	node.style.top=h+'px';
	TARGET.appendChild(node);
	//alert('creation obj n'+i);
	}
	
	f_count_h--;
	//alert('f_count_h='+f_count_h);
	(f_count_h!=0)? generate(f_count_w,f_count_h) : snow_fall();
}

function snow_fall()
{
	var w=null;
	var h=0;
	var t=null;
	var nl=null;
	if(READY==0)
	{
	ALL=TARGET.getElementsByTagName('img');
	READY=1;
	LENGTH=ALL.length;
	}
	
	for(i=0;i!=LENGTH;i++)
	{
	t=Math.round(Math.random());
	
	nl=ALL[i].offsetLeft;
	
	(t==0)? w=nl-INC : w=nl+INC;
	
	if(w>u_width)
	{
	//w=u_width-45;
	w=Math.abs(Math.floor(Math.random()*u_width));
	}
	
	h=ALL[i].offsetTop+Math.floor(Math.random()*INC)+1;
	
	if(h>max_h)
	{
	h=min_h+1;
	//alert('retour a zero');
	}
	ALL[i].style.top=h+'px';
	ALL[i].style.left=w+'px';
	}
	
	
	//setTimeout('snow_fall()',10);//FF
	setTimeout('snow_fall()',400);//100 pour ie
}