<?php

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:1px;margin-left: 5px;padding-left:2px;">
	<a href="javascript:tag(\'[b]\', \'[/b]\')"><i class="fa fa-bold fa-fw"></i></a>
	<a href="javascript:tag(\'[i]\', \'[/i]\')"><i class="fa fa-italic fa-fw"></i></a>
	<a href="javascript:tag(\'[u]\', \'[/u]\')"><i class="fa fa-underline fa-fw"></i></a>
	<a href="javascript:tag(\'[s]\', \'[/s]\')"><i class="fa fa-strikethrough fa-fw"></i></a>
	<a href="javascript:tag(\'[url=]\', \'[/url]\')"><i class="fa fa-link fa-fw"></i></a>
	<a href="javascript:tag(\'[red]\', \'[/red]\')"><font color="red"><i class="fa fa-stop fa-fw"></i></font></a>
	<a href="javascript:tag(\'[green]\', \'[/green]\')"><font color="green"><i class="fa fa-stop fa-fw"></i></font></a>
	<a href="javascript:tag(\'[blue]\', \'[/blue]\')"><font color="blue"><i class="fa fa-stop fa-fw"></i></font></a>
	<a href="javascript:tag(\'[orange]\', \'[/orange]\')"><font color="orange"><i class="fa fa-stop fa-fw"></i></font></a>
        <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#Bing" aria-expanded="false" aria-controls="Bing"><font color="blue"><i class="fa fa-smile-o fa-fw"></i></font></a><br />
        <div id="Bing" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
        	
        <a href="javascript:tag(\'.\', \'sm.\')"><img src="/style/smiles/sm.png" /></a> 
	<a href="javascript:tag(\'.\', \'sm1.\')"><img src="/style/smiles/sm1.png" /></a> 
	<a href="javascript:tag(\'.\', \'sm2.\')"><img src="/style/smiles/sm2.png" /></a> 
	<a href="javascript:tag(\'.\', \'sm3.\')"><img src="/style/smiles/sm3.png" /></a> 
	<a href="javascript:tag(\'.\', \'sm4.\')"><img src="/style/smiles/sm4.png" /></a> 
	<a href="javascript:tag(\'.\', \'sm5.\')"><img src="/style/smiles/sm5.png" /></a>
	<a href="javascript:tag(\'.\', \'sm6.\')"><img src="/style/smiles/sm6.png" /></a>
	<a href="javascript:tag(\'.\', \'sm7.\')"><img src="/style/smiles/sm7.png" /></a>
	<a href="javascript:tag(\'.\', \'sm8.\')"><img src="/style/smiles/sm8.png" /></a>
	<a href="javascript:tag(\'.\', \'sm9.\')"><img src="/style/smiles/sm9.png" /></a>
	<a href="javascript:tag(\'.\', \'sm10.\')"><img src="/style/smiles/sm10.png" /></a>
	<a href="javascript:tag(\'.\', \'sm11.\')"><img src="/style/smiles/sm11.png" /></a>
	<a href="javascript:tag(\'.\', \'sm12.\')"><img src="/style/smiles/sm12.png" /></a>
	<a href="javascript:tag(\'.\', \'sm13.\')"><img src="/style/smiles/sm13.png" /></a>
	<a href="javascript:tag(\'.\', \'sm14.\')"><img src="/style/smiles/sm14.png" /></a>
	<a href="javascript:tag(\'.\', \'sm15.\')"><img src="/style/smiles/sm15.png" /></a>
	<a href="javascript:tag(\'.\', \'sm16.\')"><img src="/style/smiles/sm16.png" /></a>
	<a href="javascript:tag(\'.\', \'sm17.\')"><img src="/style/smiles/sm17.png" /></a>
	<a href="javascript:tag(\'.\', \'sm18.\')"><img src="/style/smiles/sm18.png" /></a>
	<a href="javascript:tag(\'.\', \'sm19.\')"><img src="/style/smiles/sm19.png" /></a>
	<a href="javascript:tag(\'.\', \'sm20.\')"><img src="/style/smiles/sm20.png" /></a>
	<a href="javascript:tag(\'.\', \'sm21.\')"><img src="/style/smiles/sm21.png" /></a>
	<a href="javascript:tag(\'.\', \'sm22.\')"><img src="/style/smiles/sm22.png" /></a>
	<a href="javascript:tag(\'.\', \'sm23.\')"><img src="/style/smiles/sm23.png" /></a>
	<a href="javascript:tag(\'.\', \'sm24.\')"><img src="/style/smiles/sm24.png" /></a>
	<a href="javascript:tag(\'.\', \'sm25.\')"><img src="/style/smiles/sm25.png" /></a>
	<a href="javascript:tag(\'.\', \'sm26.\')"><img src="/style/smiles/sm26.png" /></a>
	<a href="javascript:tag(\'.\', \'sm27.\')"><img src="/style/smiles/sm27.png" /></a>
	<a href="javascript:tag(\'.\', \'sm28.\')"><img src="/style/smiles/sm28.png" /></a>
	<a href="javascript:tag(\'.\', \'sm29.\')"><img src="/style/smiles/sm29.png" /></a>
	<a href="javascript:tag(\'.\', \'sm30.\')"><img src="/style/smiles/sm30.png" /></a>
	<a href="javascript:tag(\'.\', \'sm31.\')"><img src="/style/smiles/sm31.png" /></a>
	<a href="javascript:tag(\'.\', \'sm32.\')"><img src="/style/smiles/sm32.png" /></a>
	<a href="javascript:tag(\'.\', \'sm33.\')"><img src="/style/smiles/sm33.png" /></a>
	<a href="javascript:tag(\'.\', \'sm34.\')"><img src="/style/smiles/sm34.png" /></a>
	<a href="javascript:tag(\'.\', \'sm35.\')"><img src="/style/smiles/sm35.png" /></a>
	<a href="javascript:tag(\'.\', \'sm36.\')"><img src="/style/smiles/sm36.png" /></a>
	<a href="javascript:tag(\'.\', \'sm37.\')"><img src="/style/smiles/sm37.png" /></a>
	<a href="javascript:tag(\'.\', \'sm38.\')"><img src="/style/smiles/sm38.png" /></a>
	<a href="javascript:tag(\'.\', \'sm39.\')"><img src="/style/smiles/sm39.png" /></a>
	<a href="javascript:tag(\'.\', \'sm40.\')"><img src="/style/smiles/sm40.png" /></a>
	<a href="javascript:tag(\'.\', \'sm41.\')"><img src="/style/smiles/sm41.png" /></a>
	<a href="javascript:tag(\'.\', \'sm42.\')"><img src="/style/smiles/sm42.png" /></a>
	<a href="javascript:tag(\'.\', \'sm43.\')"><img src="/style/smiles/sm43.png" /></a>
	<a href="javascript:tag(\'.\', \'sm44.\')"><img src="/style/smiles/sm44.png" /></a>
	<a href="javascript:tag(\'.\', \'sm45.\')"><img src="/style/smiles/sm45.png" /></a>
	<a href="javascript:tag(\'.\', \'sm46.\')"><img src="/style/smiles/sm46.png" /></a>
	<a href="javascript:tag(\'.\', \'sm47.\')"><img src="/style/smiles/sm47.png" /></a>
	<a href="javascript:tag(\'.\', \'sm48.\')"><img src="/style/smiles/sm48.png" /></a>
	<a href="javascript:tag(\'.\', \'sm49.\')"><img src="/style/smiles/sm49.png" /></a>
	<a href="javascript:tag(\'.\', \'sm50.\')"><img src="/style/smiles/sm50.png" /></a>
	<a href="javascript:tag(\'.\', \'sm51.\')"><img src="/style/smiles/sm51.png" /></a>
	<a href="javascript:tag(\'.\', \'sm52.\')"><img src="/style/smiles/sm52.png" /></a>
	<a href="javascript:tag(\'.\', \'sm53.\')"><img src="/style/smiles/sm53.png" /></a>
	<a href="javascript:tag(\'.\', \'sm54.\')"><img src="/style/smiles/sm54.png" /></a>
	<a href="javascript:tag(\'.\', \'sm55.\')"><img src="/style/smiles/sm55.png" /></a>
	<a href="javascript:tag(\'.\', \'sm56.\')"><img src="/style/smiles/sm56.png" /></a>
	<a href="javascript:tag(\'.\', \'sm57.\')"><img src="/style/smiles/sm57.png" /></a>
	<a href="javascript:tag(\'.\', \'sm58.\')"><img src="/style/smiles/sm58.png" /></a>
	<a href="javascript:tag(\'.\', \'sm59.\')"><img src="/style/smiles/sm59.png" /></a>
	<a href="javascript:tag(\'.\', \'sm60.\')"><img src="/style/smiles/sm60.png" /></a>
	<a href="javascript:tag(\'.\', \'sm61.\')"><img src="/style/smiles/sm61.png" /></a>
	<a href="javascript:tag(\'.\', \'sm62.\')"><img src="/style/smiles/sm62.png" /></a>
	<a href="javascript:tag(\'.\', \'sm63.\')"><img src="/style/smiles/sm63.png" /></a>
	<a href="javascript:tag(\'.\', \'sm64.\')"><img src="/style/smiles/sm64.png" /></a>
	<a href="javascript:tag(\'.\', \'sm65.\')"><img src="/style/smiles/sm65.png" /></a>
	<a href="javascript:tag(\'.\', \'sm66.\')"><img src="/style/smiles/sm66.png" /></a>
	<a href="javascript:tag(\'.\', \'sm67.\')"><img src="/style/smiles/sm67.png" /></a>
        
        </div></div>';
}
