function switchLanguage()
{
    __currentLangIndex__ = document.getElementById("lang").value;
    updateLanguage(__currentLangIndex__);
}

function updateLanguage(index)
{
    if(desiteAPI.checkIfFileExists(__projectDirectory__ + __lang__[index].href))
    {
        var language = desiteAPI.readTextFileAsString(__projectDirectory__ + __lang__[index].href, "UTF-8");
        var vList = JSON.parse(language).value;
        for(var i=0; i< vList.length; i++)
        {
            if(document.getElementById("txt-"+i))
            {
                if(document.getElementById("txt-"+i).type == "button")
                {
                    document.getElementById("txt-"+i).value = vList[i].txt;
                } 
                else
                {
                    document.getElementById("txt-"+i).innerHTML = vList[i].txt;
                }
            }
        }
    }
    else
    {
        var language = desiteAPI.readTextFileAsString(__projectDirectory__ + __lang__[0].href, "UTF-8");
        var vList = JSON.parse(language).value;
        for(var i=0; i< vList.length; i++)
        {
            if(document.getElementById("txt-"+i))
            {
                if(document.getElementById("txt-"+i).type == "button")
                {
                    document.getElementById("txt-"+i).value = vList[i].txt;
                } 
                else
                {
                    document.getElementById("txt-"+i).innerHTML = vList[i].txt;
                }
            }
        }
    }
    _tp_configFilePath = __projectDirectory__ + __lang__[index].intern;
    if(desiteAPI.checkIfFileExists(_tp_configFilePath))
    {
        configJSONStr = desiteAPI.readTextFileAsString(_tp_configFilePath, "UTF-8");
        __internal__ = JSON.parse(configJSONStr).value;    
    }
    else
    {
        _tp_configFilePath = __projectDirectory__ + __lang__[0].intern;
        configJSONStr = desiteAPI.readTextFileAsString(_tp_configFilePath, "UTF-8");
        __internal__ = JSON.parse(configJSONStr).value;
    }
    globalModelName = __internal__[0].txt;
    globalDTMFolder = __internal__[1].txt;
    globalCeilingFolder = __internal__[2].txt;
    globalRoofFolder = __internal__[3].txt;
    openCloseDetails();
    executeOpen();
    saveConfig();
}