
function change_tags(begin, end, special_option, textarea_id){

	var txt_area = document.getElementById(textarea_id);
	var selectionStart = txt_area.selectionStart;
	var selectionEnd = txt_area.selectionEnd;
 	var selected_text = (txt_area.value).substring(selectionStart,selectionEnd);
	var begin_lngth = begin.length;
	var end_length = end.length;

	if(selectionStart == selectionEnd){
		if(special_option != ''){
			var result = prompt(special_option, "");
			var tmp_begin = '';
			tmp_begin = begin.split("*|*");
			begin = tmp_begin[0]+result+tmp_begin[1];
			begin_lngth = begin.length;
			end_length = end.length;			
		}
			txt_area.value = txt_area.value.substring(0,selectionStart) + begin + selected_text + end + txt_area.value.substring(selectionEnd);
			txt_area.focus();
			txt_area.setSelectionRange(selectionStart+begin_lngth, selectionStart+begin_lngth);
		
	}else{
		if(special_option != ''){
			var result = prompt(special_option, "");
			var tmp_begin = '';
			tmp_begin = begin.split("*|*");
			begin = tmp_begin[0]+result+tmp_begin[1];
			begin_lngth = begin.length;
			end_length = end.length;	
		}
			txt_area.value = txt_area.value.substring(0,selectionStart) + begin + selected_text + end + txt_area.value.substring(selectionEnd);
			txt_area.focus();
			txt_area.setSelectionRange(selectionStart+begin_lngth, selectionStart+begin_lngth+selected_text.length);
		
	}

}
