// JavaScript REGEnet Novoročenky

var clX, clY, offset;
var posun = 110;  // Tohle je konstanta, pomocí které se prodlužuje grafika stránky

function otevritOkno(odkaz, sirka, vyska) 
{
  okno = window.open(odkaz, "Okno", "width="+sirka+",height="+vyska+",left=60,top=60,resizable=yes,scrollbars=yes");
  okno.focus();
}

function showDotisk() 
{
  document.getElementById('blok_dotisk').style.display = 'block';
}

function hideDotisk() 
{
  document.getElementById('blok_dotisk').style.display = 'none';
}

function getClX() {
  if (self.innerHeight) {
  	return self.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
  	return document.documentElement.clientWidth;
  }
  else if (document.body) {
  	return document.body.clientWidth;
  } 
}

function getClY() {
  if (self.innerHeight) {
  	return self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
  	return document.documentElement.clientHeight;
  }
  else if (document.body) {
    return document.body.clientHeight;
  }
}

function getOffset() {
  if (document.body.offsetHeight > document.body.scrollHeight) {
    return document.body.offsetHeight;
  }
  else {
    return document.body.scrollHeight;
  }    
}

function fit() {
  pozice = findPos(document.getElementById('prodlouzeni'));
  if(!offset) {
    offset = getOffset();
  }
  clX = getClX();
  clY = getClY();
  if (offset > clY) {
    iHeight = Math.abs(offset - pozice[1] - posun);  
  }
  else {
    iHeight = Math.abs(clY - pozice[1] - posun);
  }
  document.getElementById('prodlouzeni').style.height = iHeight.toString() + 'px';
}

function resize() { 
  if(getClX() != clX || getClY() != clY) {
    fit();
  }
}

function findPos(obj) 
{
  var curleft = curtop = 0;
  if (obj.offsetParent) 
  {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) 
    {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return [curleft,curtop];
}
