function TrackPage(pageLabel, contextVals) {
    ShowEventInteraction(window.location.href, "PAGE", pageLabel, "", contextVals);
}

function TrackInput(fieldLabel, fieldValue, fieldParent) {
    ShowEventInteraction(window.location.href, "INPUT", fieldLabel, fieldValue, fieldParent);
}

function TrackAsset(assetID, area) {
    ShowEventInteraction(window.location.href, "ASSET", "Asset", assetID, area);
}

function TrackLink(targetURL, targetLabel, contextVals) {
    ShowEventInteraction(window.location.href, "CLICK", targetLabel, targetURL, contextVals);
}


function TrackCTABtn(thisBtn) {
    var contextVals = "ClickArea=CTA";
    var targetLabel;
    if (thisBtn.text)
        targetLabel = thisBtn.text;
    else
        targetLabel = thisBtn.innerText;
    var targetURL = thisBtn.href;
    ShowEventInteraction(window.location.href, "CLICK", targetLabel, targetURL, contextVals);
}


function TrackTNTRecipe(RecipeName) {
    PAGESOURCE = "TNT";
    var SrvCall = "current:s_t";
    ShowEventInteraction(window.location.href, "TNT", "Recipe", RecipeName, SrvCall);
}


function TrackUMP(assetID, actionType, contextVals) {
    var Context = "new:s_tl";
    if (contextVals != null)
        Context += ";" + contextVals;
    ShowEventInteraction(window.location.href, "UMP", actionType, assetID, Context);
}

function TrackAssetView(assetID, area) {
    TrackEventInteraction(window.location.href, "ASSETCLICK", "Asset", assetID, area);
}

function TrackFormSubmit(targetURL, targetLabel) {
    TrackEventInteraction(window.location.href, "FORMSUBMIT", targetLabel, targetURL, "");
}


function ShowEventInteraction(url, eventType, label, value, context) {
    _coreTrackEventInteraction(url, eventType, label, value, context, "", "false");
}

function TrackEventInteraction(url, eventType, label, value, context) {
    _coreTrackEventInteraction(url, eventType, label, value, context, "", "true");
}


function _coreTrackEventInteraction(url, eventType, label, value, context, omniCode, writetoDB) {
    var pageSource = "";
    if (typeof PAGESOURCE != "undefined")
        pageSource = PAGESOURCE;

    var market = "";
    if (typeof MARKET != "undefined")
        market = MARKET;

    var t_r = "";
    if (typeof T_R != "undefined")
        t_r = T_R;

    var t_c = "";
    if (typeof T_C != "undefined")
        t_c = T_C;

    try {
        var track = new RemoteMethod('Tracking.epi?kNtBzmUK9zU' + omniCode);
        track.MethodName = 'TrackEventInteraction';
        track.AddArguments(url, t_r, eventType, label, value, t_c, context, pageSource, market, writetoDB);
        track.Invoke();
    }
    catch (err) {
    }
}
