// marquage Google Analytics - parametrage par ga chez resoneo.com
// syntaxe de base
var _gaq = _gaq || [];
var resoneo_gact = new r_gact();
// fonctions utilitaires
function lienSortant(lien) {
  var _gA = lien.href.split('/');
  var _gS = lien.href.split('#');
  var _gT = '/_lien-sortant/' + _gA[2] + '/?d=' + _gS[0];
  _gaq.push(['_trackPageview',_gT]);
  _gaq.push(function() {
      try {
          setTimeout('window.open(_gat._getTrackerByName()._getLinkerUrl(\'' + lien.href + '\',false),\'_blank\')', 100);
      } catch(err) {
          window.open(lien.href, '_blank'); // preserve le fonctionnement du lien href en cas de pb
      }
  });
}
function lienFichier(lien) { // lien vers les documents generiques
  var _gT = '/_lien-document/?f=' + lien.href + '#' + window.location.href;
  _gaq.push(['_trackPageview',_gT]);
  _gaq.push(['sp._trackPageview',lien.href]);
  setTimeout('window.open(\'' + lien.href + '\',\'_blank\')', 100);
}

function lienContrat(lien) { // lien vers les contrats generes pour chaque client
  var _gT = '/_lien-contrat/contrat?f=' + lien.title;
  _gaq.push(['_trackPageview',_gT]);
  _gaq.push(['sp._trackPageview',lien.href]);
  setTimeout('window.open(\'' + lien.href + '\',\'_blank\')', 100);
}

function lienCalque(lien) {
  var _gT = window.location.pathname + '?calque=' + lien.title;
  _gaq.push(['_trackPageview',_gT]);
}
function pushParameters(account, opt_name) {
  var prefix = opt_name ? opt_name + '.' : '';
  _gaq.push([prefix + '_setAccount', account]);
  // detection de moteurs de recherche additionnels (francophones, ...)
  _gaq.push(
          [ prefix + '_addOrganic', 'cuil','q',true],
          [ prefix + '_addOrganic', 'cluuz','q',true],
          [ prefix + '_addOrganic', 'mywebsearch','searchfor',true],
          [ prefix + '_addOrganic', 'gooofullsearch','Keywords',true],
          [ prefix + '_addOrganic', 'lo.st','x_query',true],
          [ prefix + '_addOrganic', 'alice','qs',true],
          [ prefix + '_addOrganic', 'news.google','q',true],
          [ prefix + '_addOrganic', 'voila','kw',false],
          [ prefix + '_addOrganic', 'aol','query',true],
          [ prefix + '_addOrganic', 'exalead','q',true],
          [ prefix + '_addOrganic', 'yauba','q',true],
          [ prefix + '_addOrganic', 'yougoo','q',true],
          [ prefix + '_addOrganic', 'hooseek','recherche',true],
          [ prefix + '_addOrganic', 'ecosia','q',true],
          [ prefix + '_addOrganic', 'vizzeo','q',true],
          [ prefix + '_addOrganic', 'wibeez','q',true],
          [ prefix + '_addOrganic', 'veosearch','q',true],
          [ prefix + '_addOrganic', 'incredimail','q',true],
          [ prefix + '_addOrganic', 'sweetim','q',true],
          [ prefix + '_addOrganic', 'conduit','q',true],
          [ prefix + '_addOrganic', 'searcheo','q',true],
          [ prefix + '_addOrganic', 'babylon','q',true],
          [ prefix + '_addOrganic', 'imesh','q',true],
          [ prefix + '_addOrganic', 'fastbrowsersearch','q',true],
          [ prefix + '_addOrganic', 'magentic','q',true],
          [ prefix + '_addOrganic', 'search.free.fr','q',true],
          [ prefix + '_addOrganic', 'vizzeo','q',true],
          [ prefix + '_addOrganic', 'bluewin.ch','searchTerm',true],
          [ prefix + '_addOrganic', 'google','as_q',true]);
  _gaq.push([prefix + '_setAllowAnchor', true]);
  _gaq.push([prefix + '_setAllowHash', false]);
  _gaq.push([prefix + '_setAllowLinker', true]);
}
// Environnement de production
pushParameters('UA-19259368-1', 'sp');         // identifiant du compte specifique
pushParameters('UA-8203615-1', '');            // identifiant du compte consolide, par defaut
_gaq.push(['_gat._anonymizeIp']);
// valeur par defaut de la page : basee sur l'url
var page = document.location.pathname + document.location.search + document.location.hash;
// supprime index.php pour la home
page = page.replace('/index.php', '/');
_gaq.push(['_trackPageview',page]);
_gaq.push(['sp._trackPageview']);
// Matriceo Tracking
_gaq.push(function() {
  try {
      resoneo_gact.receiver();
      resoneo_gact.trackSource();
  } catch(err) {
  }
});

// en production
var scriptUrl = '.google-analytics.com/ga.js';

(function() {
  var ga = document.createElement('script');
  ga.type = 'text/javascript';
  ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + scriptUrl;
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(ga, s);
})();
