var id = 30;
var kohtax = new Array();
var kohtay = new Array();
var nopeusx = new Array();
var nopeusy = new Array();

function alusta() {
	for(i = id; i >= 1; i--) {
		kohtax[i] = Math.random() * screen.width;
		kohtay[i] = Math.random() * screen.height;

		nopeusx[i] = Math.random() * 2 - 1;
		nopeusy[i] = Math.random() + 1;
		
		document.images['lumi' + i].style.left = kohtax[i] + "px";
		document.images['lumi' + i].style.top = kohtay[i] + "px";
	}

	sadetta();
}

function sadetta() {
	for(i = id; i >= 1; i--) {
		nopeusx[i] = nopeusx[i] + Math.random() * 0.1 - 0.05;
		nopeusy[i] = nopeusy[i] + Math.random() * 0.1 - 0.05;

		if(nopeusx[i] > 1) nopeusx[i] = 1;
		if(nopeusx[i] < -1) nopeusx[i] = -1;
		if(nopeusy[i] > 2) nopeusy[i] = 2;
		if(nopeusy[i] < 1) nopeusy[i] = 1;

		kohtax[i] = kohtax[i] + nopeusx[i];
		kohtay[i] = kohtay[i] + nopeusy[i];

		if(kohtax[i] > screen.width) kohtax[i] = -15;
		if(kohtax[i] < -15) kohtax[i] = screen.width;
		if(kohtay[i] > screen.height) kohtay[i] = -15;

		document.images['lumi' + i].style.left = kohtax[i] + "px";
		document.images['lumi' + i].style.top = kohtay[i] + "px";
	}

	setTimeout(sadetta, 10);
}
