function setCursorPos (elm, begin, end)
{
    if (typeof elm.selectionStart != "undefined" && typeof elm.selectionEnd != "undefined")
    {
        elm.setSelectionRange (begin, end);
        elm.focus ();
    }

    else if (document.selection && document.selection.createRange)
    {
        var range = elm.createTextRange ();
        range.move ("character", begin);
        range.moveEnd ("character", end - begin);
        range.select ();
    }
}



//vložení textu na pozici
function insertAtCursor(obj,val)
{
var o = obj;
o.focus();
if (document.selection)
{
sel = document.selection.createRange();
sel.text = val;
}
else if (o.selectionStart || o.selectionStart == '0')
{
var startPos = o.selectionStart;
var endPos = o.selectionEnd;
o.value = o.value.substring(0,startPos) + val + o.value.substring(endPos, o.value.length);
	setCursorPos (document.formular.text, startPos,startPos);
}
else
{
o.value += val;
	setCursorPos (document.formular.text, startPos,startPos);
}
}

//vložení kolem vybraného textu
function insertAroundSelection(obj,startVal,endVal)
{
var o = obj;
o.focus();
if (document.selection)
{
	sel = document.selection.createRange();
	var selText = sel.text;
	sel.text = startVal + selText + endVal;

}
else if (o.selectionStart || o.selectionStart == '0')
{
var startPos = o.selectionStart;
var endPos = o.selectionEnd;
o.value = o.value.substring(0,startPos) + startVal + o.value.substring(startPos,endPos) + endVal + o.value.substring(endPos,o.value.length);
	setCursorPos (document.formular.text, startPos,startPos);
}
else
{
o.value += startVal + endVal;
	setCursorPos (document.formular.text, startPos, startPos);
}
} 

function add(ins) {
	document.all.text.value=document.all.text.value+ins;
	review();
}
