var TextBox = document.getElementById('wtextbox');

function bold()         { format('b'); }
function italic()       { format('i'); }
function underline()    { format('u'); }
function strike()       { format('s'); }

function format ( tag ) {

    if ( document.selection ) {
        newtag = '['+tag+']'+document.selection.createRange().text+'[/'+tag+']';
        document.selection.createRange().text = newtag;
    } else {
        TextBox.innerHTML += '['+tag+']'+'[/'+tag+']';
    }

    TextBox.focus();

}
