function popup(url, title, width, height) {
  document.body.scroll="no";
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

  var pop = new myPop();
  pop.popOut(url, title, width, height, (myWidth - width)/2 + scrOfX, (myHeight - height)/2 + scrOfY);
}

function closepopup(pop) {
  pop.close();
}

function myPop() { 


    if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
      }

  this.square = null;
  this.overdiv = null;

  this.popOut = function(url, title, width, height, left, top) {
    // vse pod oknem   

    var maindoc = document;
    this.overdiv = maindoc.createElement("div");
    this.overdiv.className = "overdiv";
    this.overdivstyle=this.overdiv.style;
    this.overdivstyle.position='absolute';
    this.overdivstyle.top=(0)+'px';
    this.overdivstyle.left=(0)+'px';
    this.overdivstyle.width=(xWithScroll)+'px';
    this.overdivstyle.height=(yWithScroll)+'px';

    this.overdivstyle.opacity = (15/100);
    this.overdivstyle.MozOpacity = (15/100);
    this.overdivstyle.filter = "alpha(opacity=65)";
    this.overdivstyle.backgroundColor='#C0C0C0';
    maindoc.body.appendChild(this.overdiv);

    // cele okno
    this.square = maindoc.createElement("div");
    this.square.className = "square";
    this.square.obj = this;
    this.square.id = "pop";
    this.squarestyle=this.square.style;
    this.squarestyle.position='absolute';
    this.squarestyle.visibility='visible';
    this.squarestyle.width=(width)+'px';
    this.squarestyle.height=(height)+'px';
    this.squarestyle.top=(top)+'px';
    this.squarestyle.left=(left)+'px';
    this.squarestyle.border=(1) + 'px solid';
    this.squarestyle.backgroundColor='#FFFFFF';


    maindoc.body.appendChild(this.square);
    
    // hlavicka okna
    this.wintitlediv = maindoc.createElement("div");
    this.wintitlediv.className = "wintitle";
    this.wintitledivstyle = this.wintitlediv.style;
    this.wintitledivstyle.position='absolute';
    this.wintitledivstyle.top=(0) + 'px';
    this.wintitledivstyle.left=(0) + 'px';
    this.wintitledivstyle.backgroundColor='#98B1D4';
    this.wintitledivstyle.width=(width)+'px';
    this.wintitledivstyle.height=(30)+'px';
    this.square.appendChild(this.wintitlediv);

    this.titlediv = maindoc.createElement("div");
    this.titlediv.className = "ititle";
    this.titledivstyle = this.titlediv.style;
    this.titlediv.innerHTML = title;
    this.titledivstyle.position='absolute';
    this.titledivstyle.top = (5) + 'px';
    this.titledivstyle.left=(5) + 'px';
    this.titledivstyle.color='#000000';
    this.titledivstyle.backgroundColor='#98B1D4';
    this.square.appendChild(this.titlediv);


    // zaviraci tlacitko    
    this.closebtn = maindoc.createElement("button");
    this.closebtn.onclick = function() {
      this.parentNode.obj.close();
    }
    this.closebtn.innerHTML = "x";
    this.closestyle = this.closebtn.style;
    this.closestyle.position='absolute';
    this.closestyle.top = (3) + 'px';
    this.closestyle.left=(width - 27) + 'px';
    this.closestyle.width=(24)+'px';
    this.closestyle.height=(24)+'px';
    this.square.appendChild(this.closebtn);

    // telo okna
    this.myiframe=maindoc.createElement('IFRAME');
    this.myiframe.id='myiframe';
    this.myiframe.name='myiframe';
    this.myiframe.setAttribute('frameborder','1');
    this.myiframe.src=url;
    this.myiframestyle=this.myiframe.style;
    this.myiframestyle.padding=(0) + 'px';
    this.myiframestyle.position='absolute';
    this.myiframestyle.border=(0) + 'px';
    this.myiframestyle.top=(30) + 'px';
    this.myiframestyle.left=(0) + 'px';
    this.myiframestyle.visibility='visible';
    this.myiframestyle.width=(width)+'px';
    this.myiframestyle.height=(height-30)+'px';
    this.square.appendChild(this.myiframe);


  }

  this.close = function() {
    var maindoc = document;
    if (parent.document) {
      maindoc = parent.document;
    }
    if (this.myiframe != null) {
      this.square.removeChild(this.myiframe);
      this.myiframe = null;
    }
    if (this.square != null) {
      maindoc.body.removeChild(this.square);
      this.square = null;
    }
    if (this.overdiv != null) {
      maindoc.body.removeChild(this.overdiv);
      this.overdiv = null;
    }

  }
}

