Page = function () {};

Page.showPicture = function (imgNode, src, w, h, title) 
{
   var ImgDiv = document.getElementById('page-orig-image');
   
   if (ImgDiv) {
      if (ImgDiv.parentNode) {
         ImgDiv.parentNode.removeChild(ImgDiv);
      };
      var TitleDiv = ImgDiv.getElementsByTagName('div')[0];
      var Img = ImgDiv.getElementsByTagName('img')[0];
   } else {
      ImgDiv = document.createElement('div');
      ImgDiv.id = 'page-orig-image';
      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%';
      
      TitleDiv = document.createElement('div');
      
      ImgDiv.onclick = function () {this.parentNode.removeChild(this)};
      
      var Img = document.createElement('img');
      ImgDiv.appendChild(TitleDiv);
      ImgDiv.appendChild(Img);
   };
   
   var vp = Page.getViewport();
   
   Img.src = '';
   Img.src = src;
   
   var pomerX = w/(vp.x-4);
   var pomerY = h/(vp.y-4-20);
   
   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;
   
   ImgDiv.style.top = ((vp.y/2)-(h/2)-2)+'px';
   Img.style.backgroundColor = 'white';
   
   Img.style.border = '2px solid black';
   
   if (!title) title = '';
   TitleDiv.innerHTML = title;
   
   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;
   }
};

Page.sDefense = function ($fEl) {
   var $fc = document.createElement('input');
   $fc.type = 'hidden';
   $fc.name = 'defense';
   $fc.value = '1';
   $fEl.appendChild($fc);
};

/* webina - login form */
Page.showLoginForm = function ()
{
   var el = document.getElementById('login-div');
   el.style.display = 'block';
   el.style.zIndex = '10';
   window.scrollTo(0,0);
}

function gid($co) {return document.getElementById($co);}