/**
 * programmed by scorpi - PGweb 2006 - www.pgweb.cz - tahanks! :o)
 * gum up (5 lines) by veetek  
*/

Page = function () {};

Page.showPicture = function (imgNode, src, w, h) 
{
var ztmavnuti = document.getElementById('overlay');
if (ztmavnuti) {
  ztmavnuti.style.visibility = 'visible';
  ztmavnuti.style.height = document.body.scrollHeight
  }

   var ImgDiv = document.getElementById('page-orig-image');
   
   if (ImgDiv) {
      if (ImgDiv.parentNode) ImgDiv.parentNode.removeChild(ImgDiv);
      var Img = ImgDiv.firstChild;
   } else {
      ImgDiv = document.createElement('div');
      ImgDiv.id = 'page-orig-image';
      ImgDiv.style.zIndex = 100;
      ImgDiv.style.position = 'fixed';
      if (document.all && !window.Opera) ImgDiv.style.position = 'absolute';    
      ImgDiv.style.left = '0';
      ImgDiv.style.textAlign = 'center';
      ImgDiv.style.width = '100%';
      ImgDiv.style.cursor = 'pointer';
      ImgDiv.title = 'Kliknutím obrázek zavřete';
      
      
      ImgDiv.onclick = function () {this.parentNode.removeChild(this)
      
      var ztmavnuti = document.getElementById('overlay');
      if (ztmavnuti) {
        ztmavnuti.style.visibility = 'hidden';
        ztmavnuti.style.height = '100%';
      }
      };
      
      var Img = document.createElement('img');
      ImgDiv.appendChild(Img);
   };
   
   var vp = Page.getViewport();
   
   Img.src = '';
   Img.src = src;
   
   var pomerX = w/(vp.x-4);
   var pomerY = h/(vp.y-4);
   
   if (pomerX>1 || pomerY>1) {
      var pomerMax = pomerX > pomerY ? pomerX : pomerY;
      w = Math.round(w/pomerMax);
      h = Math.round(h/pomerMax);
   };
   Img.width = w;
   Img.height = h;
   
   var scrollTop = 0;
   if (document.all && !window.Opera) {
      scrollTop = document.body.scrollTop;
   };
   
   ImgDiv.style.top = ((vp.y/2)-(h/2)-2+scrollTop)+'px';
   Img.style.backgroundColor = 'black';
   Img.style.border = '2px solid black';
   document.body.appendChild(ImgDiv);
};

Page.getViewport = function () {
   var x,y;
   if (self.innerHeight) {
   	x = self.innerWidth;
   	y = self.innerHeight;
   } else if (document.documentElement && document.documentElement.clientHeight) {
   	x = document.documentElement.clientWidth;
   	y = document.documentElement.clientHeight;
   } else if (document.body) {
   	x = document.body.clientWidth;
   	y = document.body.clientHeight;
   };
   return {'x' : x, 'y' : y};
};

Page.regFileCombo = function (idCombo, elCombo, elAddButton, itemClassName, hiddenClassName) {
   if (!Page.FileCombo) Page.FileCombo = {};
   Page.FileCombo[idCombo]
   
   var els = elCombo.getElementsByTagName('*');
   var elHiddenBuffer = [];
   for (var i=0; i<els.length; i++) {
      if (Lib.containsClass(els[i], itemClassName) && Lib.containsClass(els[i], hiddenClassName)) {
         elHiddenBuffer[elHiddenBuffer.length] = els[i];
      };
   };
   
   elAddButton.onclick = function () {
      var itemEl = elHiddenBuffer.shift();
      Lib.removeClass(itemEl, hiddenClassName);
      if (elHiddenBuffer.length==0) elAddButton.parentNode.removeChild(elAddButton);
      return false;
   }
};

