

function toPointer(){
	document.body.style.cursor="pointer";
}

function toText(){
	document.body.style.cursor="text";
}

function insrtTags(tagStart, tagEnd, smplTxt) {
	var txtarea;
	if (document.mainForm){
		txtarea= document.mainForm.inpMainTxt;
	}
	
	var slTxt, isSmpl = false;
	if (document.selection && document.selection.createRange) { // Explo
		if (document.documentElement && document.documentElement.scrollTop)
			var winScroll = document.documentElement.scrollTop
		else if (document.body)
			var winScroll = document.body.scrollTop;
			
		txtarea.focus();
		var range = document.selection.createRange();
		slTxt = range.text;
		ctrlSelectText();
		range.text = tagStart + slTxt + tagEnd;
		if (isSmpl && range.moveStart) {
			if (window.opera)
				tagEnd = tagEnd.replace(/\n/g,'');
			range.moveStart('character', - tagEnd.length - slTxt.length); 
			range.moveEnd('character', - tagEnd.length); 
		}
		range.select();   
		if (document.documentElement && document.documentElement.scrollTop)
			document.documentElement.scrollTop = winScroll
		else if (document.body)
			document.body.scrollTop = winScroll;

	} else if (txtarea.selectionStart || txtarea.selectionStart=='0') { // FF
		var textScroll = txtarea.scrollTop;
		txtarea.focus();
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		slTxt = txtarea.value.substring(startPos, endPos);
		ctrlSelectText();
		txtarea.value = txtarea.value.substring(0, startPos)
			+ tagStart + slTxt + tagEnd
			+ txtarea.value.substring(endPos, txtarea.value.length);
			
		if (isSmpl) {
			txtarea.selectionStart = startPos + tagStart.length;
			txtarea.selectionEnd = startPos + tagStart.length + slTxt.length;
		} else {
			txtarea.selectionStart = startPos + tagStart.length + slTxt.length + tagEnd.length;
			txtarea.selectionEnd = txtarea.selectionStart;
		}
		txtarea.scrollTop = textScroll;
	} 

	function ctrlSelectText(){
		if (!slTxt) {
			slTxt = smplTxt;
			isSmpl = true;
		} else if (slTxt.charAt(slTxt.length - 1) == ' ') { //exclude ending space char
			slTxt = slTxt.substring(0, slTxt.length - 1);
			tagEnd += ' '
		} 
	}
}

