var przesX = 20;
var przesY = 10;

function otworz(url, ramka, szer, wys) {

	przesX += 40;
	przesY += 20;
	if (przesX > 300) {
		przesX = 20;
		przesY = 10;
	}

	okno = window.open(url, ramka, 'left=' + przesX + ',top=' + przesY + ',width='+szer+',height='+wys+',innerheight='+wys+',innerwidth='+szer+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	okno.focus();

	return okno;
}

var pw = 0;

function otworzObrazek(nazwa, podpis)
{
	t = screen.height/2 - 200; l = screen.width/2 -250;

	if (podpis==undefined || podpis == '') {
		podpis = 'oferty.net';
		podpis_pod = '';
		hplus = 55;
		wplus = 55;
	} else {
		hplus = 100;
		wplus = 55;
		podpis_pod = '<div style="text-align:center;" class="tekst"><p>'+podpis+'</p></div>';
	}
	
	if(!document.all) hplus+=30;

    try {
    	if (pw!=0) pw.close();	
    } catch (ex) {
    }
	
    pw = window.open('about:blank','zdjecie','top='+t+',left='+l+',width=500,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
    d = pw.document;
    d.write('<html><head><title>'+podpis+'</title><link rel="stylesheet" type="text/css" href="/img/style.css" /><sc'+'ript type="text/javascript">'
    	   +'function adjust() {i=document.getElementById(\'mim\'); if (i.height>screen.height-80) {h=screen.height-80} else {h=i.height+'+hplus+'}; '
    	   +'if (i.width>screen.width-80) {w=screen.width-80} else {w=i.width+'+wplus+'}'
    	   +'resizeTo(w,h); moveTo(screen.width / 2 - w/2,screen.height/2 - h/2) }</scr'+'ipt></head>'
    	   +'<body onload="adjust()" style="margin:10px;text-align:center;cursor:pointer;">'
    	   +'<img id="mim" src="'+nazwa+'" border="0" onclick="window.close()" />'+podpis_pod+'</body></html>');
    d.close();
    pw.focus();

}

function otworzWNowymOknie(lokacja) {
    w = 800;
    h = 600;
    popW = 1000;
    popH = 700;
    if (screen.availWidth != 0) {
        w = screen.availWidth;
        h = screen.availHeight;
    }

    topPos = (h-popH)/2;
    leftPos = (w-popW)/2;
    if (topPos < 0) {
        topPos = 0;
    }
    if (leftPos < 0) {
        leftPos = 0;
    }
    
    opcje = 'top='+topPos+',left='+leftPos+',width='+popW+',height='+popH;
    opcje += ',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes'; 
    
    okno = window.open(lokacja,null,opcje);
    okno.focus();
    return false;
}
