﻿$(document).ready(function() {
  // Creating custom :external selector
if(location.href.indexOf("auth") == -1){
  $.expr[':'].external = function(obj){

      return !obj.href.match(/^mailto\:/)

              && (!obj.href.match(/\.firemansfund/)
              // the obj.href.match(/""/) catches the 
              // clicks for web parts              
             // && !obj.href.match(/\/)
              && !obj.href.match(/javascript\:/)
              && !obj.href.match(/ffido.com/)
              && !obj.href.match(/ffic.com/)
              && !obj.href.match(/ifgbonds.com/))

  };


  // 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 Fireman\'s Fund Insurance Company Website.  Thank you for visiting our site.</div>').dialog({

      title: "Fireman's Fund Insurance Company",

      modal : true,

      overlay: {

        backgroundColor: '#000',

        opacity: 0.5

      },

      buttons: {

        'Close': function() {

          $(this).dialog('close').remove();

          return false;

        },

        'Continue': function() {

          $(this).dialog('close').remove();

          window.open(link);

        }


      }

    });


    return false;

  });
}
});
