var CONTEXTPATH = CONTEXTPATH || "";

(function ($) {
    var url = CONTEXTPATH + '/log/userVisit.mooc?';
    var p = {};

    var cookies = {};
    var cookies = document.cookie.split('; ');
    for (var i = 0; i < cookies.length; i++) {
        var split = cookies[i].split('=');
        cookies[split[0]] = unescape(split[1]);
    }

    p.vk = cookies["moocvk"] || "";

    //var key = new UUID().id.toLowerCase();
    //p.vs = key;

    p.ds = (window.screen.width || 0) + "x" + (window.screen.height || 0);
    p.dc = window.screen.colorDepth || 0;
    p.cs = navigator.cookieEnabled ? 1 : 0;
    p.js = navigator.javaEnabled() ? 1 : 0;
    p.ln = navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage || "";
    p.ua = (new Base64()).encode(navigator.userAgent);
    p.vu = location.href;

    var fv = "";
    if (navigator.plugins && navigator.mimeTypes.length) {
        var s = navigator.plugins["Shockwave Flash"];
        s && s.description && (fv = s.description.replace(/^.*\s+(\S+)\s+\S+$/, "$1"))
    } else if (window.ActiveXObject)
        try {
            var s = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            s && (fv = s.GetVariable("$version")) && (fv = fv.replace(/^.*\s+(\d+),(\d+).*$/, "$1.$2"))
        } catch (xa) {
        }
    p.fv = fv;

    var q = [];
    for (var k in p) {
        q.push(k + "=" + encodeURIComponent(p[k]));
    }
    url += q.join("&");

    $.ajax({
        type: 'get',
        url: url
    });
})($ || jQuery);