// add to the footer as a <script> include
;(function($) {
  $.fn.track_event_and_link = function(domains) {
    var domains_regex = new RegExp(domains.join("|"));
    var current_hostname = window.location.hostname;
    var hostname_regex = new RegExp(current_hostname);
 
    return this.each(function() {
      // if hostname starts with http(s) or ftp, and doesn't match the current hostname
      if(/^(http|ftp|https):\/\//.test(this.href) && !(hostname_regex.test(this.href))) {
        $(this).click(function() {
          // tracking an outbound link click from current domain to link
          pageTracker._trackEvent('outbound-link', 'click', $(this).context.hostname, this.href);

          // is this going to a cross-domain link?
          if(domains_regex.test(this.href)) {
            pageTracker._link(this.href);
            return false;
          }
        });
      }
    });
  }
})(jQuery);

$(document).ready(function() {
  // list of apptix domains
  domains = new Array(
    "apptix.com",
    "apptix.net",
    "apptixvoice.com",
    "asp\-one.com",
    "asp\-one.org",
    "mailstreet.com",
    "mailstreet.net",
    "mi8.com",
    "sharepointsite.com",
    "sharepointsite.org",
    "hostaccount.com",
    "collaborationhost.net"
  );

  $("a[href]").not($("a[href^='https://cp.mailstreet.hostaccount.com']")).track_event_and_link(domains);
});


