
function otworz_okno(adres, w, h){
F=window.open('','','width='+w+',height='+h);
F.screenX=100;
F.screenY=100;
F.document.open();
F.document.write('<html><head><title>'+adres+'</title></head><body style="margin: 0px; padding: 0px; text-align: center;"><img src="'+adres+'" alt="" style="cursor: pointer;" onclick="window.close();"></body></html>');
F.document.close();
}



function pomoc(tresc){
F=window.open('','', 'width='+300+', height='+120);
F.screenX=100; 
F.screenY=100;
F.document.open();
F.document.write('<html><head><link rel="stylesheet" href="style2.css" type="text/css" /><title>pomoc</title></head><body style="background: #fff; cursor: pointer; height: 100%; text-align: left;" onclick="window.close();"><div style="padding: 10px; height: 120px; overflow: scroll;"'+tresc+'</div></body></html>');
F.document.close();
}

function pokaform(){
      document.getElementById('zadajpytanie').style.display='block';
}

function conf(gdzie, tresc){
	if(window.confirm(tresc)) { 
		window.location.href=gdzie; 
	}
}

function wstaw(myField, myValueStart, myValueEnd) 
{
    
    if (document.selection) 
    {
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValueStart+sel.text+myValueEnd;
    }
    
    else if (myField.selectionStart || myField.selectionStart == 0) 
    {
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        myField.value = myField.value.substring(0, startPos)+ myValueStart+myField.value.substring(startPos,endPos)+myValueEnd+myField.value.substring(endPos, myField.value.length);
    }
    else 
    {
        myField.value += myValue;
    }
}


function dodaj_element(kontener){
	var kont = document.getElementById(kontener);
	if(navigator.userAgent.match(/IE/)) {
		znacznik = 	document.createElement('<input name="plik[]" class="input" type="file" onchange="dodaj_element(\'pliki\');" />');
		kont.appendChild(znacznik);
	} else {
		var znacznik = document.createElement('input');
		znacznik.setAttribute('type', 'file');
		znacznik.setAttribute('name', 'plik[]');
		znacznik.setAttribute('onchange', 'dodaj_element(\'pliki\')');
		znacznik.className = 'input';
		kont.appendChild(znacznik);
	}
}
function schowajzakladki(){
var x = 1;
while(document.getElementById('zakladka'+x) != undefined){
      x++;
      document.getElementById('zakladka'+x).style.display = 'none';
}}

function zmienzakladke(numer) {
      var x = 1;
      while(document.getElementById('zakladka'+x) != undefined){
            document.getElementById('zakladka'+x).style.display = 'none';
            if(x == numer){
                  document.getElementById('zakladka'+x).style.display = 'block';
            }
      x++;
      }
}



