//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//BLOG.JS
//GILLINGHAM TECHNOLOGIES COPYRIGHT (C) 2004, 2005, 2006, 2007, 2008. 2009
//
//JAVASCRIPT FOR BLOG.ASPX
//
//IF YOU ARE GOING TO USE THIS SCRIPT PLEASE KEEP THIS HEADER IN PLACE TO GIVE PROPER
//ACKNOWLEDGEMENT FOR MY HARD WORK.
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

//-----------------------------------------------------------
//Wrap an html tag around selected text in an asp.net textbox.
//aspId = asp.net text box name
//s = starting html tag
//e = ending html tag
//-----------------------------------------------------------
function tag(s, e){
    var txt = document.getElementById("<%=txtNewBlogText.ClientID %>");
    
    if (document.selection){ //this is microsoft ie
        var str = document.selection.createRange().text;
        document.selection.createRange().text = s + str + e; 
    }
    else if (txt.selectionStart){ //this is mozilla
        var sIdx = txt.selectionStart;
        var eIdx = txt.selectionEnd;
        var str = txt.value.substring(sIdx, eIdx);
        txt.value = txt.value.substring(0,sIdx) + s + str + e +
          txt.value.substring(eIdx, txt.value.length);
    }     
    return false; //stop the asp btn from postback        
}

function bold(){
    return tag("<b>", "</b>");
}
        
function italic(){
    return tag("<i>", "</i>");
}

function underline(){
    return tag("<u>", "</u>");
}

function strike(){
    return tag("<strike>", "</strike>");
}

function font(size){
    if (size != "null"){
        return tag("<" + size + " style=\"display: inline\">", "</" + size + ">");
    }
}

