var i = 1;
var lastRow = 4;

function addRowToTable() {
    var tbl = document.getElementById('reportTable');
    
    // if there's no header row in the table, then iteration = lastRow + 1
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
		row.id = i;
    
    // left cell
    var cellLeft = row.insertCell(0);
    var divLeft = document.createTextNode(' ');
//    divLeft.appendChild(document.createTextNode(text1));
//    divLeft.class = 'report';
    cellLeft.appendChild(divLeft);
    
    // right cell
    var cellRight = row.insertCell(1);
    var inputRight = document.createElement('input');
    var aRight = document.createElement('a');
//    inputRight.appendChild(document.createTextNode(text));
//    aRight.id = i + '_';
    aRight.href = 'javascript:skryj(\'' + i + '\');';
		aRight.appendChild(document.createTextNode('smaž'));
//    inputRight.id = i;
    inputRight.type = 'file';
    inputRight.size = '30';
//    divRight.class = 'clock';
    cellRight.appendChild(inputRight);
    cellRight.appendChild(document.createTextNode(' '));
    cellRight.appendChild(aRight);
		i++; lastRow++;
}

// IE only - wraps selected text with lft and rgt
  function WrapIE(lft, rgt) {
    strSelection = document.selection.createRange().text;
    if (strSelection!="") {
      document.selection.createRange().text = lft + strSelection + rgt;
    }
  }

// Moz only - wraps selected text with lft and rgt
  function wrapMoz(txtarea, lft, rgt) {
    var selLength = txtarea.textLength;
    var selStart = txtarea.selectionStart;
    var selEnd = txtarea.selectionEnd;
    if (selEnd==1 || selEnd==2) selEnd=selLength;
    var s1 = (txtarea.value).substring(0,selStart);
    var s2 = (txtarea.value).substring(selStart, selEnd)
    var s3 = (txtarea.value).substring(selEnd, selLength);
    txtarea.value = s1 + lft + s2 + rgt + s3;
  }
  
// Chooses technique based on browser
  function wrapTag(txtarea, lft, rgt) {
    lft = unescape(lft);
    rgt = unescape(rgt);
    if (document.all) {
      WrapIE(lft, rgt);
    }
    else if (document.getElementById) {
      wrapMoz(txtarea, lft, rgt);
    }
  }  
  
// IE only - Insert text at caret position or at start of selected text
  function insertIE (txtarea, text) {
    if (txtarea.createTextRange && txtarea.caretPos) { 
      var caretPos = txtarea.caretPos; 
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text+caretPos.text + ' ' : text+caretPos.text;
    } else {
      txtarea.value = txtarea.value + text; 
    }
    return;
  } 

// Moz only - Insert text at caret position or at start of selected text
  function insertMoz(txtarea , lft) {
    var rgt="";
    wrapTag(txtarea, lft, rgt);
    return;
  }

// Switch function based on browser - Insert text at caret position or at start of selected text
  function insertTag(txtarea , lft) {
    if (document.all) {
      insertIE(txtarea, lft);
    }
    else if (document.getElementById) {
      insertMoz(txtarea, lft);
    }
  }

function smajliky(what)
{
    //document.shoutform.text.value = document.shoutform.text.value + ' ' + what + ' ';
	//document.shoutform.text.focus();
	insertTag (document.ff.zprava,what);
}


function schovej (koho)
{if (document.getElementById(koho).style.display=='none')
{document.getElementById(koho).style.display='block';}
else
{document.getElementById(koho).style.display='none'}};

function zobraz(co) {
document.getElementById(co).style.display='block'};
function skryj(co2) {
document.getElementById(co2).style.display='none'};





// IE only - wraps selected text with lft and rgt
  function WrapIE_(lft, rgt) {
    strSelection = document.selection.createRange().text;
    if (strSelection!="") {
      document.selection.createRange().text = lft + strSelection + rgt;
    }
  }

// Moz only - wraps selected text with lft and rgt
  function wrapMoz_(lft, txtarea, rgt) {
    var selLength = txtarea.textLength;
    var selStart = txtarea.selectionStart;
    var selEnd = txtarea.selectionEnd;
    if (selEnd==1 || selEnd==2) selEnd=selLength;
    var s1 = (txtarea.value).substring(0,selStart);
    var s2 = (txtarea.value).substring(selStart, selEnd)
    var s3 = (txtarea.value).substring(selEnd, selLength);
    txtarea.value = lft + s1 + s2 + rgt + s3;
  }
  
// Chooses technique based on browser
  function wrapTag_(lft, txtarea, rgt) {
    lft = unescape(lft);
    rgt = unescape(rgt);
    if (document.all) {
      WrapIE_(lft, rgt);
    }
    else if (document.getElementById) {
      wrapMoz_(lft, txtarea, rgt);
    }
  }  
  
// IE only - Insert text at caret position or at start of selected text
  function insertIE_ (text, txtarea) {
    if (txtarea.createTextRange && txtarea.caretPos) { 
      var caretPos = txtarea.caretPos; 
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text+caretPos.text + ' ' : text+caretPos.text;
    } else {
      txtarea.value = text + txtarea.value; 
    }
    return;
  } 

// Moz only - Insert text at caret position or at start of selected text
  function insertMoz_(lft , txtarea) {
    var rgt="";
    wrapTag_(lft, txtarea, rgt);
    return;
  }

// Switch function based on browser - Insert text at caret position or at start of selected text
  function insertTag_(lft , txtarea) {
    if (document.all) {
      insertIE_(lft , txtarea);
    }
    else if (document.getElementById) {
      insertMoz_(lft , txtarea);
    }
  }

function odpoved(what)
{
    //document.shoutform.text.value = document.shoutform.text.value + ' ' + what + ' ';
	//document.shoutform.text.focus();
  document.ff.odpoved.value="";
	insertTag_ (what,document.ff.odpoved);
}

function check_form(frma)
	{
	msg='Formulář není zcela vyplněn. Prosím vyplňte následující položky:\n';
	var result=true;
	if (frma.jmeno.value == "") {msg+='\tJméno\n'; result=false; }
	if (frma.zprava.value == "") {msg+='\tZpráva\n'; result=false; }
	if (frma.control.value != "3") {msg+='\tKontrolní otázka\n'; result=false; }
	if (result == false) alert(msg);
		return(result);
	}

