// JavaScript Document

function delConfirm()
{
  return window.confirm("Opravdu smazat?");
}

/**
 * Kontrola formulare 'Rezervace letadel'
 */
function checkFormPlaneReserve(form)
{
  if (form)
  {
    if (form.destinace && form.destinace.value == "") {
      form.destinace.focus();
      window.alert("Zadejte prosím destinaci / účel letu.");
      return false;
    }
    return true;
  }
  return false;
}

/**
 * Kontrola formulare - prispevek do diskuze
 */
function checkDiskuseForm()
{
  var f = document.forms["formDiskuze"];
  if (f)
  {
    if (f.nadpis.value == "") {
      f.nadpis.focus();
      window.alert('Zadej prosím nadpis!');
      return false;
    }
    if (f.text.value == "") {
      f.text.focus();
      window.alert('Zadej prosím text!');
      return false;
    }
  }
  return true;
} 

/**
 * Zvetsovani obrazku
 */
function zoomImage(zoomSrc)
{
  var newWindow = window.open('zoom.php?openByJS=1&img=' + zoomSrc, '', 'width=640,height=480,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
  newWindow.focus(); 
  return false;
}

function zoomResizeWindow()
{
  if (document.images[0])
  {
    w = document.images[0].width + 50;
    h = document.images[0].height + 110;
    if (w > screen.availWidth)  w = screen.availWidth;
    if (h > screen.availHeight) h = screen.availHeight;
    x = (screen.availWidth  - w)/2;
    y = (screen.availHeight - h)/2;
    
    window.resizeTo(w, h);
    window.moveTo(x, y);
  }
  return;
}

/**
 * Chat
 */
function addSmile(smile) {
  var textElem = document.getElementById("chatText");
  if (textElem) {
    textElem.value += "**" + smile;
    textElem.focus();
  }
}

function checkChatForm() {
  var f = document.getElementById("formChat");
  if (f) {
    if (f.autor.value == "") {
      f.autor.focus();
      alert("Vyplňte prosím pole 'Autor'.");
      return false;
    }
    if (f.nadpis.value == "" && f.text.value == "") {
      f.nadpis.focus();
      alert("Vyplňte prosím pole 'Nadpis' a/nebo pole 'Text'.");
      return false;
    }
  }
  return true;
}

function chranFormular() {
  var inp = document.getElementById("ochr2");
  if (inp) inp.value = "1";
} 
