

function InitSnow( p_BeginSnow, p_area_W, p_area_H, p_area_T, p_area_L) 
{
	snowing=false;
	snowTimeOut_ID=0;
	N = 40; 			//nombre de flocons
	Y = new Array();
	X = new Array();
	S = new Array();
	A = new Array();
	B = new Array();
	M = new Array();
	V = (document.layers)?1:0;
	SPEED = 100;
	
	AREA_H = (p_area_H != null) ? p_area_H : (document.layers)?window.innerHeight:window.document.body.clientHeight;
	AREA_W = (p_area_W != null) ? p_area_W : ((document.layers)?window.innerWidth:window.document.body.clientWidth) / 2.1;
	AREA_T = (p_area_T != null) ? p_area_T : (document.layers)?window.pageYOffset:document.body.scrollTop;
	AREA_L = (p_area_L != null) ? p_area_L : (document.layers)?window.pageXOffset:document.body.scrollLeft;
	
	iH = AREA_H; // le début
	iW = AREA_W; // le début
	
	for (i=0; i < N; i++){                                                                
		Y[i]=Math.round(Math.random()*iH);
		X[i]=Math.round(Math.random()*iW);
		S[i]=Math.round(Math.random()*5+2);
		A[i]=0;
		B[i]=Math.random()*0.1+0.1;
		M[i]=Math.round(Math.random()*1+1);
	}
	
	if (V){
		for (i = 0; i < N; i++){
			document.write("<LAYER NAME='sn"+i+"' LEFT="+AREA_L+" TOP="+AREA_T+" BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"'></LAYER>")
		}
	}
	else{
		document.write('<div style="position:absolute;top:'+AREA_T+'px;left:'+AREA_L+'px">');
		document.write('<div style="position:relative">');
		for (i = 0; i < N; i++) {
// Marche avec Netscape
			document.write('<div id="si' + i + '"' +  'style="position:absolute;top:'+AREA_T+';left:'+AREA_L+';width:'+M[i]+';height:'+M[i]+';background:#fffff0;font-size:'+M[i]+'"></div>')
//			document.write('<div id="si" style="position:absolute;top:'+AREA_T+';left:'+AREA_L+';width:'+M[i]+';height:'+M[i]+';background:#fffff0;font-size:'+M[i]+'"></div>')
		}
		document.write('</div></div>');
	}
	if (p_BeginSnow)snow();
}

function snow(){
			
	var obj = '';		
	var nest = '';
	
	var H = AREA_H
	var W = AREA_W
	var T = AREA_T
	var L = AREA_L
	
	for (i=0; i < N; i++){
		sy=S[i]*Math.sin(90*Math.PI/180);
		sx=S[i]*Math.cos(A[i]);
		Y[i]+=sy;
		X[i]+=sx; 
		if (Y[i] > H){
			Y[i]=-10;
			X[i]=Math.round(Math.random()*W);
			M[i]=Math.round(Math.random()*1+1);
			S[i]=Math.round(Math.random()*5+2);
		}
		if (V){
			document.layers['sn'+i].left=X[i];document.layers['sn'+i].top=Y[i]+T
		}
		else {
			// marche avec Netscape aussi.
			obj = 'si' + i;		
 	 		this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
			this.css.left =X[i];
			this.css.top =Y[i]+T;
			
/*			si[i].style.pixelLeft=X[i];
			si[i].style.pixelTop=Y[i]+T;
*/
		} 
		A[i]+=B[i];
	}
	snowTimeOut_ID= setTimeout('snow()',SPEED);
	snowing=true;
}

function Start_Stop_Snow()
{
	if (snowing) {
		Stop_Snow();
	}
	else {
		snow();
	}
}


function Stop_Snow()
{
	clearTimeout(snowTimeOut_ID);
	snowing=false;
}

