﻿var _translationCache = {};
function GetTranslation(key) {
	if (_translationCache[key] != null && typeof (_translationCache[key]) != 'undefined') {
		return _translationCache[key];
	}
	var text = jQuery.ajax({
		url: _baseUrl + "Handlers/TranslationHandler.ashx?key=" + key,
		async: false
	}).responseText;

	_translationCache[key] = text;

	return text;
}

function SaveTranslation(keyID) {
    jQuery.getJSON(_baseUrl + 'Admin/Translation/TranslationKeyHandler.ashx',
    {
        m: 'savekey',
        languageKeyID: keyID,
        keyContent: jQuery('#tbTranslationContent').val(),
        commentContent: jQuery('#tbTranslationComment').val(),
        nocache: new Date().getTime()
    },
    function (data) {
        if (data.success == true) {
            window.location.href = window.location.href;
        }
        else {
            new ErrorDialog('', '', {});
        }
    });
}

function FacebookLogout() {
    try {
        var fbWorks = false;

        FB.getLoginStatus(function (response) {
            fbWorks = true;
            if (response.session) {
                // logged in and connected user, someone you know
                FB.logout(function (response) {
                    // user is now logged out
                    jQuery('#lbLogout').click();
                });
            } else {
                // no user session available, someone you dont know
                jQuery('#lbLogout').click();
            }
        });

        if (!fbWorks) {
            jQuery('#lbLogout').click();
        }
    }
    catch (err) {
        jQuery('#lbLogout').click();
    }
}
