function GetDataStorage2(_key) {
    if (!Coherent.isAttached)
        return null;
    if (window.frameElement) {
        return window.top["datastorage"];
    }
    return datastorage;
}
function GetStoredData2(_key) {
    try {
        var Storage = GetDataStorage2();
        if (Storage) {
            var value = Storage.getData(_key);
            return value;
        }
    }
    catch (error) {
        return null;
    }
    return null;
}

function is_msfs_2024() {
    return SimVar.GetSimVarValue("ELEVATOR TRIM MAX","number") > 0.001 || SimVar.GetSimVarValue("L:FCR_WASM_ONLINE","number") > 0;
}

var is2024 = false;
RegisterViewListener("JS_LISTENER_DATASTORAGE", OnDataStorageReady2);
function OnDataStorageReady2() {

    if (window.document) {
        window.document.dispatchEvent(new Event("dataStorageReady"));
    }
    is2024 = is_msfs_2024();
    let zut = SimVar.GetSimVarValue("ATC MODEL", "string") + "::" + "Global" + "::" + "PMS50_GTN750_SDK_VERSION";
    let toto = GetStoredData2(zut);
    if(is2024 && toto != "2020") {
        Include.addScript("/Pms50/gtn750/Pages/VCockpit/Instruments/Shared/WT/v2/2024/msfssdk.js");
        Include.addScript("/Pms50/gtn750/Pages/VCockpit/Instruments/Shared/WT/v2/2024/garminsdk.js");
    }
    else {
        Include.addScript("/Pms50/gtn750/Pages/VCockpit/Instruments/Shared/WT/v2/msfssdk.js");
        Include.addScript("/Pms50/gtn750/Pages/VCockpit/Instruments/Shared/WT/v2/garminsdk.js");
    }
    Include.addScript("/Pms50/gtn750/Pages/VCockpit/Instruments/Shared/WT/v2/WTT1.js");
}
