$(document).ready(function() {

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

$('a:not([href^="http://www.mopdogweb.com/_beta/flbtest"]):not([href^="http://www.firstlandmarkonline.com"]):not([href^="#"]):not([href^="/"]):not([href^="mailto:"]):not([href^="http://ca.hostbyweb.net"]):not([href^="https://ns.bankbyweb.net"]):not([href^="index.php"])').addClass('external');

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

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

    $('<div>By clicking \'Okay\' you will be transferred to a web site not controlled by First Landmark Bank. First Landmark Bank is not responsible for any of the info or services provided by this web site. The web site you are about to access is not covered by First Landmark Bank\'s privacy policy or security statement. <br /> <strong>Are you sure you want to proceed?</strong></div>').dialog({
      title: "External Link",
      modal : true,
      overlay: {
        backgroundColor: '#000',
        opacity: 0.5
      },
      buttons: {
        'Okay': function() {
          $(this).dialog('close').remove();
          window.open(link);
        },
        'Cancel': function() {
          $(this).dialog('close').remove();
          return false;
        }
      }
    });

    return false;
  });
});
