 var procesy = new Array();
 var pasekProcesowStan = false;
 
 setInterval("czysc_procesy();", 1000);
 
 function Proces(nazwa){
	this.id = Math.floor(Math.random()*999999999);
	this.nazwa = nazwa;
	this.stan = true;
 }
 
 function odswiez_procesy(){
	if(pasekProcesowStan){
		pokaz_procesy();
	}
 }
 
 function dodaj_proces(proc){
	procesy.push(proc);
	odswiez_procesy();
 }
 
 function usun_proces(proc){
	for(var i in procesy){
		if(procesy[i].id == proc.id){
			procesy[i].stan = false;
		}
	}
 }
 
 function czysc_procesy(){
	for(var i in procesy){
		if(procesy[i].stan == false){
			var tmp = procesy[0];
			procesy[0] = procesy[i];
			procesy[i] = tmp;
			procesy.shift();
		}
	}
	
	odswiez_procesy();
 }
 
 function pasek_procesu_init(){
	var bar = document.getElementById("progres_bar");
	var winH = getHeight();
	var winW = getWidth();
	const HEIGHT = 25;
	bar.style.display = "";
	bar.style.width = winW-195-11+"px";
	bar.style.height = HEIGHT+"px";
	bar.style.top = winH-HEIGHT-11+"px";
 }
 
 function ustaw_pasek_postepu(){
	pasek_procesu_init();
	var bar = document.getElementById("progres_bar");
	bar.onclick = function(){
		if(pasekProcesowStan == false){
			pasekProcesowStan = true;
			pokaz_procesy();
		}else{
			pasekProcesowStan = false;
			ukryj_procesy();
		}
	}
 }
 
 function pokaz_procesy(){
	var bar = document.getElementById("progres_bar");
	var winH = getHeight();
	var winW = getWidth();
	
	const HEIGHT = 25;
	const RHEIGHT = 26;
	
	var h = HEIGHT;
	
	for(var i=bar.childNodes.length; i>1; i--){
		bar.removeChild(bar.childNodes[i-1]);
	}
	for(var i in procesy){
		var row = document.createElement("div");
		row.appendChild(document.createTextNode(procesy[i].nazwa));
		bar.appendChild(row);
		h += RHEIGHT;
	}
	
	bar.style.width = winW-195-11+"px";
	bar.style.height = h+"px";
	bar.style.top = winH-h-11+"px";
 }
 
 function ukryj_procesy(){
	var bar = document.getElementById("progres_bar");
	for(var i=bar.childNodes.length; i>1; i--){
		bar.removeChild(bar.childNodes[i-1]);
	}
	pasek_procesu_init();
 }