/*
 *
 * Autor: kt
 * Insirowane przez:
 * Document firework script (By Kurt Gregg, kurt.grigg@virgin.net)
 *
 */
Clrs=new Array('d00','0d0','00d','dd0','d0d','0dd','d90')
border=new Array('f88','8f8','88f','ff8','f8f','8ff','fc5')
Xpos=128;
initialStarColor='0f0';
step=5;
currStep=0;
explosionSize=75;
amount=15;

function fireworks()
{
	var fajerwerk;
	var wielkoscPixela;
	var kolor;
	for (i=0; i<amount; i++)
	{
		fajerwerk=document.getElementById('s'+i).style;
		if (currStep < 101)
		{
			fajerwerk.left= Xpos + parseInt(explosionSize*Math.sin(currStep/105)*Math.cos(360/amount*i*3.1415/180))+'px';
			fajerwerk.top = parseInt(explosionSize*Math.sin(currStep/105)*Math.sin(360/amount*i*3.1415/180))+'px';
			fajerwerk.opacity=1;
			fajerwerk.background='#'+initialStarColor;
		}
		else
		{
			fajerwerk.left= Xpos + parseInt(explosionSize*Math.sin(currStep/105)*Math.cos(360/amount*i*3.1415/180))-Math.round(Math.random()*2)+'px';
			fajerwerk.top = parseInt(explosionSize*Math.sin(currStep/105)*Math.sin(360/amount*i*3.1415/180))-Math.round(Math.random()*2)+'px';
			wielkoscPixela=Math.round(Math.random()*3);
			kolor = Math.round(Math.random()*6);
			fajerwerk.background='#'+Clrs[kolor];
			fajerwerk.border='1px solid #'+border[kolor];
			fajerwerk.width=wielkoscPixela+'px';
			fajerwerk.height=wielkoscPixela+'px';
			fajerwerk.opacity=currStep<175?1:(1000-(currStep*4))/300;
		}
	}
	if (currStep >= 250)
	{
		currStep=0;
		initialStarColor=Clrs[Math.round(Math.random()*6)];
		for (i=0; i<amount; i++)
		{
			fajerwerk=document.getElementById('s'+i).style;
			fajerwerk.opacity=0;
			fajerwerk.width='1px';
			fajerwerk.height='1px';
		}
		Xpos=Math.round(Math.random()*600)+150;
		return;
	}
	currStep+=step;
}

function init()
{
	var f = document.createElement('div');
	f.setAttribute('id', 'f');
	document.body.appendChild(f);
	f=document.getElementById('f');
	for (var i=0; i<amount; i++)
	{
		div = document.createElement("div");
		div.setAttribute('id', 's'+i);
		f.appendChild(div);

		div=document.getElementById('s'+i).style;
		div.position='absolute';
		div.top='0px';
		div.left='0px';
		div.width='1px';
		div.height='1px';
		div.background='#fff';
		div.fontSize='1px';
		kolor = Math.round(Math.random()*6);
		div.background='#'+Clrs[kolor];
		div.border='1px solid #'+border[kolor];
		div.width='1px';
		div.height='1px';
	}
	f.style.position='absolute';
	f.style.top='170px';
	f.style.left=parseInt(self.innerWidth?self.innerWidth:(document.documentElement.clientWidth?document.documentElement.clientWidth:(document.body.clientWidth?document.body.clientWidth:'1000')))/2-400+'px';
	setInterval('fireworks()', 25);
}
