/*
 * Google Analytics code embedding with host filtering
 */
// Global for Google Analytics to find it
var _gaq = _gaq || [];

(function() {
  var filteredHosts = [
    'aurora',
    'aurora-neu',
    'dtele.de', // Thus do not embed this way on dtele.de!
    '217.7.249.100'
  ];
  
  filteredHosts = '\0' + filteredHosts.join('\0');
  
  // Filter local embeds
  if (filteredHosts.indexOf('\0' + document.location.hostname) > -1) {
    return;
  }
  
  // Make sure Google Analytics account was set properly
  if (!gaAccount || !/UA-[0-9]+-[0-9]+/.test(gaAccount)) {
    alert('Bitte Google-Analytics-Account mit der Variable "gaAccount" ' +
          'im Format "UA-XXXXXXXX-X" festlegen!');
    return;
  }

  // Actual Google Analytics code
  _gaq.push(['_setAccount', gaAccount]);
  _gaq.push(['_gat._anonymizeIp']);
  _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);
  })();
})();
