// bbCode control by
// subBlue design
// www.subBlue.com

// Define the bbCode tags
function addtext(sc,loc){
    loc.value +=sc;
}

function stylecombo(startup,nr,loc)
{
    var nada;
    nada=startup+(nr*2);
    bbstyle(nada,loc);
}

bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[stanga]','[/stanga]','[centru]','[/centru]','[dreapta]','[/dreapta]','[citat]','[/citat]','[url]http://','[/url]','[font=#B01E28]','[/#B01E28]','[font=red]','[/font]','[font=orange]','[/font]','[font=green]','[/font]','[font=blue]','[/font]','[size=7]','[/size]','[size=9]','[/size]','[size=18]','[/size]','[size=24]','[/size]','[img]http://','[/img]');

function bbstyle(bbnumber,loc) {

        var txtarea = loc;

        txtarea.focus();
        donotinsert = false;
        theSelection = false;
        bblast = 0;
        gasit=0;

                browserul = navigator.userAgent;

                if(browserul.indexOf("Firefox")>=1)
                     gasit=1;
                if(browserul.indexOf("Opera")>=1)
                     gasit=1;

		if(!gasit)
                theSelection = document.selection.createRange().text; // Get text selection
                
		if (theSelection) {
                        // Add tags around selection
                        document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
                        txtarea.focus();
                        theSelection = '';
                        return;
                }else
                {
                        txtarea.value += bbtags[bbnumber]+bbtags[bbnumber+1];
                }
}