function HtmlSpecialChars(str)
{
  str = str.replace('<', '&lt;');
  str = str.replace('>', '&gt;');
  str = str.replace('\"', '&quot;');
  str = str.replace('&', '&amp;');
  return str;
}

/*
function replaceUnicodeChar(chr)
{
  if (chr=="<") return "&lt;";
  if (chr==">") return "&gt;";
  if (chr=="\"") return "&quot;";
  if (chr=="&") return "&amp;";
  var chrCode = chr.charCodeAt(0);
  var czTable = Array(193, 201, 205, 211, 218, 221, 225, 233, 237, 243, 250, 253, 268, 269, 270, 271, 282, 283, 317, 318, 327, 328, 344, 345, 352, 353, 356, 357, 366, 367, 381, 382);
  if (czTable.indexOf(chrCode) < 0) return "&#"+chrCode+";";
  return chr;
}

function HtmlSpecialChars(str)
{
  return str.replace(/[<>"&\u00A0-\uFFFF]/g, function(m){return replaceUnicodeChar(m)});
}
*/

function LangSelect(fcScript)
{
  var lcVars = '';
  element = document.getElementById('dtid');
  if (element) lcVars += (lcVars == '' ? '' : '&') + 'dtid=' + element.value;
  element = document.getElementById('IDlog');
  if (element) lcVars += (lcVars == '' ? '' : '&') + 'IDlog=' + element.value;
  element = document.getElementById('IDlogDetail');
  if (element) lcVars += (lcVars == '' ? '' : '&') + 'IDlogDetail=' + element.value;
  element = document.getElementById('IDMaster');
  if (element) lcVars += (lcVars == '' ? '' : '&') + 'IDMaster=' + element.value;
  element = document.getElementById('akce');
  if ((element) && (element.value > 10)) lcVars += (lcVars == '' ? '' : '&') + 'akce=' + (element.value - 10) ;
  element = document.getElementById('IDAkce');
  if (element) lcVars += (lcVars == '' ? '' : '&') + 'IDAkce=' + element.value;
  if (lcVars != '') fcScript += '&' + lcVars;
  self.location.href = fcScript;
}

function replacestring(str,str_find,str_replace,int_case_insensitive)
{
  if (arguments.length<3 || str_find=="" || str_normal=="" || typeof("".split)!="function") return(str);
  // no param means default, "case SENSITIVE"...
  if(!(int_case_insensitive)) return(str.split(str_find)).join(str_replace);
  str_find = str_find.toLowerCase();
  var rv = "";
  var ix = str.toLowerCase().indexOf(str_find);
  while(ix>-1)
  {
    rv += str.substring(0,ix)+str_replace;
    str = str.substring(ix+str_find.length);
    ix = str.toLowerCase().indexOf(str_find);
  };
  return(rv + str);
}

function LTstNumberModN(str, n, errmsg)
{
  var suma = 0;
  var koef = 1;
  for (i = str.length-1; i >= 0; i--)
  {
    var cifra = parseInt(str.charAt(i));
    suma = suma + koef * cifra;
    koef = koef * 2;
  }
  if ((suma % n) != 0)
  {
      alert(errmsg);
      return false;
  }
  return true;
}

