function insert (obj,otag, ctag, single){
	var txt = document.getElementById(obj);
	txt.focus();
	
	if (document.getSelection){
		var sel_start = txt.selectionStart;
		var sel_end   = txt.selectionEnd;
	
		if (single){
			txt.value = txt.value.substr(0, sel_start) + otag + txt.value.substr(sel_end);
			txt.selectionStart = sel_start + otag.length;
			txt.selectionEnd   = sel_start + otag.length;
		}
		else{
			txt.value = txt.value.substr(0, sel_start) + otag + txt.value.substr(sel_start, sel_end - sel_start) + ctag + txt.value.substr(sel_end);
			txt.selectionStart = sel_start + otag.length;
			txt.selectionEnd   = sel_end   + otag.length;
		}
	}
	else{
		var sel = document.selection.createRange();
	
		if (sel){
			if (single) sel.text = otag;
			else{
				var selText = sel.text;
				sel.text = otag + selText + ctag;
				sel.moveStart ("character", -ctag.length-selText.length);
				sel.moveEnd   ("character", -ctag.length);
			}
			sel.select();
		}
	}
}