﻿/*
jquery confirmation dialog - use for links that go outside the cpbank site
author: Lisa Way
last updated: 1/13/2010

Include the following on the calling page (it's already in Universal.Master):
    <link href="../_css/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script src="../_javascript/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>

Exmaple use:
    $(document).ready(function() {
        prepareHotlink("#IAgree", "http://www.fdic.gov/deposit/deposits/insured/index.html");
    }
    <p><a href="http://www.fdic.gov/deposit/deposits/insured/index.html" onclick="javascript:return confirmHotlink('#IAgree', 'googleAnalyticsAction')">http://www.fdic.gov/deposit/deposits/insured/index.html</a></p>
    <div id="IAgree" title="Third Party Site Disclaimer"></div>
*/

function prepareHotlink(id, url, content, buttonSet) {
    if (!content) var content = "You are now leaving the Capital Pacific Bank website. The link you selected is an external website hosted by another party and is not protected by our Privacy Policy. Capital Pacific bank holds no responsibility for any external websites. We neither endorse the information, content, presentation, or accuracy nor make any warranty, expressed or implied, regarding any external website. Press Accept to proceed, or Decline to stay on the Capital Pacific Bank website.";
    $(id).html(content);
    if (!buttonSet) var buttonSet = 1;
    switch (buttonSet) {
        case 1:
            $(id).dialog({
                autoOpen: false,
                bgiframe: true,
                resizable: false,
                width: 520,
                modal: true,
                closeOnEscape: true,
                overlay: {
                    backgroundColor: '#000',
                    opacity: 0.85
                },
                buttons: {
                    'Accept': function() { window.location = url; },
                    'Decline': function() { $(this).dialog('close'); }
                }
            });
            break;
            
        case 2:
            $(id).dialog({
                autoOpen: false,
                bgiframe: true,
                resizable: false,
                width: 520,
                modal: true,
                closeOnEscape: true,
                overlay: {
                    backgroundColor: '#000',
                    opacity: 0.85
                },
                buttons: {
                    'Continue': function() { window.location = url; },
                    'Return': function() { $(this).dialog('close'); }
                }
            });
            break;
    }
}

function confirmHotlink(id, googleAnalyticsAction) {
    $(id).dialog('open');
    _gaq.push(['_trackEvent', 'OffsiteLinks', googleAnalyticsAction]); // Google Analytics event tracking
    return false;
}

function prepareDialogBox(id, url, content, myWidth) {
    if (!myWidth) var myWidth = 520;

    $(id).html(content);
    $(id).dialog({
        autoOpen: false,
        bgiframe: true,
        resizable: false,
        width: myWidth,
        modal: true,
        closeOnEscape: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.85
        },
        buttons: {
        'OK': function() { if (url) window.location = url; else $(this).dialog('close'); }
        }
    });
}

