$(document).ready(function() {


    // Navigation use - teaser
    $('.teaser-link a').click(function() {
      _gaq.push(['_trackEvent', 'Navigation use > Teasers clicks', $(this).attr('href'), window.location.pathname]);
    });
    
    // Navigation use - home links
    $('.logo a').click(function() {
      _gaq.push(['_trackEvent', 'Navigation use > Home buttons clicks', 'Libratone logo', window.location.pathname]);
    });
    $('.red-label a').click(function() {
      _gaq.push(['_trackEvent', 'Navigation use > Home buttons clicks', 'Red label icon', window.location.pathname]);
    });


   
    // FAQ ancher-links (#faq1 to #faqx)
    $('h2.faq a').click(function() {
      var $a = $(this);
      var href = $a.attr('href');
      _gaq.push(['_trackEvent', 'Link categories > FAQ ancher links clicks', window.location.pathname, href + ': ' + $a.text() ]);
    });
    
    // Outbound links
    $('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'];
    $('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]);
      }
    });    
  
    // Social media    
      // Footer left side links to Facebook and Twitter
      $('footer .facebook a, footer .twitter a').click(function() {
        _gaq.push(['_trackEvent', 'Social media > Outbound clicks (footer)', $(this).attr('href'), window.location.pathname]);
      });
      // Foorter right side element to share to Facebook, Twitter and email
      $('footer .share-content a').click(function() {
        _gaq.push(['_trackEvent', 'Social media > Share this page clicks (footer)', $(this).text(), window.location.pathname]);
      });


    
    


});
