// DO NOT EDIT THIS FILE: Changes will be overwritten from
// the default template in Help Builder's startup directory
function getdocumentselection() {
    var sel = document.selection;
    var range = sel.createRange();
    if (!range)
        return null;                

    if (sel.type == "Text" || sel.type == "None") {
                    
        var parent = range.parentElement();

        var parentHtml = null;
        var tagName = null;
        if (parent) {
            parentHtml = parent.outerHTML;
            tagName = parent.nodeName;
        }
        var selHtml = null;
        if (range)
            selHtml = range.htmlText;

        var res = {
            selection: sel,
            range: range,
            parent: parent,
            tagname: tagName,
            parenthtml: parentHtml,
            selectionhtml: selHtml
        }                    
    }
    else if (sel.type == "Control") {                
        if (range.length < 1)
            return null;
        var el = range.item(0);

        var res = {
            selection: sel,
            range: range,
            parent: el.parentNode,
            tagname: el.nodeName,
            parenthtml: el.outerHTML,
            selectionhtml: el.outerHTML
        }
    }
    return res;
}
