//[b]gibi ikili ifaderler için [/b]

function bbcodeikili(kod,alan) {
    var alan;
tt = document.getElementById(alan);
if (document.getSelection) // firefox
{ 
    var once = tt.value.substring(0, tt.selectionStart);
    var sonra = tt.value.substr(tt.selectionEnd);
    var ara = tt.value.substring(tt.selectionStart, tt.selectionEnd);
tt.value = once + "[" + kod + "]" + ara + "[/" + kod + "]" + sonra; }

else // IE
{ 
var ara = document.selection.createRange().text;
tt.focus();
var sec = document.selection.createRange();
sec.text = "[" + kod + "]" + ara + "[/" + kod + "]"; }
return; 
}

// gibi çoklu ifadeler için

function bbcodecoklu(kod,alan,selectt) {
    var alan, kod;
    //coklu için select menusu
    
    var endeks, secilen
    endeks=selectt.selectedIndex
    secilen=selectt.options[endeks].value
    
    //bitis
    
    tt = document.getElementById(alan);
    if (document.getSelection) // firefox
    { 
        var once = tt.value.substring(0, tt.selectionStart);
        var sonra = tt.value.substr(tt.selectionEnd);
        var ara = tt.value.substring(tt.selectionStart, tt.selectionEnd);
        tt.value = once + "[" + kod + "=" + secilen + "]" + ara + "[/" + kod + "]" + sonra; }

    else // IE
    { 
    var ara = document.selection.createRange().text;
    tt.focus();
    var sec = document.selection.createRange();
    sec.text = "[" + kod + "=" + secilen + "]" + ara + "[/" + kod+ "]"; 
    }
    selectt.selectedIndex=selectt.options[endeks];
    return; 

}



// ve  gibi çoklu ifadeler için selectsiz

function bbcodecoklu2(kod,alan) {
    var alan, kod, url;
    if(kod=="email")
    {
        url=prompt("E-posta adresini girin.");
    }
    else
    {
        url=prompt("Baglanti URL'sini girin.","http://");
    }
    
    if(url==null)
    {
        
    }
    else
    {
        tt = document.getElementById(alan);
        if (document.getSelection) // firefox
        { 
            var once = tt.value.substring(0, tt.selectionStart);
            var sonra = tt.value.substr(tt.selectionEnd);
            tt.value = once + "[" + kod + "=" + url + "/]" + url + "[/" + kod + "]" + sonra; }

        else // IE
        { 
        var ara = document.selection.createRange().text;
        tt.focus();
        var sec = document.selection.createRange();
        sec.text = "[" + kod + "=" + url + "/]" + url + "[/" + kod+ "]"; 
        }
        return; 
    }
}



//:) gibi yüzler için tekli
function bbcodetekli(kod,alan) {
    var alan;
tt = document.getElementById(alan);
if (document.getSelection) // firefox
{ 
    var once = tt.value.substring(0, tt.selectionStart);
    var sonra = tt.value.substr(tt.selectionEnd);
    var ara = tt.value.substring(tt.selectionStart, tt.selectionEnd);
tt.value = once + kod + sonra; }

else // IE
{ 
var ara = document.selection.createRange().text;
tt.focus();
var sec = document.selection.createRange();
sec.text = kod ; }
return; 
} 