$(document).ready(function() {

    // G/A search stats
    $('a.fulltextsearch_titlelink').click(function() {
      _gaq.push(['_trackEvent', 'Livesearch-SearchResultClick', $('#qPhrase').text() , $(this).attr("href") , parseInt($(this).attr("id").substring(6))]);
    });
    $('.searchBreadcrumbs a').click(function() {
      _gaq.push(['_trackEvent', 'Livesearch-BreadcrumbsClick', $('#qPhrase').text() , $(this).attr("href")]);
    });
    
    // Footer links
    $('.footer a').click(function() {
      var $a = $(this);
      var href = $a.attr('href');
      _gaq.push(['_trackEvent', 'Navigation use > Footer clicks', href, window.location.pathname]);
    });
    
    // Outbound links
    $('.content a').click(function() {
      var $a = $(this);
      var href = $a.attr('href');
      if ( (href.match(/^http/)) && (! href.match(document.domain)) ) {     
        _gaq.push(['_trackEvent', 'Navigation use > Outbound clicks', href, window.location.pathname]);
      }
    });
    // File downloads
    var fileTypes = ['docx','xlsx','doc','xls','pdf','zip'];
    $('.content a').click(function() {
      var $a = $(this);
      var href = $a.attr('href');
      var hrefArray = href.split('.');
      var extension = hrefArray[hrefArray.length - 1];
      if ($.inArray(extension,fileTypes) != -1) {
        _gaq.push(['_trackEvent', 'File downloads', href, '"' + $a.text() + '" from ' + window.location.pathname]);
      }
    });    
  



});
