function showalert(alertmess){
	
		humanMsg.displayMsg('<strong>Uwaga:</strong><br><span class="indent">'+alertmess+'</span>');	
	
	}
function validateform(form,type){

	if ( type == 'wojewodztwa' ){
	
		if ( form.nazwa.value == '' ){ showalert("Podaj nazwę województwa"); return false; }
				
	}
	
	return true;
	
}

function strlen (string) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Sakimori
    // +      input by: Kirk Strobeck
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +    revised by: Brett Zamir (http://brett-zamir.me)
    // %        note 1: May look like overkill, but in order to be truly faithful to handling all Unicode
    // %        note 1: characters and to this function in PHP which does not count the number of bytes
    // %        note 1: but counts the number of characters, something like this is really necessary.
    // *     example 1: strlen('Kevin van Zonneveld');
    // *     returns 1: 19
    // *     example 2: strlen('A\ud87e\udc04Z');
    // *     returns 2: 3
 
    var str = string+'';
    var i = 0, chr = '', lgth = 0;
 
    var getWholeChar = function (str, i) {
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str.charAt(i)+str.charAt(i+1);
        } else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev = str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
        }
        return str.charAt(i);
    };
 
    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } // Adapt this line at the top of any loop, passing in the whole string and the current iteration and returning a variable to represent the individual character; purpose is to treat the first part of a surrogate pair as the whole character and then ignore the second part
        lgth++;
    }
    return lgth;
}

function checklogin(form){


	if ( form.login.value == '' || form.login.value == 'Podaj swój identyfikator' ){
		humanMsg.displayMsg('<strong>Uwaga:</strong><br><span class="indent">Podane przez Ciebie informacje są nieprawidłowe. Wpisz je ponownie i spróbuj	zalogować sie do systemu. Jeżeli to nie pomoże skontaktuj się z obsługą systemu</span>');
		return false;
		
	}
	
	humanMsg.displayMsg('<strong>Sprawdzam:</strong><br><span class="indent">Sprawdzam czy dane istnieją w naszej bazie danych</span>');	
	
	$.post("xhtml/ajax/testlogindetails.php", { login: form.login.value, pass: form.pass.value }, function(data){
																										   
	if ( strlen(data) == 4 ){ form.submit(); return true; }else{ humanMsg.displayMsg('<strong>Uwaga:</strong><br><span class="indent">Podane przez Ciebie dane logowania nie istnieją w naszym systemie. Spróbuj ponownie lub skontaktuj się z administratorem systemu</span>'); return false;	
	}
  });

return false;	
}

function alertpotwierdz(site){
jQuery('#content').fadeTo("fast",0.33);
jQuery('#alertbox').load('xhtml/ajax/confirm.php?page='+site);
jQuery('#alertbox').toggle("fast");
	
}
function alertpotwierdzkomunikat(komunikat){
jQuery('#content').fadeTo("fast",0.33);
jQuery('#alertbox').load('xhtml/ajax/karta.php?komunikat='+komunikat);
jQuery('#alertbox').toggle("fast");
	
}
function alertkarta(karta){
jQuery('#content').fadeTo("fast",0.33);
jQuery('#alertbox').load('xhtml/skaner/karta.php?karta='+karta);
jQuery('#alertbox').toggle("fast");
	
}
function alertkartainfo(karta){
jQuery('#content').fadeTo("fast",0.33);
jQuery('#alertbox').load('xhtml/skaner/kartapracownik.php?karta='+karta);
jQuery('#alertbox').toggle("fast");
	
}
function loadsubpage(karta,page){
	document.getElementById('kcontent').innerHTML  = '<br><br><img src="http://blacklot.pl/strony/bajkolandia/_img/loader.gif">';
jQuery('#kcontent').load(page+'?karta='+karta);
document.getElementById('debug').innerHTML = '0';	
document.getElementById('debug2').innerHTML = '0'
document.getElementById('debug3').innerHTML = '0'
	
}
function loadsubpageaddr(page){
	document.getElementById('kcontent').innerHTML  = '<br><br><img src="http://blacklot.pl/strony/bajkolandia/_img/loader.gif">';
jQuery('#kcontent').load(page);
document.getElementById('debug').innerHTML = '0';	
document.getElementById('debug2').innerHTML = '0'
document.getElementById('debug3').innerHTML = '0'
	
}
function loadsubpageaddr2(page){
	document.getElementById('alertbox').innerHTML  = '<center><h2>Proszę czekać</h2><br><img src="http://blacklot.pl/strony/bajkolandia/_img/loader.gif"></center>';
jQuery('#alertbox').load(page);
document.getElementById('debug').innerHTML = '0';	
document.getElementById('debug2').innerHTML = '0'
document.getElementById('debug3').innerHTML = '0'
	
}
function loadsubpageaddralert(page){
jQuery('#content').fadeTo("fast",0.33);
jQuery('#alertbox').load(page);
jQuery('#alertbox').toggle("fast");
document.getElementById('debug').innerHTML = '0';	
document.getElementById('debug2').innerHTML = '0'
document.getElementById('debug3').innerHTML = '0'
	
}
function loadsubpageaddrconfirm(page){
if ( confirm("Czy napewno chcesz to zrobić") ){
document.getElementById('kcontent').innerHTML  = '<center><h2>Proszę czekać</h2><br><img src="http://blacklot.pl/strony/bajkolandia/_img/loader.gif"></center>';
jQuery('#kcontent').load(page);
document.getElementById('debug').innerHTML = '0';	
document.getElementById('debug2').innerHTML = '0'
document.getElementById('debug3').innerHTML = '0'
}
	
}
function przypiskarty(karta,page){
	document.getElementById('kcontent').innerHTML  = '<br><br><img src="http://blacklot.pl/strony/bajkolandia/_img/loader.gif">';
jQuery('#kcontent').load(page+'?karta='+karta);
document.getElementById('debug2').innerHTML = '1';
document.getElementById('debug3').innerHTML = karta;
	
}
function zamknijalert(){
jQuery('#content').fadeTo("fast",1.0);
jQuery('#alertbox').toggle("fast");	
document.getElementById('debug').innerHTML = '0';	
document.getElementById('debug2').innerHTML = '0'
document.getElementById('debug3').innerHTML = '0'
}
function przekieruj(site){

window.location = site;
	
}
function zmien_oddzial(obj){
window.location = 'oddzial,'+obj.options[obj.selectedIndex].value+'.html';
	
}
function definiuj_zajecia(obj){
	
document.getElementById('zajecia').innerHTML = 'Definiuje zajęcia dla użytkownika... Proszę czekać...';
jQuery('#zajecia').load('xhtml/ajax/zajecia_uzytkownik.php?user='+obj.value);
	
}
function checkform(id, form){

if ( id == 1 ){

	if ( form.klient.value == '' ){  showalert('Wypełnij pole klienta'); return false; }
	if ( form.data1.value == '' ){  showalert('Podaj datę wystawienia faktury'); return false; }
	if ( form.data2.value == '' ){  showalert('Podaj datę płatności'); return false; }
	if ( form.oddzial.options[form.oddzial.selectedIndex].value == '' ){  showalert('Wybierz zajęcia za które będzie naliczona faktura'); return false; }	
	if ( form.tytuk.value == '' ){  showalert('Wypełnij pole Tytuł'); return false; }	
	
	
	return true;
}
	
	
}