version = navigator.appVersion.toLowerCase();
agent = navigator.userAgent.toLowerCase();
ie = (version.indexOf('msie')>-1);
win = (version.indexOf('windows')>-1);
opera = (agent.indexOf('opera')>-1);

function changeEnable(cim, co)
{
  if (cim.checked) co.disabled = false;
  else co.disabled = true;
}

/* Open new window */
function OpenWnd(strURL, target)
{
	var objWnd = window.open(strURL,target,"scrollbars=1,status=1,resizable");
	objWnd.focus();
}
/* Open new window */

/* Print, favorites */
function prn()
{
  document.write('\074a a  title="vytisknout stránku" class="print" href=\"javascript:goprn();\"\076Tisk\074/a\076');
}

function goprn()
{
  window.print();
}

function fav()
{
  if ((opera) && (win)) return false;
  else if ((ie) && (win)) document.write('\074a title="přidat stránku do oblíbených položek" class="fav" href=\"javascript:gofav();\"\076Do oblíbených\074/a\076&nbsp;|');
}

function gofav()
{
  window.external.addFavorite('http://www.isrt.cz/','ISRT - Institut Synergické Reflexní Terapie');
}
/* Print, favorites */

/* Forms: forum & prihlaska */
function trim(dlh)
{
  dlh = dlh.replace(/^[\s]+/g,"");
  dlh = dlh.replace(/[\s]+$/g,"");
  return dlh;
}

function forumCheck(forumData)
{
  var forumAlert = "";
  var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
  if (trim(forumData.writer.value)=="")
  {
    forumAlert = forumAlert + "Vyplňte prosím Vaše jméno.\n\n";
    forumData.writer.focus();
  }
  if (!((forumData.email.value=="") || (forumData.email.value=="@")))
  {
    if (!filter.test(forumData.email.value)) forumAlert = forumAlert + "Váš email nemá správný formát.\n\n";
  }
  if (trim(forumData.nadpis.value)=="") forumAlert = forumAlert + "Chybí nadpis!\n\n";
  if (trim(forumData.msg.value)=="") forumAlert = forumAlert + "Nelze odeslat prázdný příspěvek.\n\n";
  if (forumAlert)
  {
    forumAlert = "========= Upozornění =========\n\n" + forumAlert;
    alert(forumAlert);
    return false;
  }
  else return true;
}

function prihlCheck(prihlData)
{
  var prihlaskaAlert = "";
  var ostatChyby = "";
  var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
  if (trim(prihlData.id_kurzu.value)=="") prihlaskaAlert = prihlaskaAlert + "- číslo kurzu\n";
  if (trim(prihlData.datum_akce.value)=="") prihlaskaAlert = prihlaskaAlert + "- datum akce\n";
  if (trim(prihlData.jmeno.value)=="" || trim(prihlData.prijmeni.value)=="") prihlaskaAlert = prihlaskaAlert + "- jméno\n";
  if (trim(prihlData.prace.value)=="") prihlaskaAlert = prihlaskaAlert + "- povolání\n";
  if (trim(prihlData.privat_ulice.value)=="" || trim(prihlData.privat_psc.value)=="" || trim(prihlData.privat_mesto.value)=="") prihlaskaAlert = prihlaskaAlert + "- adresa bydliště\n";
  if (trim(prihlData.privat_email.value)=="") prihlaskaAlert = prihlaskaAlert + "- email (privát)\n";
  if (trim(prihlData.privat_tel.value)=="") prihlaskaAlert = prihlaskaAlert + "- telefon (privát)\n";
  if (prihlData.squash_hajek.checked)
  {
    if (trim(prihlData.poc_noci.value)=="") prihlaskaAlert = prihlaskaAlert + "- počet nocí\n";
    if (trim(prihlData.prijezd.value)=="") prihlaskaAlert = prihlaskaAlert + "- datum příjezdu\n";
    if (trim(prihlData.odjezd.value)=="") prihlaskaAlert = prihlaskaAlert + "- datum odjezdu\n";
    if (trim(prihlData.poc_osob_pokoj.value)=="") prihlaskaAlert = prihlaskaAlert + "- počet osob k ubytování\n";
  }
  if ((prihlData.prace_email.value!="") && (!filter.test(prihlData.prace_email.value)))
  {
    prihlaskaAlert = prihlaskaAlert + "\nOstatní chyby:\n\n- pracovní email nemá správný formát\n";
    ostatChyby = "1";
  }
  if ((prihlData.privat_email.value!="") && (!filter.test(prihlData.privat_email.value)))
  {
    if (!ostatChyby) prihlaskaAlert = prihlaskaAlert + "\nOstatní chyby:\n\n";
    prihlaskaAlert = prihlaskaAlert + "- privátní email nemá správný formát";
  }
  if (prihlaskaAlert)
  {
    prihlaskaAlert = "======== Upozornění ========\n\nNebyla vyplněna tato povinná pole:\n\n" + prihlaskaAlert;
    alert(prihlaskaAlert);
    return false;
  }
  else return true;
}
/* Forms: forum & prihlaska */

// antiSpam email protection
function obfuscate (address) {
    var obfuscated = "";
    
    for (i = 0; i < address.length; i++) {
        obfuscated += "&#" + address.charCodeAt(i) + ";";
    };

    return (obfuscated);
};

/* Preload */
var pr_temp_variable = null;

function preload (id_name, id_src)
{
  pr_temp_variable = new Array (id_name, true, new Image());
  pr_temp_variable[2].src = id_src;
  eval ("item_" + id_name + " = pr_temp_variable");
}
/* Preload */

