var gaSettings = {
  disableStr : 'ga-disable-UA-530425-3',
  gaOptOutFeedbackText : '<b style="color:red">-- Das Tracking durch Google Analytics wurde in Ihrem Browser für diese Website deaktiviert --</b>'
};
 
function gaOptout(gaSettings) {
  document.cookie = gaSettings.disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
    window[gaSettings.disableStr] = true;
}
 
function gaOptOutFeedback(gaSettings) {
  var gaDomainName = document.getElementById('gaDomainName'),
      gaOptOutDom = document.getElementById('gaOptOutDom'),
      gaOptOut = document.getElementById('gaOptOut'),
      gaOptOutFeedback = document.getElementById('gaOptOutFeedback'),
      newDomainName = document.createElement('span'),
      newFeedbackText = document.createElement('span');
 
  newDomainName.setAttribute('id', 'gaDomainName');
  newDomainName.innerHTML = ' : <a href="' + window.location.origin + '">' + window.location.origin + '</a>';
  
    newFeedbackText.setAttribute('id', 'gaOptOutFeedback');
    newFeedbackText.setAttribute('class', 'gaOptOutFeedback');
    newFeedbackText.innerHTML = ' ' + gaSettings.gaOptOutFeedbackText;
 
                
  if (gaDomainName !== null){
      gaDomainName.remove();
    }
  if (gaOptOutFeedback !== null){
      gaOptOutFeedback.remove();
  }
  
  gaOptOutDom.insertAdjacentElement('afterend', newDomainName);
  gaOptOut.insertAdjacentElement('afterend', newFeedbackText);
 
}
 
 
document.getElementById('gaOptOut').addEventListener('click', function () {
    gaOptout(window.gaSettings);
    gaOptOutFeedback(window.gaSettings);
});
 
if (document.cookie.indexOf(window.gaSettings.disableStr + '=true') > -1) {
    window[window.gaSettings.disableStr] = true;
    gaOptOutFeedback(window.gaSettings);
}
