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

}

var zajete=0;
var czasajax=6000;

function przegladarka (szer, wys,idparent,idobr) {

	if (zajete) return;
	zajete=1;
	$('#fotozoom').hide();
	$('#fotozoom img').attr('src',' ');
	$('#fotozoom').width(szer);
	$('#fotozoom').height(wys);
	$('#fotozoom').css('position','absolute');
	$('#fotozoom').css('z-index','100');
	$('#fotozoom').css('left',Math.ceil(($(window).width()-szer)/2)+'px');
	odtopu=Math.ceil(($(window).height()-wys)/2)+$(window).scrollTop();
	if (odtopu<10) odtopu=10;
	$('#fotozoom').css('top',odtopu+'px');
	$.ajax({
		url: 'ajax/obr.php',
		type: 'GET',
		dataType: 'html',
		async: false,
		timeout: czasajax,
		data: 'idobr='+idobr,
		error: function() {
			zajete=0;
		},
		success: function(wynik) {
			zajete=0;
			if (wynik=='/**/') {
			} else {
				$('#fotozoom img').attr('src',wynik);
				$('#fotozoom').fadeIn('slow');
			}
		}
	})	
	return false;

}

function przegladarka2 (szer, wys,idparent,idobr) {
	if (zajete) return;
	zajete=1;
	$('#fotozoom').hide();
	$('#fotozoom img').attr('src',' ');
	$('#fotozoom').width(szer);
	$('#fotozoom').height(wys);
	$('#fotozoom').css('position','absolute');
	$('#fotozoom').css('z-index','100');
	$('#fotozoom').css('left',Math.ceil(($(window).width()-szer)/2)+'px');
	odtopu=Math.ceil(($(window).height()-wys)/2)+$(window).scrollTop();
	if (odtopu<10) odtopu=10;
	$('#fotozoom').css('top',odtopu+'px');
	$.ajax({
		url: 'ajax/obr2.php',
		type: 'GET',
		dataType: 'html',
		async: false,
		timeout: czasajax,
		data: 'idobr='+idobr,
		error: function() {
			zajete=0;
		},
		success: function(wynik) {
			zajete=0;
			if (wynik=='/**/') {
			} else {
				$('#fotozoom img').attr('src',wynik);
				$('#fotozoom').fadeIn('slow');
			}
		}
	})	
	return false;
}

function przegladarka3 (szer, wys,idparent,idobr) {
	if (zajete) return;
	zajete=1;
	$('#fotozoom').hide();
	$('#fotozoom img').attr('src',' ');
	$('#fotozoom').width(szer);
	$('#fotozoom').height(wys);
	$('#fotozoom').css('position','absolute');
	$('#fotozoom').css('z-index','100');
	$('#fotozoom').css('left',Math.ceil(($(window).width()-szer)/2)+'px');
	odtopu=Math.ceil(($(window).height()-wys)/2)+$(window).scrollTop();
	if (odtopu<10) odtopu=10;
	$('#fotozoom').css('top',odtopu+'px');
	zajete=0;
	$('#fotozoom img').attr('src','gfx/d_galeria'+idobr+'.jpg');
	$('#fotozoom').fadeIn('slow');
	return false;
}

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=''
}
	
$(document).ready(function() {
	if ($('form.safe'))
	$('form.safe').submit(function() {
		$(this).attr('action',$(this).attr('action')+'&safe=1');
	});
	$('#fotozoom').click(function(){
		$('#fotozoom').fadeOut('slow',function(){$('#fotozoom img').attr('src','');});
	});
	
	$('a.nowhere').click(function(){return false});
	
});


$(document).ready(function() {
	$('#leftmenu ul > li').hover(function() {
		if (obj) {
			obj.find('ul:first').hide();
			obj = null;
		} 
		
		$(this).find('ul:first').show();//.css('z-index',200);
	}, function() {
		obj = $(this);
		setTimeout(
			"checkHover()",
			1);
	});
});		


var obj = null;

function checkHover() {
	if (obj) {
		obj.find('ul').hide();	
	}
}
