function NewWindow(link){
  window.open(link,null,"top=0,left=0,toolbar=no,menubar=no,location=no,status=yes,resizable=yes");
}

function ConfirmAction(anchor, text)
{
  if (confirm(text))
  {
    return true;
  }
  return false;
}

function SetAIndex(fieldname)
{
  var field=document.getElementById(fieldname);
  var optI=0;
  var ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1) && (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
  if (ie)
    optI=1;
  var optTxt="";
  document.write('|');
  
  while (optI<field.childNodes.length)
  {
    if (optTxt != field.childNodes.item(optI).childNodes.item(0).data.substring(0,1))
    {
      optTxt = field.childNodes.item(optI).childNodes.item(0).data.substring(0,1)
      if (ie)
        document.write('<a href="#'+((optI-1)/2)+'" onclick="javascript: document.getElementById(\''+fieldname+'\').selectedIndex='+((optI-1)/2)+';return false;">'+optTxt+'</a>|');
      else
        document.write('<a href="#'+optI+'" onclick="javascript: document.getElementById(\''+fieldname+'\').selectedIndex='+optI+';return false;">'+optTxt+'</a>|');
    }
    optI++;
    if (ie)
      optI++;
  }
}

function __getDdlKey(e)
{
  var code;
  if (!e)
    var e = window.event;
  if (e.keyCode)
    code = e.keyCode;
  else
   if (e.which)
     code = e.which;
  return code;
}
var lastValue = '';

function __searchDdlReset()
{
  lastValue = '';
  window.status = 'Najít:';
}
function __searchDdlList(eventObj,slcObj)
{
  if (navigator.userAgent.indexOf('MSIE') > -1 || navigator.userAgent.indexOf('Opera') > -1)
  {
    var lastKey = __getDdlKey(eventObj);
    if (lastKey == 8 && lastValue.length > 1)
      lastValue = lastValue.substring(0,lastValue.length-1);
    else
      lastValue += String.fromCharCode(lastKey);
    window.status = 'Najít: ' + lastValue;
    for (i=0; i<slcObj.length; i++)
    {
      if ((slcObj.options[i].text.toLowerCase().indexOf(lastValue.toLowerCase()) == 0) && (lastValue.value != ''))
      {
        slcObj.options[i].selected = true;
        return false;
      }
    }
    return false;
  }
  else
    return true;
}

function showhide( id ){
  if (document.getElementById){
    obj = document.getElementById(id);
    if (obj.style.display == "none"){
      obj.style.display = "";
    } else {
      obj.style.display = "none";
    }
  }
}

function toggle_ul(el) {
  // Get parent
  var parent = el.parentNode;
  var children = parent.childNodes;
  for (i=0; i<children.length; i++) {
    if (children[i].nodeName == "UL" && children[i].className == "treefile") {
      var ul = children[i];
      if (ul.style.display == "none") {
        ul.style.display = "";
      } else {
        ul.style.display = "none";
      }
    }
  }
}

function hdtypdata ( id , chid ) {
  obj = document.getElementById(chid);
  if (document.getElementById(id).value == "NULL"){
    obj.style.display = "";
  } else {
    obj.style.display = "none";
  }
}






function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked)
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    promenna = new Date(); 

    cal.setRange(1940, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}

