var iC=0;
var popup;
var popupOpened=0;
function imager(url,width,height,duzeStr) { 
   x = document.getElementsByTagName('img');
   for(i=0;i<x.length;i++)
   {

      if(x[i].src.indexOf(url) > -1) {
         x[i].onclick=imagerObj(x[i],width,height,duzeStr);
         x[i].style.cursor='pointer';
      }
   }
}
function imagerObj(obj,width,height,duzeStr) { 
   return (function() {
          imagerOnClick(obj,width,height,duzeStr); 
         });
}
function imagerOnClick(obj,width,height,duzeStr) { 
   if(popupOpened==1&&!popup.closed) { 
      popup.close();
   }
   re = new RegExp("(/zdjecia\/[^\.]+)\.([^\.]+)\.(.*)");
   u= obj.src.replace(re,'$1.' +duzeStr+'.$3');
   popup=window.open(u,'popup','top=50,width='+width+ ',height=' + height +',status=no');
   popup.focus();
   popup.moveTo(100,100);
   popup.onclick=popup.close;
   popupOpened=1;
}
