var _commonHash = { rusDCselected: true }; var State = function () { return this; }; State.Obj = State.prototype = { locale: { _languageId: undefined, _currencyId: undefined, isDefined: function () { return this._languageId || this._currencyId }, getLanguage: function () { return jm.Data.DbCache.Language.GetById(this._languageId); }, getCurrency: function () { return jm.Data.DbCache.Currency.GetById(this._currencyId); }, chargeToRub: function (amount, currencyId) { var currency = jm.Data.DbCache.Currency.GetById(currencyId); return jm.Math.Round(currency.ConvertToRub(amount), 2); } } }; var _state = new State(); var _lang_curr = { isLangMD: false, isCurrMD: false, bmd: function () { if (!_lang_curr.isLangMD) _lang_curr.closeLang(); else _lang_curr.isLangMD = false; if (!_lang_curr.isCurrMD) _lang_curr.closeCurr(); else _lang_curr.isCurrMD = false; }, showLang: function () { var div = jm.el("header_Lang_div"), divL = jm.el("header_LangL_div"), currBtn = jm.el("header_CurrBtn_div"); if (!div) return; if (divL.innerHTML == "") { var html = '', ru = jm.Data.DbCache.Language.GetByCode("ru"), en = jm.Data.DbCache.Language.GetByCode("en"); if (ru && ru._isActive) html += '
Русский
'; if (en && en._isActive) html += '
English
'; if (html == "") return; divL.innerHTML = html; } div.style.marginLeft = currBtn.style.display == "none" ? "109px" : "21px"; div.style.display = ""; div.className = "languages anim200l"; setTimeout(function () { div.style.opacity = 1; }, 20); }, closeLang: function () { var div = jm.el("header_Lang_div"); if (!div || div.style.display == "none") return; div.style.opacity = 0; setTimeout(function () { div.className = "languages"; div.style.display = "none"; }, 200); }, showCurr: function () { var div = jm.el("header_Curr_div"), divL = jm.el("header_CurrL_div"); if (!div || !divL) return; if (divL.innerHTML == "") { var html = '', rub = jm.Data.DbCache.Currency.GetByCode("rub"), uah = jm.Data.DbCache.Currency.GetByCode("uah"), usd = jm.Data.DbCache.Currency.GetByCode("usd"), eur = jm.Data.DbCache.Currency.GetByCode("eur"); if (rub && rub._isActive) html += '
RUB
'; if (uah && uah._isActive) html += '
UAH
'; if (usd && usd._isActive) html += '
$USD
'; if (eur && eur._isActive) html += '
EUR
'; if (html == "") return; divL.innerHTML = html; } div.style.display = ""; div.className = "currencies anim200l"; setTimeout(function () { div.style.opacity = 1; }, 20); }, closeCurr: function () { var div = jm.el("header_Curr_div"); if (!div || div.style.display == "none") return; div.style.opacity = 0; setTimeout(function () { div.className = "currencies"; div.style.display = "none"; }, 200); }, selLang: function (id) { var lang = jm.Data.DbCache.Language.GetById(id), div = jm.el("header_LangBtn_div"), divT = jm.el("header_LangT_div"); if (!lang || !lang._isActive || !div || !divT) return; switch(lang._code){ case "ru": divT.innerHTML = div.innerHTML = 'RUS'; break; case "en": divT.innerHTML = div.innerHTML = 'ENG'; break; } _lang_curr.closeLang() jm.Locale.LocaleBtnClick({ _languageId: id }); }, selCurr: function (id) { var curr = jm.Data.DbCache.Currency.GetById(id), div = jm.el("header_CurrBtn_div"), divT = jm.el("header_CurrT_div"); if (!curr || !curr._isActive || !div || !divT) return; if (_auth.user && _auth.user.paymentAccounts && _auth.user.paymentAccounts.length > 0 && !curr.SupportsPM(PaymentMethod.Autopayment)) { _controls.messageBox.show("Ошибка", "Для смены основной валюты аккаунта, пожалуйста, предварительно удалите все привязанные банковские карты", _controls.messageBox.button.ok, _controls.messageBox.icon.error, 600); _nav.updatePageLinks(); return; } divT.innerHTML = div.innerHTML = '' + curr._symbol + '' + curr._code.toUpperCase(); _lang_curr.closeCurr(); jm.Locale.LocaleBtnClick({ _currencyId: id }); } }; jm.Mouse.Subscribe.Add("lang_curr", [["MouseDown", _lang_curr.bmd]]);