
function ins(name){
var input=document.fast_reply.post;
input.value=input.value+"[b]"+name+"[/b]"+" \n";
}

function insd(name){
var input=document.fast_reply.description;
document.fast_reply.description.value = name;
}

function pasted(text, flag){ 
if ((document.selection)&&(flag)) {
	document.fast_reply.description.focus();
	document.fast_reply.document.selection.createRange().text = text;
} else document.fast_reply.description.value += text;
}

function Insert(text){ 
if (text!="") paste("[quote]"+text+"[/quote]\r\n", 0);
document.fast_reply.post.focus();
}

function paste(text, flag){ 
if ((document.selection)&&(flag)) {
	document.fast_reply.post.focus();
	document.fast_reply.document.selection.createRange().text = text;
} else document.fast_reply.post.value += text;
}

function get_selection() {
   if (document.getSelection){
	selection = document.getSelection();
	selection = selection.replace(/\r\n\r\n/gi, "_doublecaret_");
	//selection = selection.replace(/\r\n/gi, " ");
	selection = selection.replace(/\n\n/gi, "\n");
	selection = "\n"+"[I]"+selection+"[/I]";
       while (selection.indexOf("  ") !=-1) selection = selection.replace(/  /gi, ""); 
	selection = selection.replace(/_doublecaret_/gi, "\r\n\r\n");
  } else
      selection = document.selection.createRange().text;
}

function ins_icon(name){
var input=document.fast_reply.post;
input.value=input.value+name;
}

function add_code(name){
var input=document.fast_reply.post;
input.value=input.value+name;
}
/* меню чтения приват мессаг */
/* формирование кнопок */
function privat_read(name,id_msg,id_user){
document.writeln("<div class='t_l_button'>");
document.writeln("<a href=\"javascript:privat_quote('"+name+", в этой теме вы написали: '+selection)\" onmousedown=\"get_selection()\">&nbsp;цитировать&nbsp;</a>");
document.writeln("<a href='view_profile.php?user_id="+id_user+"&vng="+js_sess_id+"' target='_blank'>&nbsp;профиль&nbsp;юзера&nbsp;</a>");
document.writeln("<a href=\"javascript:del_post('private.php?cmd=del_msg&msg="+id_msg+"');\">&nbsp;удалить это сообщение&nbsp;</a>");
document.writeln("<a href=\"javascript:del_post('private.php?cmd=del_all&id_user="+id_user+"');\">&nbsp;удалить все сообщения этого пользователя&nbsp;</a>");
document.writeln("</div>");
}
/* цитирование в привате */
function privat_quote(text){ 
if (text!="") paste("[quote]"+text+"[/quote]\r\n", 0);
document.fast_reply.post.focus();
}

