<!-- präsentiert von kostenlose-javascripts.de -->

	var Amount;          // Anzahl der Konfettis
	var spd;    		 // beeinflusst Fallgeschwindigkeit 
	var duration;		 // Dauer eines Konfettiwurfs (ein negativer Wert bedeutet: unendlich)
	
	var durationCounter;

	var stop = false;

	colors=new Array(5)
	colors[0]="red";
	colors[1]="green";
	colors[2]="yellow";
	colors[3]="magenta";
	colors[4]="blue";

	Ypos=new Array();
	Xpos=new Array();
	Speed=new Array();
	Step=new Array();
	Cstep=new Array();

	function initKonfetti(amt, speed, dur) {
		Amount = amt;
		spd = speed;
		duration = dur;
		durationCounter = duration;
		document.write('<div style="position:absolute;top:0px;left:0px;visibility:hidden;" id="konfetti"><div style="position:relative">');
		for (i = 0; i < Amount; i++){
			var P=Math.floor(Math.random()*colors.length);
			rndCol=colors[P];
			document.write('<span style="position:absolute;top:0px;left:0px;color:' + rndCol + ';line-height:1em;font-size:72px;font-family: \'Times New Roman\', Times, serif;" id="si'+i+'">.</span>');
		}
		document.write('</div></div>');

		WinHeight=window.document.body.clientHeight;
		WinWidth=window.document.body.clientWidth;
		for (i=0; i < Amount; i++){
			Ypos[i] = Math.round(Math.random()*WinHeight);
			Xpos[i] = Math.round(Math.random()*WinWidth);
			Speed[i]= Math.random()*3+spd;
			Cstep[i]=0;
			Step[i]=Math.random()*0.1+0.05;
		}
	}
	
	
	function fall(){
		// a negative value of durationCounter means: loop infinitely
		if (durationCounter > 0) {
			durationCounter--;
		}
		if (durationCounter == 0) {
			setVisibility("hidden");
			stop = true;
			durationCounter = duration;
			return;
		}
		
		var WinHeight=window.document.body.clientHeight;
		var WinWidth=window.document.body.clientWidth;
		var hscrll=document.body.scrollTop;
		var wscrll=document.body.scrollLeft;
		for (i=0; i < Amount; i++){
			sy = Math.floor(Speed[i]*Math.sin(90*Math.PI/180));
			sx = Math.floor(Speed[i]*Math.cos(Cstep[i]));
			Ypos[i]+=sy;
			Xpos[i]+=sx;
			if (Ypos[i] > WinHeight-80){
				Ypos[i]=-60;
				Xpos[i]=Math.round(Math.random()*WinWidth);
				Speed[i]=Math.random()*5+spd;
			}
			Xpos[i] = (Xpos[i] > WinWidth-30)?WinWidth-30:Xpos[i];
			
			var newXValue = Xpos[i]+"px";
			var newYValue = Ypos[i]+hscrll+"px";
			document.getElementById('si'+i).style.left=newXValue;
			document.getElementById('si'+i).style.top=newYValue;

			Cstep[i]+=Step[i];
			
		}
		
		if (!stop) {
			setTimeout('fall()',40);
		}
	}

	function setVisibility(visibility) {
		document.getElementById('konfetti').style.visibility = visibility;
	}

