
var FormSend = false;

d = document;
n = navigator;
nap = n.appVersion;
nua = n.userAgent;
win = (nap.indexOf('Win') != -1);
mac = (nap.indexOf('Mac') != -1);
lin = (nua.indexOf('Linux') != -1);

if (!d.layers){
  dom = (d.getElementById);
  op = (nua.indexOf('Opera') != -1);
  konq = (nua.indexOf('Konqueror') != -1);
  saf = (nua.indexOf('Safari') != -1);
  moz = (nua.indexOf('Gecko') != -1 && !saf && !konq);
  ie = (d.all && !op);
  ie4 = (ie && !dom);
  ie5x = (d.all && dom);
  ie5mac = (mac && ie5x);
  ie5xwin = (win && ie5x);
}

function fav(url,title) {
  if ((moz || ie || op) && win) {
    document.write('\074a href=\"javascript:goFav(\''+url+'\', \''+title+'\');\"\076Přidat k oblíbeným\074/a\076');
  } else {
    return false;
  }
} // end function fav

function goFav(url,title) {
  if (window.sidebar) {
    alert('Pro přidání do oblíbených stiskněte Ctrl+D');
  } else {
    if (window.external) {
      window.external.AddFavorite(url,title);
    } else {
      alert('Pro přidání do oblíbených stiskněte Ctrl+D');
    }
  }
} // end function goFav

function CheckKontaktForm(KontaktForm) {
  var Problem = 'no';
  var Message = 'Vyplňte prosím všechny povinné položky !!! \n\n';

  if (!FormSend) { 
    inp = document.KontaktForm.email.value;
    email = /^[a-z0-9_.-]+([_\\.-][a-z0-9]+)*@([a-z0-9_\.-]+([\.][a-z]{2,4}))+$/i;
    if (email.test(inp) == false) {
      Message = Message+"- vložte platnou emailovou adresu \n";
      document.KontaktForm.email.style.borderColor = 'red';
      if (Problem == 'no') {document.KontaktForm.email.focus();}
      Problem = 'yes';
    } else {
      document.KontaktForm.email.style.borderColor = '#7f8db9';
    }
    if (document.KontaktForm.zprava.value.length <= 0) {
      Message = Message+"- vložte zprávu \n";
      document.KontaktForm.zprava.style.borderColor = 'red';
      if (Problem == 'no') {document.KontaktForm.zprava.focus();}
      Problem = 'yes';
    } else {
      document.KontaktForm.zprava.style.borderColor = '#7f8db9';
    }
    if (Problem == 'no') {
      document.getElementById("submitbutton").disabled = true; // deaktivace tlačítka
      FormSend = true;
      return (true);
    } else {
      alert (Message);
      FormSend = false;
      return (false);
    }
  } else { // již bylo odesláno
    return (false);
  }
} // end function CheckKontaktForm

function CheckKomentareForm(KomentareForm) {
  var Problem = 'no';
  var Message = 'Vyplňte prosím všechny povinné položky !!! \n\n';

  if (!FormSend) {
    if (document.KomentareForm.comm_name.value.length <= 0) {
      Message = Message+"- vložte vaše jméno \n";
      document.KomentareForm.comm_name.style.borderColor = 'red';
      if (Problem == 'no') {document.KomentareForm.comm_name.focus();}
      Problem = 'yes';
    } else {
      document.KomentareForm.comm_name.style.borderColor = '#7f8db9';
    }
    if (document.KomentareForm.comm_email.value.length > 0) {
      inp = document.KomentareForm.comm_email.value;
      email = /^[a-z0-9_.-]+([_\\.-][a-z0-9]+)*@([a-z0-9_\.-]+([\.][a-z]{2,4}))+$/i;
      if (email.test(inp) == false) {
        Message = Message+"- email nemá správný formát \n";
        document.KomentareForm.comm_email.style.borderColor = 'red';
        if (Problem == 'no') {document.KomentareForm.comm_email.focus();}
        Problem = 'yes';
      } else {
        document.KomentareForm.comm_email.style.borderColor = '#7f8db9';
      }
    } else {
      document.KomentareForm.comm_email.style.borderColor = '#7f8db9';
    } 
    if (document.KomentareForm.comm_title.value.length <= 0) {
      Message = Message+"- vložte nadpis \n";
      document.KomentareForm.comm_title.style.borderColor = 'red';
      if (Problem == 'no') {document.KomentareForm.comm_title.focus();}
      Problem = 'yes';
    } else {
      document.KomentareForm.comm_title.style.borderColor = '#7f8db9';
    } 
    if (document.KomentareForm.comm_text.value.length <= 0) {
      Message = Message+"- vložte komentář \n";
      document.KomentareForm.comm_text.style.borderColor = 'red';
      if (Problem == 'no') {document.KomentareForm.comm_text.focus();}
      Problem = 'yes';
    } else {
      document.KomentareForm.comm_text.style.borderColor = '#7f8db9';
    }
    if (Problem == 'no') {
      document.getElementById("submitbutton").disabled = true; // deaktivace tlačítka
      FormSend = true;
      return (true);
    } else {
      alert (Message);
      FormSend = false;
      return (false);
    }
  } else { // již bylo odesláno
    return (false)
  }
} // end function CheckKomentareForm

function ToggleBox(szDivID) {
  if (document.layers) { // NN4+
    if (document.layers[szDivID].visibility == 'visible') {
      document.layers[szDivID].visibility = "hidden";
      document.layers[szDivID].display = "none";
    } else {
      document.layers[szDivID].visibility = "show";
      document.layers[szDivID].display = "inline";
    }
  } else if (document.getElementById) { // gecko(NN6) + IE 5+
    var obj = document.getElementById(szDivID);

    if (obj.style.visibility == 'visible') {
      obj.style.visibility = "hidden";
      obj.style.display = "none";
    } else {
      obj.style.visibility = "visible";
      obj.style.display = "inline";
    }
  } else if (document.all) { // IE 4
    if (document.all[szDivID].style.visibility == 'visible') {
      document.all[szDivID].style.visibility = "hidden";
      document.all[szDivID].style.display = "none";
    } else {
      document.all[szDivID].style.visibility = "visible";
      document.all[szDivID].style.display = "inline";
    }
  }
  focus();
} // end function ToggleBox

function ResizeForm(pixelvalue) {
  var box = document.getElementById('resizecanvas');
  var boxheight = parseInt(box.style.height);
  var newheight = boxheight + pixelvalue;
  if (newheight > 0) {
    box.style.height = newheight + "px";
  }
} // end function ResizeForm
