function format_sel(v) {
alert(v);
}

// insertcode is used for bold, italic, underline and quote and just
// wraps the tags around a selection or prompts the user for some
// text to apply the tag to
function insertTag(tag, desc)
{
    // our textfield
    var textarea = document.getElementById("New_Post");

    // our open tag
    var open = "<" + tag + ">";

    // our close tag
    var close = "</" + tag + ">";

    if(!textarea.setSelectionRange)
    {
        var selected = document.selection.createRange().text; 
        if(selected.length <= 0)
        { 
            // no text was selected so prompt the user for some text
           alert("You have to select text from the new post before");
        }
        else
        {
            // put the code around the selected text
            document.selection.createRange().text = open + selected + close; 
        }
    }
    else
    {
        // the text before the selection
        var pretext = textarea.value.substring(0, b.selectionStart);
        
        // the selected text with tags before and after
        var codetext = open + textarea.value.substring(b.selectionStart, b.selectionEnd) + close;

        // the text after the selection
        var posttext = textarea.value.substring(b.selectionEnd, textarea.value.length)
        
        // check if there was a selection
        if(codetext == open + close)
        {
            //prompt the user
            codetext = open + prompt("Please enter the text you'd like to " + desc, "") + close;
        }

        // update the text field
        textarea.value = pretext + codetext + posttext;
    }

    // set the focus on the text field
    textarea.focus();
}

