<?
//быстрая вставка бб кодов
function auto_bb($form, $field)
{
	global $bb_start;
	$out='';
	if(!$bb_start)
	{
		        $out = '<script language="JavaScript" type="text/javascript">
                function tag(text1, text2) {
                if ((document.selection)) {
                document.' . $form . '.' . $field . '.focus();
                document.' . $form . '.document.selection.createRange().text = text1+document.' . $form . '.document.selection.createRange().text+text2;
                } else if(document.forms[\'' . $form . '\'].elements[\'' . $field . '\'].selectionStart!=undefined) {
                var element = document.forms[\'' . $form . '\'].elements[\'' . $field . '\'];
                var str = element.value;
                var start = element.selectionStart;
                var length = element.selectionEnd - element.selectionStart;
                element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
				document.forms[\'' . $form . '\'].elements[\'' . $field . '\'].focus();
                } else document.' . $form . '.' . $field . '.value += text1+text2;
				document.forms[\'' . $form . '\'].elements[\'' . $field . '\'].focus();}</script>';
				$bb_start = 1;
	}
               return $out.'<div style="margin:2px;padding:0px;border:0px solid #333">

<a href="javascript:tag(\':-)\',\'\')"><img src="/style/smiles/smile.gif" alt="улыбка" title="Улыбка"/></a>
<a href="javascript:tag(\':-(\',\'\')"><img src="/style/smiles/sad.gif" alt="печаль" title="Печаль"/></a>
<a href="javascript:tag(\'.ржу.\',\'\')"><img src="/style/smiles/rzhu.gif" alt="ржу" title="ржу"/></a>
<a href="javascript:tag(\'.гы.\',\'\')"><img src="/style/smiles/gy.gif" alt="гы" title="гы"/></a>
<a href="javascript:tag(\'.дружба.\',\'\')"><img src="/style/smiles/druzhba.gif" alt="Дружба" title="Дружба"/></a>
<a href="javascript:tag(\'.кофе.\',\'\')"><img src="/style/smiles/kofe.gif" alt="кофе" title="кофе"/></a>
<a href="javascript:tag(\'.неа.\',\'\')"><img src="/style/smiles/nea.gif" alt="неа" title="неа"/></a>
<a href="javascript:tag(\'.глаза.\',\'\')"><img src="/style/smiles/glaza.gif" alt="глаза" title="глаза"/></a>
<a href="javascript:tag(\'.ботан.\',\'\')"><img src="/style/smiles/botan.gif" alt="Ботан" title="Ботан"/></a>
<a href="javascript:tag(\'.апл.\',\'\')"><img src="/style/smiles/apl.gif" alt="браво" title="Браво"/></a> 

</div>';

}
?>