﻿    String.prototype.trim = function() {
        return this.replace(/^\s*/, "").replace(/\s*$/, "");
    }

    function externalLinks() {
        if (!document.getElementsByTagName) return;
        var anchors = document.getElementsByTagName("a");

        for (var i=0; i < anchors.length; i++) {
            var anchor = anchors[i];
            if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
                anchor.target = "_blank";
        }
    }

    function EditorPopupLinks(editor) {
        var links = editor.get_document().getElementsByTagName("A");
        for (var i = 0; i < links.length; i++) {
            var link = links[i];
            link.setAttribute("target", "#");
        };
    }
    
    function addOnErrorEventHandler(fn) {
        var existingonerror = window.onerror;
        if (typeof window.onerror == 'function') {
            window.onerror = function() {
                existingonerror();
                fn();
            };
        } else {
            window.onerror = fn;
        }
    }
    
    String.prototype.startsWith = function(str){ 
    return (this.indexOf(str) === 0); 
    } 

    
    window.onload = externalLinks;
