/*
 * Ajoute le code Google Analytics asynchrone
 *
 */

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-896440-5']);
_gaq.push(['_trackPageview']);
      
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

//ajouté par pyg (juin 2011) : suivi des liens externes et des téléchargements

$(document).ready(function(){
    $("a[@href^='http://']:not(.noAutoLink)").addClass("offSite").bind('click keypress', function(event) {
            _gaq.push(['_trackEvent', 'outgoing','Click', $(this).attr("href")]);
    });
});

var fileTypes = ['doc','xls','pdf','mp3','iso','odt','zip','gz','epub'];		
$('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', 'Download','Click', $(this).attr("href")]);
  }

});

