dojo.require('pepper.util.OnLeave');

dojo.addOnLoad(function() {
    // onLeave popup
    var familySites = [
        'abbott.com', 'abbottdiabetescare.com', 'abbottincalifornia.com', 'abbottinvestor.com',
        'myfreestyle.com', 'smartmanual.biz', 'abbott-diabetes-care.at', 'abbott-diabetes-care.ch',
        'abbott-diabetes-care.de', 'abbott-diabetescare.pl', 'abbott-diabetes.se', 'abbott.co.in',
        'abbott.co.jp', 'abbott.co.kr', 'abbott.co.th', 'abbott.com.cn', 'abbott.com.hk',
        'abbott.com.my', 'abbott.com.ph', 'abbott.com.pk','abbott.com.sg', 'abbott.com.tw',
        'abbott.dk', 'abbottdiabetes.com.br', 'abbottdiabetescare.be', 'abbottdiabetescare.ca',
        'abbottdiabetescare.com.ar', 'abbottdiabetescare.com.au', 'abbottdiabetescare.cz',
        'abbottdiabetescare.dk', 'abbottdiabetescare.es', 'abbottdiabetescare.ie',
        'abbottdiabetescare.nl', 'abbottdiabetescare.pt', 'abbottdiabetescare.ru', 'diabetesnow.co.uk',
        'endocrineindia.com', 'logaland.is', "{same}", 'akamai.com', 'freestylenavigator.com', 'precisionoptiuminfo.com'
    ];

    var externalLinkMessage = ([
        '<p>Notice</p>',
        '<p>The "Yes" link below will take you out of the Abbott Laboratories family of websites.</p>',
        '<p>Links which take you out of Abbott Laboratories worldwide web sites are not under the control of Abbott Laboratories,  and Abbott Laboratories is not responsible for the contents of any such site or any further links from such site. Abbott Laboratories is providing these links to you only as a convenience,  and the inclusion of any link does not imply endorsement of the linked site by Abbott Laboratories.</p>',
        '<p>Do you wish to leave this site?</p>',
        '<div class="absolute-wrapper"><p class="confirmation-doc-id">DOC08973-Rev-A 12/06</p></div>'
    ]).join('');

    var baseURL = 'http://' + document.domain + '/';

    // Set up the normal on-leave dialog
    ol = new pepper.util.OnLeave({
        content: externalLinkMessage,
        hostLacks: familySites,
        title: 'Exit AbbottDiabetesCare.com',
        type: 'popup',
        width: 420,
        height: 280,
        stay: '<img src="' + (dojo.isIE && dojo.isIE < 8 ? baseURL : '') + '/static/images/no.gif"/>',
        go: '<img src="' + (dojo.isIE && dojo.isIE < 8 ? baseURL : '') + '/static/images/yes.gif"/>',
        newWindow: true
    });

    // confirm US popup
    var sites = [
        'products-data-management-systems.html',
        '/copilot-health-management-system.html'
    ];

    var externalConfirmMessage = ([
        '<p><strong>The product-specific Internet site that you have requested is intended for residents of the United States.</strong></p>',
        '<p>As a result, the site may contain information on pharmaceuticals, medical devices, and other products or uses of those products that are not approved in other countries or regions. If you are a resident of a country other than the United States, please return to Abbott.com or contact your local Abbott affiliate to obtain the appropriate product information for your country of residence.</p>',
        '<p>Are you a resident of the United States?</p>',
        '<div class="absolute-wrapper"><p class="confirmation-doc-id"><br>DOC20188-Rev-B 03/11<br></p>',
        '<p class="confirmation-center"><a href="javascript:window.close()">close window</a></p></div>'
    ]).join('');

    // Set up the normal on-leave dialog
    var ol2 = new pepper.util.OnLeave({
        content: externalConfirmMessage,
        pathContains: sites,
        title: 'Data Management System',
        type: 'popup',
        width: 440,
        height: 360,
        stay: '<img src="' + (dojo.isIE && dojo.isIE < 8 ? baseURL : '') + '/static/images/no.gif"/>',
        go: '<img src="' + (dojo.isIE && dojo.isIE < 8 ? baseURL : '') + '/static/images/yes.gif"/>',
        redirectTo: '/worldwide-locations.html'
    });
});



