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 upewnij2 () 
{
    return confirm ("Czy jesteś pewny/a?")
}

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) {
        document.getElementById(warstwa).style.display = "none";
    }
    
function pokazWarstwe(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 przeliczcene(pole,ilosc,cena)
{
	document.getElementById(pole).innerHTML=String((parseFloat(cena)*parseInt(ilosc)).toFixed(2))+"";
}

function typszukania(rodzaj)
{
	if (rodzaj==0) {
		document.getElementById('searchform').action='index.php?pg=search2'
		document.getElementById('producentselectdiv').style.display='block'
		document.getElementById('producentselect').disabled=false
	}
	else {
		document.getElementById('searchform').action='index.php?pg=search'
		document.getElementById('producentselect').disabled=true
		document.getElementById('producentselectdiv').style.display='none'
	}
}
