function openWindow(tcURL, tcWName) {
  oWindow = window.open(tcURL,tcWName,
    "fullscreen=no"
    + ",channelmode=no"
    + ",toolbar=no"
    + ",location=no"
    + ",directories=no"
    + ",status=no"
    + ",menubar=yes"
    + ",scrollbars=yes"
    + ",resizable=yes"
    + ",copyhistory=no");
}

//*************************************

function getWName() {
// Vrací generované jméno okna
  var lcDate   = new Date();
  var lcRetVal = "w" + lcDate.getTime();
  return lcRetVal;
}

//*************************************

function ZmenaVelikostiOkna() {
// Nastavení velikosti těla
/*
  Poznámka:
  48 - šířka v em odpovídající 770px při velikosti písma 100% a velikosti textu taky 100%
*/
  var lnWindowHeight = winH();
  var loPlocha        = document.getElementById("plocha-frame");
//  var loMenu         = document.getElementById("menu-frame");
  var lnHeightP      = (48/770) * lnWindowHeight - 5 - 0.3;
//  var lnHeightM      = (48/770) * lnWindowHeight - 0.3;

  if (lnHeightP < 0)
    lnHeightP = 0;
//  if (lnHeightM < 0)
//    lnHeightM = 0;

  var lcHeightP = "" + lnHeightP + "em"; 
//  var lcHeightM = "" + lnHeightM + "em"; 

  //--- Nová výška FRAME plochy i menu
  loPlocha.style.height = lcHeightP;
//  loMenu.style.height  = lcHeightM;
}

//*************************************

function SetInnerHTML(toDocument, tcID, tuValue) {
// Změna obsahu prvku
//
// Parametry:
// toDocument (Object)    - identifikace dokumentu
// tcID       (Character) - identifikace objektu
// tuValue    (?)         - hodnota, která se má zobrazit
  if (toDocument.getElementById) {
    toDocument.getElementById(tcID).innerHTML = tuValue;
  }
  else if (toDocument.layers) {
    with (toDocument[tcID].document) {
      open();
      write(tuValue);
      close();
    }
  }
  else if (toDocument.all) {
   toDocument.all[tcID].innerHTML = tuValue;
  }
}

//*************************************

function NahodnyObrazek(tnPocet, tnAktualni) {
// Vrací náhodný obrázek ze zadaného počtu
  var lnRetVal = Math.ceil(Math.random() * tnPocet);
  if (arguments.length > 1) {
    //--- Nový obrázek nebude stejný jako předchozí
    while (lnRetVal == tnAktualni) {
      lnRetVal = Math.ceil(Math.random() * tnPocet);
    }
  }
  return lnRetVal;
}

//*************************************

function ZmenObrazek(tlCasovac) {
  var lcSource1  = document.images["foto1"].src;
  var llFilters1 = document.images["foto1"].filters;
  var lnSuffix1  = "";
  //=== Obrázek 1 (nahoře)
  var lnCisloOld1 = (lcSource1.substring(lcSource1.lastIndexOf("/")+1, lcSource1.lastIndexOf(".")))*1;
  var lnCisloNew1 = NahodnyObrazek(lnPocetObrazku1, lnCisloOld1);
  //--- Číslo je menší než 10 - přidáme vedoucí nulu
  if (lnCisloNew1 < 10) {
    lnSuffix1 = "0";
  }
  lnSuffix1 += (lnCisloNew1);
  with (document.images["foto1"]) {
    if (llFilters1) {
      filters[0].Apply();
      filters[0].transition = 12;       // přechodový efekt zrnění
    }
    src   = lcPath1 + lcPath2 + lnSuffix1 + ".jpg";
//    title = aTitle[lnCisloNew1-1];
    if (llFilters1) {
      filters[0].Play();
    }
  }

  if (tlCasovac) {
    TimerID2 = setTimeout("ZmenObrazek(1)", lnInterval);
  }
}

//*************************************

function MenitObrazek() {
//  ZmenObrazek();
  TimerID1 = setTimeout("ZmenObrazek(1)", lnInterval);
}

//**************************************

function SetWindowMaximize(toWindow) {
//  Maximalizace okna
  var lnWidthMax  = screen.width;
  var lnHeightMax = screen.height;

  //--- Zjistíme dostupné rozměry pro maximalizaci okna
  if (screen.availHeight) {
    var lnHeightMax = screen.availHeight;
  }
  if (screen.availWidth) {
    var lnWidthMax = screen.availWidth;
  }

  //--- Přesun do levého horního rohu a zvětšení na max. velikost
  with(toWindow) {
    moveTo(0,0);
    resizeTo(lnWidthMax,lnHeightMax);
  }
}

//*************************************

function IsSit() {
// Je-li skript spuštěn ze sítě, vrací TRUE, jinak FALSE;
  var lcAdresa = location.href;
  return (lcAdresa.substring(0,4) == "http");
}

//*************************************

function GetAdresaPHP(tcScriptName) {
// Vrací úplnou cestu k PHP skriptu podle toho, odkud je spuštěn
  var lcAdresa = location.href;
  if (IsSit()) {
    lcAdresa = lcAdresa.substring(0, lcAdresa.lastIndexOf("?")+1)
    lcAdresa = lcAdresa.substring(0, lcAdresa.lastIndexOf("/")+1) + tcScriptName;
  }
  else {
    lcAdresa = "http://localhost/J&A/" + tcScriptName;
  }
  return lcAdresa;
}

//**************************************

function winH() {
// Vrací výšku aktuálního okna
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if (document.documentElement && document.documentElement.clientHeight)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientHeight;
   else if (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

//**************************************

function winW() {
// Vrací šířku aktuálního okna
   if (window.innerWidth)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerWidth;
   else if (document.documentElement && document.documentElement.clientWidth)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerWidth */
      return document.documentElement.clientWidth;
   else if (document.body && document.body.clientWidth)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return null;
}
