//Code 2002 by pigwa@infocentrum.com
function dodIkone(Id,Sc,Txt,Ext,TrzyStan,IcoName){
  if(IcoName==null)IcoName=Id;
  if(TrzyStan)Ikony[Id]=new Array(4);
  else Ikony[Id]=new Array(3);
  Ikony[Id][0]=Txt;
  Ikony[Id][1]=new Image();Ikony[Id][1].src=Sc+IcoName+"."+Ext;
  Ikony[Id][2]=new Image();Ikony[Id][2].src=Sc+IcoName+"a"+"."+Ext;
  if(TrzyStan){Ikony[Id][3]=new Image();Ikony[Id][3].src=Sc+IcoName+"w"+"."+Ext;}
}
function wla(Id,Tx){var tSrc = Ikony[Id][3].src;Ikony[Id][3].src = Ikony[Id][1].src;Ikony[Id][1].src = tSrc;nrm(Id);st(Tx);return true;}
function st(t){window.status=t;return true;}

function aqw(Id){if(Klk!=Id)aqq(Id);return true;}
function nrw(Id){if(Klk!=Id)nrm(Id);return true;}
var Klk="";
function klk(Id){if(Klk!=Id){var tmp=Klk;Klk=Id;wla(Id,"");if(tmp!="")wla(tmp,"");}st(Ikony[Id][0]);return true;}

Mis=(navigator.userAgent.indexOf("MSIE")!=-1)?1:0;
Ixy=(navigator.appVersion.indexOf("X11")!=-1)?1:0;
Mac=(navigator.appVersion.indexOf("Mac")!=-1)?1:0;
Kon=(navigator.appName.indexOf("Netscape")!=-1)?1:0;
Wiek=(Mis==1&&navigator.appVersion.indexOf("MSIE"))?parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+4)):parseInt(navigator.appVersion);

