﻿if (!window.Dba)
    window.Dba = {};

var _gaq = _gaq || [];

Dba.Analytics = {
    init: function() {
        var ga = document.createElement('script');
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        ga.setAttribute('async', 'true');
        document.documentElement.firstChild.appendChild(ga);

        _gaq.push(['_setAccount', 'UA-1352051-1']);
        _gaq.push(['_setDomainName', '.www9.dba.dk']);
        _gaq.push(['_setAllowHash', false]);
        _gaq.push(['_setAllowLinker', true]);
        _gaq.push(['_setCookieTimeout', 604800]);
        _gaq.push(['_setSessionTimeout', 3600]);
        _gaq.push(['_initData', true]);
    },

    trackClickEvent: function(category, label) {
        _gaq.push(['_trackEvent', category, 'click', label]);
    },

    trackViewEvent: function(category, label) {
        _gaq.push(['_trackEvent', category, 'view', label]);
    },
    trackPageView: function(virtualUrl) {
        _gaq.push(['_trackPageview', virtualUrl]);
        $(document).triggerHandler('analytics:ready');
    },
    setCustomVar: function(index, name, value, scope) {
        _gaq.push(['_setCustomVar', index, name, value, scope]);
    },
    deleteCustomVar: function(index) {
        _gaq.push(['_deleteCustomVar', index]);
    }
};
