
$(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 about to leave the <strong>Multiplex</strong> website and view the content of an external website:- <br><br> <strong>'+(link)+'</strong> <br><br>  <strong>Multiplex</strong> cannot be held responsible for the content of external websites, are you sure you want to proceed?</div>').dialog({
      title: "External Link",
      modal : true,
      overlay: {
        backgroundColor: '#000',
        opacity: 4.5,
		zIndex: 12000
      },
      buttons: {
        'Okay': function() {
          $(this).dialog('close').remove();
          window.open(link);
        },
        'Cancel': function() {
          $(this).dialog('close').remove();
          return false;
        }
      }
    });
 
    return false;
  });
});