//Written by Bogdan Blaszczak/BlaTek
//blatek@25.pl
//original version @ http://js.webhelp.pl/js/prz/blatek/datepicker.html
//Modified by PablO @ 2005
//full desc available @ http://piskorz.info/narzedzia/date-picker
//last update 15-11-2006
function Calendar(T,E,i,j,tE,tBody,Row,f,t,d,wd){if(!document.getElementById||!document.body.appendChild)return
T=this
function cEl(t,p,h,w){p.appendChild(t=document.createElement(t))
if(h)t.innerHTML=h
if(w)t.colSpan=5
return t}
function cB(x){with(T.Cal){B=0;x==0?Y--:x==1?Y++:x==2?(!M?(M=11,Y--):M--):(M==11?(M=0,Y++):M++)}}
if(!T.Cal){E=document.createElement('ins')
E.className='clndr'
T.parentNode.insertBefore(E,T.nextSibling)
T.Cal={E:E,B:1,cM:new Date().getMonth(),cD:new Date().getUTCDate(),cY:new Date().getFullYear(),sD:0,sM:-1,sY:0,M:-1,Y:0}
if((i=T.value.match(/\d{2,4}/g))&&i.length==3){with(T.Cal){sD=+i[1];sM=M=i[0]-1;sY=Y=i[2]}}
}
E=T.Cal.E
with(T.Cal){if(B){M=M+1?M:sM+1?sM:cM;Y=Y||sY||cY}f=Date.UTC(Y,M,1);t=Date.UTC(Y,M+1,1)}
while(E.childNodes[0])E.removeChild(E.firstChild)
tE=cEl('table',E)
tBody=cEl('thead',tE)
tBody.onmouseup=function(){T.focus()}
tBody.onmousemove=function(){if(window.getSelection)window.getSelection().removeAllRanges()}
Row=cEl('tr',tBody)
cEl('td',Row,'&#171;').onmousedown=function(){cB(0)}
cEl('th',Row,T.Cal.Y,1)
cEl('td',Row,'&#187;').onmousedown=function(){cB(1)}
Row=cEl('tr',tBody)
cEl('td',Row,'&#171;').onmousedown=function(){cB(2)}
cEl('th',Row,cld_BlaTek.month[T.Cal.M],1)
cEl('td',Row,'&#187;').onmousedown=function(){cB(3)}
tBody=cEl('tbody',tE)
Row=cEl('tr',tBody)
for(i=0;i<7;i++){cEl('th',Row,cld_BlaTek.day[i]).className='day'+(i+1)%7}
for(i=f;i<t;i+=86400000){with(new Date(i)){d=getUTCDate();wd=getUTCDay()}
if(wd==1||i==f)Row=cEl('tr',tBody)
if(wd!=1&&d==1){for(j=1;j<(wd?wd:7);j++)cEl('td',Row).className='empty day'+j}
(tE=cEl('td',Row,d)).className='day'+wd
tE.onmousedown=function(x){x=+this.innerHTML
with(T.Cal){sM=M;sD=x;sY=Y;T.value=((y=M+1)<10?'0'+y:y)+'/'+(x<10?'0'+x:x)+'/'+Y}}
with(T.Cal){if(M==cM&&d==cD&&Y==cY)tE.className+=' today';if(M==sM&&d==sD&&Y==sY)tE.className+=' selected'}}
for(i=wd||7;i<7;){cEl('td',Row).className='empty day'+(++i%7)}
T.onblur=function(){if(T.Cal.B)E.className='clndr hide';T.form.className=T.form.className.replace(/\bhideSel\b/,'')}
T.Cal.B=1
E.className='clndr'
T.form.className+=' hideSel'}


//global object (You can translate month&day names)
cld_BlaTek={
 day:['pn','wt','śr','cz','pt','so','n'],
 month:['styczeń','luty','marzec','kwiecień','maj','czerwiec',
 'lipiec','sierpień','wrzesień','październik','listopad','grudzień']
}

//this function change days displayed in the input field
//x - number of days to add to input field
function changeDay(x,T,d){T=gId(T)
if((i=T.value.match(/\d{1,4}/g))&&i.length==3){x=new Date(Date.UTC(1*i[2],i[1]-1,1*i[0],0,0,0)+(0x5265C00*x))
T.value=((d=x.getMonth()+1)<10?'0'+d:d)+'/'+((c=x.getUTCDate())<10?'0'+c:c)+'/'+x.getFullYear()}} 

//this function add onfocus event listener to input fields
function addCalendar(a,i){aEL(window,'load',function(){for(j in a){if(i=document.getElementById(a[j]))aEL(i,'focus',Calendar)}})}

function aEL(o,t,f){var a=[].slice.call(arguments,3)
o[t+f]=function(e){return !1===f.apply(o,[e||window.event].concat(a))?e.preventDefault?e.preventDefault():!1:1}
return(o.x=o.addEventListener)?o.x(t,o[t+f],!1):(o.x=o.attachEvent)?o.x('on'+t,o[t+f]):!1}
function gId(i){return document.getElementById(i)}

//below line activates calendar on input fields with id: to, from, today
addCalendar(['to','from','today'])


function sprawdz(pole){
if(document.formularz.tytulNewsa.value==""){
alert("Wypełnij pole");
return false;
}
return true;
}
