﻿var _gaq;
analytics = function () {
    var a;
    var ref;
    this.gainit = function (account) {
        _gaq = _gaq || [];
        _gaq.push(['_setAccount', account]);
        _gaq.push(['_trackPageview']);
        this.a = account;
        this.ref = _gaq;
    }
    this.gaload = 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);
    }
    this.googleordertrack = function (orderid, rootpath, undefined) {
        var el = document.getElementById("ifrm_ecweb");
        if (el == undefined) {
            el = document.createElement("iframe");
            el.setAttribute('id', 'ifrm_ecweb');
            el.style.height = 1 + 'px';
            el.style.width = 1 + 'px';
            document.body.appendChild(el);
        }
        el.setAttribute('src', rootpath + '/modules/googleanalytical/ecgoogletrack.ashx?a=' + this.a + '&orderid=' + orderid);
    }
    this.googletrackpageview = function (pagepath, undefined) {
        if (_gaq == undefined) {
            _gaq = this.ref;
        }
        _gaq.push(['_trackPageview', pagepath]);
    }
    this.init = this.gainit;
    this.load = this.gaload;
    this.ecordertrack = this.googleordertrack;
    this.ecpagetrack = this.googletrackpageview;
};
var eca = new analytics();

