$(document).ready(function() {

  // Creating custom :external selector
  $.expr[':'].external = function(obj){
      return !obj.href.match(/^mailto\:/)
      		&& !obj.href.match(/^javascript\:/)
      		&& !obj.href.match("mcw1.synergentcorp.com")
            && (obj.hostname != location.hostname);
  };

  // Add 'external' CSS class to all external links
  $('a:external').addClass('external');

  $('.external').click(function() {
    var link = $(this).attr('href');

    $('<div>You are currently leaving the Changing Seasons FCU website. The credit union is not liable for the content or availability of linked web sites.<br /><br />Click \'OK\' to proceed.</div>').dialog({
      title: "Changing Seasons Federal Credit Union Privacy Policy",
      modal : true,
      width : 580,
      overlay: {
        backgroundColor: '#000',
        opacity: 0.5
      },
      buttons: {
        'OK': function() {
          $(this).dialog('close').remove();
          window.open(link);
        },
        'Cancel': function() {
          $(this).dialog('close').remove();
          return false;
        }
      }
    });

    return false;
  });
});
