﻿  /* tato funkce nastavuje sirku div s tabulkou, aby byl siroky jako tabulka, ktera je v nem 
-> aby fungovalo zarovnani na stred
*/
function setWidthDivContent(div, tbl)
{
  div = getE(div);
  tbl = getE(tbl);
  
  div.style.width = tbl.clientWidth+"px";
}


function setWidthDivContent(div, tbl, minWidth)
{
  div = getE(div);
  tbl = getE(tbl);
  
  if (minWidth > tbl.clientWidth)
    div.style.width = minWidth+"px";
  else
    div.style.width = tbl.clientWidth+"px";
}

function checkLowResolution(hdn)
{
  if (screen.width <= 800)
  {
    Cookie.setCookie('lowRes', 'True');
  }
  else
  {
    Cookie.removeCookie('lowRes');
  }
}

function checkLength(tbx, length, e) 
{
  var oEvent = window.event ? window.event : e;

  //backspace a delete nedela nic
  if ((oEvent.keyCode == 8) || (oEvent.keyCode == 46))
  {
    return true;
  }  
  tbx = getE(tbx);
  if (tbx != null)
  {
    if (tbx.value.length >= length) {
      alert('Překročen povolený počet znaků.');
      return false;
    }
  }
}

function chbxLstSelect(chbxLst, value) {
  //budu prochazet stranku dokud nenajdu
  var i = 0;
  while (1 == 1) {
    var chbx = document.getElementById(chbxLst + '_' + i.toString());

    if (chbx == null)
      break;
    else {
      chbx.checked = value;
      i = i + 1;
    }
  }
}

function reloadOpener()
{
  if (window.opener != null)
  {
    window.opener.location.reload();
    window.close();
  }
}

function Maximize() {
  window.moveTo(0, 10);
  window.resizeTo(screen.width, screen.height - 50);
}

function trim(str) {

  return str.replace(/^\s*|\s*$/g, "");
}

function removeSpaces(tbx) {
  tbx = getE(tbx);
  tbx.value = trim(tbx.value);
  tbx.value = tbx.value.toString().replace(' ', '');
}
