$(function() {
  var doc = $(document);
  doc.find('a[href="' + window.location.pathname + '"]').addClass('state-selected');
  doc.delegate('a.cancel-back', 'click', function(event) {
    event.preventDefault();
    history.back();
  });
  doc.delegate('a[href^="http"]', 'click', function(event) {
    event.preventDefault();
    var anchor = $(this);
    $('<p>You are now leaving the PENSCO Trust Company web site. The information and links on the web page you are about to visit is not part of, under control of, or the responsibility of PENSCO Trust Company or PENSCO, LLC.  This link is being provided as a convenience and is not intended to imply endorsement by PENSCO Trust Company or PENSCO, LLC.</p>').dialog({
      resizable: false,
      draggable: false,
      modal: true,
      width: 500,
      buttons: {
        "I Agree": function() {
          $( this ).dialog( "close" );
          window.open(anchor.attr('href'), '_blank');
        },
        Cancel: function() {
          $( this ).dialog( "close" );
        }
      }
    });
  });
  
  if (LOGGED_IN) {
    $('body').addClass('state-logged-in');
  }
  else {
    $('body').addClass('state-logged-out');
  }
});
