﻿/* ******************************************** *\
|*                                              *|
|*          WReport manager javascript          *|
|*                                              *|
\* ******************************************** */

WReportManager = function() {
}

WReportManager.Register = function(section, subSection, content, profile) {
    if (!Environment.WReportEnabled) {
        return;
    }

    var rSection = (section) ? section : WRP_SECTION;
    var rSubSection = (subSection) ? subSection : WRP_SUBSECTION;
    var rContent = (content) ? content : WRP_CONTENT;

    if (Environment.DebugMode) {
        var profil = "";
        if (profile) {
            for (var i = 0; i < profile.length; i++) {
                if (profil != "") {
                    profil += "|";
                }
                profil += profile[i].key + ":" + profile[i].name;
            }
        }

        alert("[DEBUG] wreport_register("
            + "GroupId: " + WEBO_ID_GROUPE
            + ", SiteId: " + WRP_ID
            + ", Section=" + rSection
            + ", SubSection: " + rSubSection
            + ", Frame: " + WRP_ACC
            + ", Channel: " + WRP_CHANNEL
            + ", GrpSection: " + WRP_SECTION_GRP
            + ", GrpSubSection: " + WRP_SUBSECTION_GRP
            + ", Content: " + rContent
            + ", Profile: " + profil
            + ", Cookie: off)");
    }
    else {
        //Create WReport counter...
        var w_counter = new wreport_counter(rSection, rSubSection, WRP_ID, WRP_ACC, WRP_CHANNEL, WRP_SECTION_GRP, WRP_SUBSECTION_GRP);
        if (rContent) {
            w_counter.add_content(rContent);
        }
        w_counter.profiling_cookie_mode = 'off';
        if (profile) {
            for (var i = 0; i < profile.length; i++) {
                w_counter.add_profile(profile[i].key, profile[i].name);
            }
        }
        w_counter.count();
    }

    return true;
}
