howmany = 80
howbig = 50
colors = new Array('yellow','orange','blue','white','red','lightgreen');
fsize = new Array('12pt','10pt','6pt','8pt');

function spark(div) {
	this.css = document.getElementById(div).style;
	this.show = function() { this.css.visibility="visible"; }
	this.hide = function() { this.css.visibility="hidden"; }
	this.moveTo = function(x,y) { this.x=x; this.y=y; this.css.left=x; this.css.top=y; }
	this.fcolor = function(col) {this.css.color=col; }
	return this;
}

function init_sparks() {
	for (i=0; i<sparks.length; i++) {
		sparks[i].show();
		sparks[i].inc = (Math.random()*5);
		sparks[i].ang = (Math.random()*360);
	}
	center_x = event.clientX+document.body.scrollLeft;
	center_y = event.clientY+document.body.scrollTop;
	counter = 0;
	doExplode();
}

function doExplode() {
	if (counter < howbig) {
		counter++;
		for (i=0; i<sparks.length; i++) {
			x = center_x + (counter*sparks[i].inc) * Math.sin(sparks[i].ang * Math.PI/180);
			y = center_y + (counter*sparks[i].inc) * Math.cos(sparks[i].ang * Math.PI/180);
			sparks[i].moveTo(x,y);
		}
		fade(howmany-1);
		tmr1=setTimeout('doExplode()',50);
	}else{
		clearTimeout(tmr1);
	}
}

function fade(n) {
	if (n>=0) {
		sparks[n].hide();
		n--;
		tmr2=setTimeout("fade("+n+")",1);
	} else {
		clearTimeout(tmr2);
	}
}

sparks = new Array();
for (i=0; i<howmany; i++) {
	num = Math.round(Math.random()*(fsize.length-1))
	fs = fsize[num];
	document.write('<div id="spark'+i+'" style="position: absolute; font-size: '+fs+';">*</div>');
	sparks[i] = new spark('spark'+i);
	sparks[i].hide();
	num = Math.round(Math.random()*(colors.length-1))
	col = colors[num];
	sparks[i].fcolor(col);
}
