function okno (sciezka, szer, wys, scroll, other) 
{
    lewopx=Math.round((screen.width-szer)/2)
    gorapx=Math.round((screen.height-wys)/2)
    if(scroll==1){
		wind=window.open (sciezka,'','scrollbars=yes,left='+lewopx+',top='+gorapx+',width='+szer+',height='+wys+', toolbar=0'+other)
    }else{
		wind=window.open (sciezka,'','left='+lewopx+',top='+gorapx+',width='+szer+',height='+wys+', toolbar=0'+other)
    }
    
	//wind.onclick = wclose
	//wind.onblur = wclose

}

function przegladarka (szer, wys,idparent,idobr) {
//	lewo=Math.round((screen.width-szer)/2)
//    gora=Math.round((screen.height-wys)/2)
    
//    szer = szer + 50
//    wys = wys + 50
    sciezka = 'przegladarka.php?idparent='+idparent+'&idobr='+idobr
    
    wind=window.open (sciezka,'','fullscreen=1, toolbar=0, resizable=1, scrollbars=1')
//    wind=window.open (sciezka,'','left='+lewo+',top='+gora+',width='+szer+',height='+wys+', toolbar=0')
}

function wclose()
{
	this.window.close()
}

function upewnij () 
{
    return confirm ("Czy jesteś pewny/a? \nTa operacja jest nieodwracalna!")
}

function upewnijc (txt) 
{
    return confirm ("Czy jesteś pewny/a?"+txt)
}

function sprawdzform (form, wymagane) 
{
    var poprawny = true
    
    for (i=0;i<wymagane.length;i++) {
        if (document.forms[form].elements[wymagane[i]].value == '') {
            document.forms[form].elements[wymagane[i]].style.borderColor = "#FF0000"
            poprawny = false
        }
        else
            document.forms[form].elements[wymagane[i]].style.borderColor = "#666666"
    }

    if (poprawny == false) {
        alert ("Uzupełnij wszystkie zaznaczone pola")
        return false
    }
    else 
        return true
}

function schowajWarstwe(warstwa) {
        if (document.getElementById(warstwa))
        document.getElementById(warstwa).style.display = "none";
    }
    
function pokazWarstwe(warstwa) {
        if (document.getElementById(warstwa))
        document.getElementById(warstwa).style.display = "block";
    }
    
function chkboxtoggle(itemid)
{
	itm=document.getElementById(itemid)
	if (!itm)
		return
	if (itm.checked==true)
		itm.checked=false
	else
		itm.checked=true
} 

function showonoff(idek,disp)
{
	if (!disp)
		disp='block'
	elem=document.getElementById(idek)
	if (!elem) return
	if (elem.style.display=='none')
		elem.style.display=disp
	else
		elem.style.display='none'
}

function cleanInput(idek,tekst)
{
	pole=document.getElementById(idek)
	if (!pole) return
	if (pole.value==tekst) pole.value=''
}

	//zabezpieczenie botowe
$(document).ready(function() {
	pole_email_val=$('.pole_email').val();
	$('form.safe').submit(function() {
		$(this).attr('action',$(this).attr('action')+'&safe=1');
	});
	$('.pole_email').bind('focus',
	function () {
		if ($(this).val()==pole_email_val) $(this).val('');
	}
	);
	$('.pole_email').bind('blur',
	function () {
		if ($(this).val()=='') $(this).val(pole_email_val);
	}
	);
	$('#boxtitledotacje').click(function() {$('#menudotacje').toggle();$('#menudotacjeinfo').toggle();});
	$('#menudotacjeinfo').click(function() {$('#menudotacjeinfo').hide();$('#menudotacje').show()});
	$('#boxtitlesprawozdanie').click(function() {$('#menusprawozdanie').toggle();$('#menusprawozdanieinfo').toggle()});
	$('#menusprawozdanieinfo').click(function() {$('#menusprawozdanieinfo').hide();$('#menusprawozdanie').show()});
	$('#boxtitlepozyczki').click(function() {$('#menupozyczki').toggle();$('#menupozyczkiinfo').toggle()});
	$('#menupozyczkiinfo').click(function() {$('#menupozyczkiinfo').hide();$('#menupozyczki').show()});
	$('#boxtitlerifdzialania').click(function() {$('#menurifdzialania').toggle();$('#menurifdzialaniainfo').toggle()});
	$('#menurifdzialaniainfo').click(function() {$('#menurifdzialaniainfo').hide();$('#menurifdzialania').show()});
	$('#boxtitlerif').click(function() {$('#menurif').toggle();$('#menurifinfo').toggle()});
	$('#menurifinfo').click(function() {$('#menurifinfo').hide();$('#menurif').show()});
}
);
