﻿var JSTarget = {
    init: function(att, val, warning) {
        if (document.getElementById && document.createElement && document.appendChild) {
            var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
            var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
            var strWarning = ((typeof warning == 'undefined') || (warning == null)) ? ' (opens in a new window)' : warning;
            var arrLinks = document.getElementsByTagName('a');
            var oLink;
            var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
            for (var i = 0; i < arrLinks.length; i++) {
                oLink = arrLinks[i];
                if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {

                    oLink.onclick = JSTarget.openWin;
                }
            }
        }
    },
    //    openWin: function(e) {
    //    var msg = "\nLinks which take you out of Abbott Laboratories worldwide \n" +
    //     "web site are not under the control of Abbott Laboratories, \n" +
    //     "and Abbott Laboratories is not responsible for the contents \n" +
    //     "of any such site or any further links from such site. Abbott \n" +
    //     "Laboratories is providing these links to you only as a \n" +
    //     "convenience, and the inclusion of any link does not imply \n" +
    //     "endorsement of the linked site by Abbott Laboratories.\n\n" +
    //     "Do you wish to leave this site?";
    //        var warn_on_leave = confirm(msg)
    //        var event = (!e) ? window.event : e;
    //        if (warn_on_leave) {
    //            var oWin = window.open(this.getAttribute('href'), '_blank');
    //            if (oWin) {
    //                if (oWin.focus) oWin.focus();
    //                return false;
    //            }
    //            oWin = null;
    //            return true;
    //        }
    //    },

    openWin: function(e) {
        var event = (!e) ? window.event : e;
        var msg = "\nLinks which take you out of Abbott Laboratories worldwide \n" +
        "web site are not under the control of Abbott Laboratories, \n" +
       "and Abbott Laboratories is not responsible for the contents \n" +
       "of any such site or any further links from such site. Abbott \n" +
        "Laboratories is providing these links to you only as a \n" +
        "convenience, and the inclusion of any link does not imply \n" +
        "endorsement of the linked site by Abbott Laboratories.\n\n" +
         "Do you wish to leave this site?";
        if (confirm(msg)) {
            window.open(this.getAttribute('href'), '_blank');
            return false;
        }
        else
            return false;
    },
    /*
    addEvent function 
    */
    addEvent: function(obj, type, fn) {
        if (obj.addEventListener)
            obj.addEventListener(type, fn, false);
        else if (obj.attachEvent) {
            obj["e" + type + fn] = fn;
            obj[type + fn] = function() { obj["e" + type + fn](window.event); }
            obj.attachEvent("on" + type, obj[type + fn]);
        }
    }
};
JSTarget.addEvent(window, 'load', function() { JSTarget.init("rel", "warnonleave", ""); });