var Ot=0;
var nW;
function c(){if(Ot){nW.close();Ot=0;}}
function o(p,n,w,h,r,s,op){if(op==null){if(n==null)n="pigwa";if(w==null)w=580;if(h==null)h=320;if(r==null)r=0;if(s==null)s=1;op='toolbar=0,menubar=0,location=0,status='+s+',scrollbars=2,copyhistory=0,resizable='+r+',width='+w+',height='+h;}nW=window.open(p,n,op);if((Ixy||Mac)&&Mis)nW=window.open(p,n);Ot=1;nW.focus();}
function g(p,t,c,w,h){var wX=null;var wY=null;if(!w){if(screen){wX=screen.availWidth;if(wX>1024)wX=1044;if(wX>800&&wX<1024)wX=820;}}else{wX=w;}if(!h){if(screen){wY=screen.availHeight;if(wY>768)wY=788;if(wY>600&&wY<768)wY=620;}}else{wY=h;}o('','pigwaCmsGallery',wX,wY,1,0);if(t==null)t="Pigwa CMS - Galerry";if(c==null||c=="")c="";else c=c+"<br>";nW.document.open();nW.document.write("<html><LINK rel=\"stylesheet\" type=\"text/css\" href=\"css/portal.css\"><title>"+t+"</title><body marginwidth=\"0\" marginheight=\"0\"><center>"+c+"<a href=\"javascript:window.close();\"><img src=\""+document.location.href.substring(0,document.location.href.lastIndexOf("/")+1)+p+"\" alt=\""+(c!=""?c:p)+"\" border=\"0\"></a></center></body></html>");nW.document.close();}
function lockBtn(f,eN){var elem=null;if(f!=null)elem=f.elements[eN];elem.disabled=true;}
function lockBtns(){btnsLckd=new Array();for(i=0,j=0;i<tF.elements.length;i++){if(tF.elements[i].type!='hidden'&&!tF.elements[i].disabled){btnsLckd[j++]=tF.elements[i].name;}}for(i=0;i<btnsLckd.length;i++){lockBtn(tF,btnsLckd[i]);}}
function ulckBtn(f,eN){var elem=null;if(f!=null)elem=f.elements[eN];elem.disabled=false;}
function ulckBtns(){for(i=0;i<btnsLckd.length;i++){ulckBtn(tF,btnsLckd[i]);}}
var isChkin=0;
function setHTMLTag(f,tag,eo,par,cl,ds){var t=null;f.focus;if((eo==null||eo.length==0)){eo=0;}if((cl==null||cl.length==0)){cl=0;}if((par==null)){par="";}if((ds==null)){ds="";}
if(document.selection!=null&&document.selection.createRange!=null&&(document.selection.type=='Text')){
  t=document.selection.createRange().text;
  document.selection.createRange().text="###pcms:tag:pcms###";
  sb=f.value.indexOf("###pcms:tag:pcms###");
  if(sb>=0){
    document.selection.createRange().text='<'+tag+(par!=""?" "+par:"")+'>'+t+(eo<2?'</'+tag+'>':'');
  }else{
    document.selection.createRange().text=t;
  }
}else{
  t=f.value;
  if(!eo&&t.lastIndexOf('<'+tag+'>')>=0&&t.lastIndexOf('<'+tag+'>')>=t.lastIndexOf('</'+tag+'>')){
    f.value=t+'</'+tag+'>';
  }else{
    f.value=t+'<'+tag+(par!=""?" "+par:"")+'>';
    if(cl){f.value+=ds+'</'+tag+'>';}
  }
  f.focus();
}
}
function setHref(f){var t=f.value;var dsc=null;if(document.selection!=null&&document.selection.createRange!=null&&(document.selection.type=='Text')){dsc=document.selection.createRange().text;}else{dsc=prompt("Podaj opis dla linku:","Link");}if (dsc!=null && dsc!=""){var linkUrl=prompt("Podaj adres URL dla linku:","http://");if(linkUrl!=null&&linkUrl!=""){setHTMLTag(f,'a',1,'href=\"'+linkUrl+'\"',1,dsc)}}}
function setFile(f,fID){var t=f.value;f.value=t+'<pcms:file iID=\"'+fID+'\"/>';f.focus();}
function setImg(f,fID,iAl){var t=f.value;f.value=t+'<pcms:img iID=\"'+fID+'\" align=\"'+iAl+'\"/>';f.focus();}
function setImgId(f,fID,c,picPrev,p,imgPath,n,imgName){f.value=fID;if(f.value!=""){c.checked=true;}if(imgName!=""){p.value=imgPath;n.value=imgName;if(picPrev){var pP=new Image();var iP=imgPath;if(imgPath!="")iP=imgPath+"/";pP.src=iP+imgName;picPrev.src=pP.src;if(pP.complete){picPrev.height=75*(pP.height/pP.width);}}}}
function resizeZet(){if(Kon&&Wiek>4){if(window.innerWidth>300)fld.style.width=window.innerWidth-30;if(window.innerHeight>210)fld.style.height=window.innerHeight-100;}else if(Mis){if(doc.body.clientWidth>287)fld.style.width=doc.body.clientWidth-17;if(doc.body.clientHeight>210)fld.style.height=doc.body.clientHeight-100;}}
function zet(ctPth,cssPath,jsPath,doc,fN,eN,bC,bT,iC,iT,uC,uT,subC,subT,supC,supT,pC,pT,brC,brT,T,iF){
if(!Kon||Wiek>4){
  if(doc!=null)frm=doc.forms[fN];if(frm!=null)fld=frm.elements[eN];bUrl=doc.URL.substring(0,doc.URL.indexOf("/",8));if(ctPth==null)ctPth="";ctxPth=bUrl+ctPth+"/";
  o("",'textFieldZoom',640,480,1);t="Zoom Edit";if(T!=null)t=t+": "+T;
  nW.document.open("text/html");nW.document.lang="pl";nW.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><!-- CODE BEHIND by Piotr Gaede <pigwa@infocentrum.com> 2002 --><html><head><meta http-equiv=Content-Type content=\"text/html; charset=iso-8859-2\"><LINK rel=\"stylesheet\" type=\"text/css\" href=\""+bUrl+cssPath+"cms.css\"><title>"+t+"</title>"+
  "<script src=\""+bUrl+jsPath+"util.js\" type=\"text/javascript\"></script>"+
  "<script language=\"JavaScript\"><!--\n var doc=null;var fld;var tF;\nvar btnsLckd=new Array();\n//--></script>\n</head><body bgcolor=\"#ffffff\" text=\"#000000\" link=\"#A06060\" vlink=\"#606060\" alink=\"#000000\" marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" topmargin=\"0\" onLoad=\"doc=document;frm=doc.forms['ZoomEditForm'];tF=frm;fld=frm.elements['"+eN+"'];fld.focus();\" onUnload=\"opener.ulckBtns();opener.Ot=0;\" onResize=\"resizeZet();\">"+
  "<table border=\"1\" align=\"center\" height=\"98%\" width='100%'><form name=\"ZoomEditForm\" onSubmit=\"opener.document.forms['"+fN+"'].elements['"+eN+"'].value=fld.value;opener.c();return false;\" onReset=\"opener.c();\"><tr><th>"+t+
  "</th><td class=\"label\"><input type=\"submit\" name=\"save\" value=\"Zapisz\"/> <input type=\"reset\" name=\"cancel\" value=\"Anuluj\"/></td></tr><tr><td colspan=\"2\" align=\"center\"><textarea class=\"zoomEdit\" wrap=\"virtual\" cols=\"42\" rows=\"16\" name=\""+eN+"\">"+fld.value+"</textarea><br>"+
  "Wstaw: [<a href=\"javascript:setHTMLTag(fld,'b');\" title=\""+bT+"\">"+bC+"</a>] [<a href=\"javascript:setHTMLTag(fld,'i');\" title=\""+iT+"\"><i><b>"+iC+"</b></i></a>] "+
  "[<a href=\"javascript:setHTMLTag(fld,'u');\" title=\""+uT+"\">"+uC+"</a>] [<a href=\"javascript:setHTMLTag(fld,'sub');\" title=\""+subT+"\">"+subC+"</a>] [<a href=\"javascript:setHTMLTag(fld,'sup');\" title=\""+supT+"\">"+supC+"</a>] "+
  "[<a href=\"javascript:setHTMLTag(fld,'p',1);\" title=\""+pT+"\">"+pC+"</a>] [<a href=\"javascript:setHTMLTag(fld,'br',2);\" title=\""+brT+"\">"+brC+"</a>] "+
  "[<a href=\"javascript:setHref(fld);\">Link</a>] [<a href=\"javascript:o('"+ctxPth+"showfiles.action?cmd=show&what=images','filesList',400,300,0);\">Obraz</a>] [<a href=\"javascript:o('"+ctxPth+"showfiles.action?cmd=show&what=files','filesList',400,300,0);\">Plik</a>]</td></tr></form></table></body></html>");
  nW.document.close();
}else{
  alert("Wymagane: MSIE 5.5 lub nowsze, albo przeglądarka zgodna z Gecko.\nRequired: MSIE 5.5 or newer, or Gecko compatible browser.");
}}
function chkLen(fN,eN,l){if(!isChkin){isChkin=1;t=document.forms[fN].elements[eN];if(t.value.length>l){t.value=t.value.substring(0,l);m="Nie więcej niż "+l+" znakow.";alert(m);t.focus();}isChkin=0;}}
function clrNDsbl(frm,checkBox,textBox,comboBox,comboValue,radioButt,rBEn){var ch=null;var tx=null;var cb=null;var rb=null;if (textBox!=null) tx=frm.elements[textBox];if (checkBox!=null) ch=frm.elements[checkBox];if (comboBox!=null) cb=frm.elements[comboBox];if (radioButt!=null) rb=frm.elements[radioButt];if (tx!=null){if (rb!=null){tx.disabled=!rBEn;if (rBEn==true)tx.focus();else tx.value="";}else{tx.value="";if (ch!=null){if(tx.disabled!=null) tx.disabled=!ch.checked;if (ch.checked) tx.focus();}if (cb!=null){if(tx.disabled!=null) tx.disabled=!(cb.options[cb.selectedIndex].value == comboValue);if (cb.options[cb.selectedIndex].value == comboValue) tx.focus();}}} return true;}
function setAllCh(fN,eN,v){var ok=true;var f=null;var c=null;if(fN!=null){f=document.forms[fN];}else{f=document.forms[0];}if(eN!=null){c=f.elements[eN];}else{ok=false;}if(ok&&c.length!=null){for(i=0;i<c.length;i++){c[i].checked=v;}}else if(ok){c.checked=v;}return false;}
function ifMrkd(fN,eN){var ok=true;var f=null;var c=null;if(fN!=null){f=document.forms[fN];}else{f=document.forms[0];}if(eN!=null){c=f.elements[eN];}else{ok=false;}if(ok&&c.length!=null){ok=false;for(i=0;i<c.length&&!ok;i++){ok=c[i].checked;}}else if(ok){ok=c.checked;}return ok;}

function setCookie(cookieName,cookieValue,nDays){if(nDays!=null||nDays!=0)nDays=1;var today=new Date();var expire=new Date();expire.setTime(today.getTime()+3600000*24*nDays);document.cookie=cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();}
function getCookie(cookieName){if(cookieName!=null&&cookieName!=""){var theCookie=""+document.cookie;var ind=theCookie.indexOf(cookieName);if(ind==-1)return "";var ind1=theCookie.indexOf(';',ind);if(ind1==-1)ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+1,ind1));}else{return "";}}
