function addRow() {
  var elements, templateRow, rowCount, row, className, newRow, i;

  if (!document.getElementsByTagName)
    return false; /* DOM not supported */

  elements = document.getElementsByTagName("tr");
  templateRow = null;
  rowCount = 0;
  for (i = 0; i < elements.length; i++) { //nalezeni posledniho radku tabulky
    row = elements.item(i);

    /* Get the "class" attribute of the row. */
    className = null;
    if (row.getAttribute)
      className = row.getAttribute('class');
    if (className == null && row.attributes) {    // MSIE 5
      /* getAttribute('class') always returns null on MSIE 5, and
       * row.attributes doesn't work on Firefox 1.0.    Go figure. */
      className = row.attributes['class'];
      if (className && typeof(className) == 'object' && className.value) {
        // MSIE 6
        className = className.value;
      }
    }

    /* This is not one of the rows we're looking for.    Move along. */
    if (className != "row_to_clone")
      continue;

    /* This *is* a row we're looking for. */
    templateRow = row;
    rowCount++;
  }
  if (templateRow == null)
    return false; /* Couldn't find a template row. */

  /* Make a copy of the template row */
  newRow = templateRow.cloneNode(true);
  newRow.getElementsByTagName("a").item(0).parentNode.innerHTML = '<a href="#" onclick="removeRow('+rowCount.toString()+'); return false;"><img src="public/image/drop.png" alt="Odebrat účastníka" class="icon" title="Odebrat účastníka" /></a>';
  /*vycisteni inputu*/
  inputs = newRow.getElementsByTagName('input');
  for(i = 0; i < inputs.length; i++) {
    if(inputs[i].getAttribute('type') == 'text') {
      inputs[i].value = "";
    }
  }

  /* Add the newly-created row to the table */
  templateRow.parentNode.appendChild(newRow);

  recountId();
  return true;
}

function removeRow(id) {
  //alert(id);
  var row = document.getElementById('rowid_' + id);
  if(row != null) {
    row.parentNode.removeChild(row);
  }
  return true;
}

function recountId() {
  /* Declare variables */
  var elements, rowCount, row, className, i;

  if (!document.getElementsByTagName) return; /* DOM not supported */

  elements = document.getElementsByTagName("tr");
  rowCount = 0;
  for (i = 0; i < elements.length; i++) {
    row = elements.item(i);

    /* Get the "class" attribute of the row. */
    className = null;
    if (row.getAttribute)
      className = row.getAttribute('class')
    if (className == null && row.attributes) {    // MSIE 5
      /* getAttribute('class') always returns null on MSIE 5, and
       * row.attributes doesn't work on Firefox 1.0.    Go figure. */
      className = row.attributes['class'];
      if (className && typeof(className) == 'object' && className.value) {
        // MSIE 6
        className = className.value;
      }
    }

    /* This is not one of the rows we're looking for.    Move along. */
    if (className != "row_to_clone") continue;

    row.setAttribute('id', 'rowid_'+rowCount);
    rowCount++;
  }
}

