$(document).ready(function() {
  // Creating custom :external selector

  $.expr[':'].external = function(obj){

      return !obj.href.match(/^mailto\:/)

              && (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 now leaving the Department of Homeland Security webpage,<br />and headed towards: '+(link)+' <br /><br /> Are you sure you want to proceed?</div>').dialog({

      title: "EXTERNAL LINK",

      modal : true,
	  
	  width : 450,

      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;

  });

});
