/* 
 * @author _apinek
 * @version 2.0
 * 
 * SWAL https://limonte.github.io/sweetalert2/
 */

if (typeof isDebugMode !== 'undefined') {
    isDebugMode = 1;
} else {
    isDebugMode = 0;
}

var i18n = [];
var siteMode = '';

function __(text) {
/* i18n to DB */    
//    if (i18n[text] === undefined) {
//        return text;
//    } else {
//        return i18n[text];
//    }
    if (i18n[text]['translated'] === undefined) {
        return text;
    } else {
        return i18n[text]['translated'];
    }
}

function load_i18n() {
    $.ajax({
        url: "_ajax/i18n4js.ajax.php",
        data: {},
        type: 'POST',
        dataType: 'json',
        success: function (data) {
            i18n = data.i18n_js;
        },
        error: function (jqXHR, textStatus, errorThrown) {
            swal_error('obs_0001', '', JSON.stringify(jqXHR));
        }
    });
}

function swal_error(title, html, debugInfo) {
    if (!isDebugMode) {
        swal({'title': "Error : " + title, 'html': html, 'type': 'error'});
    } else {
        swal({'title': "Error : " + title, 'html': debugInfo, 'type': 'error'});
    }
}

