// wyświetlanie słownika
	function slownik() {
		dict = window.open("/slowniczek.html", "slowniczek", "width=300, height=410, top=60, left=600, resizable=0, scrollbars=1");
	}

// wyświetlanie kalendarza
	function opencalendar(sid, dzien, pole) {
		window.open("?sid="+sid+"&ctr=kalendarz&dzien="+dzien+"&field="+pole, "kalendarz", "width=280, height=230, top=60, left=600, resizable=1, scrollbars=1");
	}

// sprawdzanie loginu nowo wprowadzanego użytkownika
	function checkLogin(sid,login) {
		 var left = parseInt(screen.width/2);
		 var top = parseInt(screen.height/2);
		window.open('?sid="+sid+"&ctr=przelicznik&trg=Login&id='+login, 'przelicznik', 'width=10, height=10, top='+top+', left='+left+', resizable=0, scrollbars=0');
	}	


// sprawdzanie czy wartość pola edycyjnego jest liczbą
 function _checkLiczba(wartosc, nazwapola) {
		var str = wartosc;
		var wynik;
				
       //	zamiana przecinków na kropki
        str = str.replace(/,/g, '.');
       //	usunięcie nie cyfr i nie kropek
        str = str.replace(/[^\d\.]/g, '');

							// usuniecie kropki jeżeli jest ostatnim znakiem
       	if (str.lastIndexOf('.') == str.length-1) {
        	str = str.substr(0,str.length-1);
        }
							// poprawienie za dużej ilości kropek
        if (str.lastIndexOf('.') != str.indexOf('.')) {
        	alert('Zła wartość pola \"'+nazwapola+'\" !');
        	var pozycja = str.lastIndexOf('.');
        	var lewy = str.substr(0,pozycja);
        	var prawy = str.substr(pozycja,str.length-lewy.length);
        	while (lewy.indexOf('.') != -1) {
        		ab = lewy.substr(0,lewy.indexOf('.'));
        		bc = lewy.substr(lewy.indexOf('.')+1,lewy.length - ab.length);
        		lewy = ab + bc;
        	}
        	wynik = lewy + prawy;
        } else {
        	wynik = str;
        }
        return wynik;
 }        

 function checkLiczba(element) {
  	var str = _checkLiczba(element.value, element.name);
 	 element.value=str;
 }

// sprawdzanie, czy wartość pola jest procentem
 function checkProcent(element) {
 	var str = _checkLiczba(element.value, element.name);
		if (str>100) {
					alert('Wartość pola \"'+element.name+'\" przekroczyła 100% !');
 				str=100;
 	}
 	element.value=str;
 }
	
// sprawdzenie czy wartość pola edycyjnego jest godziną
	function checkGodzina(element) {
        var str = element.value;
		var lista = new Array(2);
		
        //	usunięcie nie cyfr i nie dwukropków
        str = str.replace(/[^\d\:]/g, '');

		if (str.length>0) {
			// stworzenie listy składającej się z godziny i minuty

			lista = str.split(':',2);

			
			if (lista[0]>23) {
				lista[0] = 0;
			}

			if 	(lista.length>1) {
				if (lista[1]>59) {
					lista[1]="0";
				}
				if (lista[1]<10) {
					lista[1] = "0"+lista[1];
				}
			} else {
				lista[1] = "00";
			}    
	        
	        element.value = lista[0]+':'+lista[1];

	        
		} else {
			element.value = '';
		}
	}
	
	function chckVsbl(elID) {
		el = document.getElementById(elID);
		hidd_el = document.getElementById('hidd_'+elID);
		if ((el != undefined) && (hidd_el != undefined)) {
			if (el.innerHTML != '' ) {
				el.innerHTML = '';
				profilvis = 0;
			} else {
				el.innerHTML = hidd_el.value;
				profilvis = 1;
			}
		}		
	}
	
