﻿//
// BlogEngine Comment Toolbar Extension: Javascript functions
//
// Extension release: 1.0
// BE Compatibility:  1.3 and superior 
// Author:            Cristiano Fino
// WebSite:           http://www.cristianofino.net
//

var txtContentID = "ctl00_cphBody_CommentView1_txtContent";
var sEn = ["[b]","[/b]"];
var sQu = ["[cite]","[/cite]"];

function Quote(sAuthor,commentID) {
        var otext = document.getElementById(commentID);
        var otextCommentArea = document.getElementById(txtContentID);
        if (window.getSelection)
            var sel = window.getSelection();
        else if (document.getSelection)
            var sel = document.getSelection();
        else if (document.selection) {
            var sel = document.selection.createRange().text; }        
        if (otext.innerText){
            if (sel != "") otextCommentArea.value += sEn[0] + sAuthor + sEn[1] + " yazdı ki:\n" + sQu[0] + sel + sQu[1];
            else otextCommentArea.value += sEn[0] + sAuthor + sEn[1] + " yazdı ki:\n[cite]" + otext.innerText + sQu[1];
        }
        else { 
            if (sel != "") otextCommentArea.value += sEn[0] + sAuthor + sEn[1] + " yazdı ki:\n" + sQu[0] + sel + sQu[1];
            else otextCommentArea.value += sEn[0] + sAuthor + sEn[1] + " yazdı ki:\n" + sQu[0] + otext.textContent + sQu[1];
        }
        otextCommentArea.focus();
        ShowCommentPreview('livepreview', otextCommentArea);
}    

function Reply(sAuthor) {
        var otextCommentArea = document.getElementById(txtContentID);
        otextCommentArea.value += sEn[0] + "@ " + sAuthor + sEn[1] + ":\n\n";
        otextCommentArea.focus();
        ShowCommentPreview('livepreview', otextCommentArea);
}    











