function openInNewWindow(href, width, height, extpar, name) { var par = (extpar && extpar.toString().length) ? ',' + extpar : ''; var hl; if (width) par += ',width=' + width; if (height) par += ',height=' + height; name = !name ? '' : name.toString(); hl = window.open(href, name, 'status=yes' + par); if (!hl) alert('Please, enable POP-UPs'); return hl; } function openInNewWindowCentered(href, width, height, extpar, name) { if (!extpar) extpar = 'scrollbars=yes'; var w = (width && (screen.availWidth - 50) > width) ? width : screen.availWidth - 50; var h = (height && (screen.availHeight - 50) > height) ? height : screen.availHeight - 100; var x = (screen.availWidth) ? parseInt((screen.availWidth - w) / 2) : 100; var y = (screen.availHeight) ? parseInt((screen.availHeight - h) / 2) - 10 : 100; if (extpar && extpar.length) extpar += ','; extpar += 'left=' + x + ',top=' + y; var hl = openInNewWindow(href, w, h, extpar, name); return hl ? hl : false; } function SelectText (elementId) { var doc = document , text = doc.getElementById(elementId) , range, selection ; if (doc.body.createTextRange) { range = document.body.createTextRange(); range.moveToElementText(text); range.select(); } else if (window.getSelection) { selection = window.getSelection(); range = document.createRange(); range.selectNodeContents(text); selection.removeAllRanges(); selection.addRange(range); } } function getp(obj, prop) { return undef(obj[prop]) ? null : obj[prop]; } function olength(obj) { return Object.keys(obj).length; } function addzero(val, border) { if (typeof border == 'undefined') border = 10; return parseInt(val) >= border ? val : ('0' + val); } function undef(obj) { return typeof obj == 'undefined'; } function def(obj) { return !undef(obj); } function okeys(obj) { var s = []; for (var i in obj) s.push(i); return s; } function okeys_str(obj) { return stringit(okeys(obj)); } function stringit(obj) { return JSON.stringify(obj); } function clog(str) { console.log(str); } function jclog(obj) { clog(JSON.stringify(obj)); } function random_word(lnum) { var randomString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var maxpos = randomString.length - 1; if (!lnum) lnum = 10; var res = ''; for (var i = 0; i < lnum; i ++) { while ((cpos = Math.round(Math.random() * 100) - 1) > maxpos); res += randomString.charAt(cpos); } return res; } function trim(str) { return (typeof str == 'undefined') ? '' : str.replace(/^[ ]+/, '').replace(/[ ]+$/, ''). replace(/\r\n$/, '').replace(/\n$/, ''). replace(/^\r\n/, '').replace(/^\n/, ''); } function rtrim(str) { return str.replace(/[ ]+$/, ''); } function validate_email(email) { return email.toString().match(/^[-_A-Za-z0-9\+][A-Za-z0-9\+\._-]*[A-Za-z0-9\+_]*@([A-Za-z0-9]+([A-Za-z0-9-]*[A-Za-z0-9]+)*\.)+[A-Za-z]+$/) ? true : false; } function validate_login(login, f_strong) { if (!f_strong) { return login.toString().match(/^[A-Za-z0-9][A-Za-z0-9_-]{2,25}$/i) ? true : false; } else { return login.toString().match(/^[A-Za-z0-9][A-Za-z0-9_]{2,25}$/i) ? true : false; } } function validate_ip(testip, f_noparts) { var ip, i; if ((ip = testip.match(/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/)) || (ip = testip.match(/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.$/)) || (ip = testip.match(/^([0-9]{1,3})\.([0-9]{1,3})\.$/)) || (ip = testip.match(/^([0-9]{1,3})\.$/))) { if (f_noparts && ip.length < 5) return false; for (i = 1; i < ip.length; i++) if (ip[i] > 255) return false; } else return false; return true; } function validate_url(url) { return url.match(/http[s]*:\/\/.+/); } function str2color(str) { if (!str.match(/^rgb\([0-9]{1,3},[ ]*[0-9]{1,3},[ ]*[0-9]{1,3}\)$/)) return str; var res = '#'; var arr = str.match(/\(([0-9]{1,3})/); if (parseInt(arr[1]) < 16) res += '0'; res += parseInt(arr[1]).toString(16); arr = str.match(/,[ ]*([0-9]{1,3}),/); if (parseInt(arr[1]) < 16) res += '0'; res += parseInt(arr[1]).toString(16); arr = str.match(/([0-9]{1,3})\)/); if (parseInt(arr[1]) < 16) res += '0'; res += parseInt(arr[1]).toString(16); return res; } function listSelectedIndex(lst) { if (!lst || !lst.length) return -1; for (var i = 0; i < lst.length; i ++) if (lst[i].selected || lst[i].checked) return i; return -1; } function sboxValue(lst) { var i = listSelectedIndex(lst); return (i < 0) ? i : lst[i].value; } function setListboxOption(lst, val, f_noClear) { if (!val) return; for (var i = 0; i < lst.length; i ++) { if (lst[i].value.toString() == val.toString()) { lst[i].selected = true; lst.value = val; } else if (!f_noClear) lst[i].selected = false; } } function print_obj(obj, f_str) { var str = ''; var j = 0; for (var i in obj) { str += i + ' => '; eval ('str += obj.' + i); str += "\n"; if (j++ > 30) { alert(str); j = 0; str = ''; } } if (f_str) return str; if (str.length) alert(str); } function getEl(id) { return document.getElementById(id); } function getcookie(varName) { var clist = document.cookie.split(';'); if (!clist.length) return false; var separatorPos = 0; for(var k in clist) { separatorPos = clist[k].indexOf('='); if (separatorPos > -1 && trim(clist[k].substring(0, separatorPos)) == varName) return clist[k].substring(separatorPos + 1); } return false; } function setcookie(varName, varValue, expires) { var d = new Date(); d.setTime(expires); document.cookie = varName + '=' + varValue + '; expires=' + d.toGMTString(expires); } function SetSystemMessage(mes) { getEl('systemMessagesArea').innerHTML = mes; } function AddSystemMessage(mes) { getEl('systemMessagesArea').innerHTML += mes; } function elementOffsetTop(str) { return parseInt($(str).offset().top); } function traceCall() { var err = new Error(); return err.stack; } function js_escape(str) { return str.replace(/<.*script.*>/g, '(script)').replace(/<.*\/.*script.*>/g, '(/script)'); } function jescape(str) { return js_escape(str); } function str2html(str) { var v = $('
').text(str).html(); v = v.replace(/\[b\]/g, '').replace(/\[\/b\]/g, ''). replace(/\[i\]/g, '').replace(/\[\/i\]/g, ''). replace(/\[u\]/g, '').replace(/\[\/u\]/g, ''). replace(/\n/g, '
'); return v; } function html2str(str) { return str.replace(/
/g, "\n"). replace(//g, '[b]').replace(/<\/b>/g, '[/b]'). replace(//g, '[i]').replace(/<\/i>/g, '[/i]'). replace(//g, '[u]').replace(/<\/u>/g, '[/u]'); } function htmlit(str) { return typeof str == 'string' ? str.toString().replace(/"/g, '"').replace(//g, '>') : ''; } function textElementFocus(el) { el.focus(); v = $(el).val(); $(el).val('').val(v); } function showDialogRel(par) { el = par.obj; if (typeof el == 'string') el = $(el); el.show(); relObj = par.relObj; //offy = (offy ? offy : 0) + $(window).scrollTop(); //offx = (offx ? offx : 0) + $(window).scrollLeft(); el.css('left', parseInt($(relObj).offset().left + par.x)); el.css('top', parseInt($(relObj).offset().top + par.y)); } var pevents = function() { var self = this; }; pevents.onScrollList = {}; pevents.lastModalId = null; pevents.modals = []; pevents.modalShow = function (el, par, id) { if (typeof el == 'string') el = $(el); pevents.overClose(); if (typeof par == 'undefined') par = {}; if (this.modals.length) for (var i in this.modals) { this.modals[i].show = false; $(this.modals[i].id).hide(); } var mid = this.modals.length; this.modals.push({element: el, id: id, bgClickClose: true, show: true, onClose: null}); $('#modalBg').show(); $('#modalBg')[0].onclick = function(ev) { pevents.modalBgClick(); ev.stopPropagation(); }; $(el).show(); if (typeof par != 'undefined' && par.noBLankClick) this.modals[mid].bgClickClose = false; if (par && par.onClose) this.modals[mid].onClose = par.onClose; if (par.focus) $(par.focus).focus(); this.escapeAreas['modal'] = function() { if (!par.noEscape) pevents.modalClose() }; } pevents.fieldBlinkHl = function(fld, par) { if (typeof par != 'object') par = {}; if (!par.isBlinking) par.count = (!par.count ? 3 : par.count) * 2; par.isBlinking = true; if (par.count <= 0) { $(par).removeClass(cname); return; } var cname = par.class ? par.class : 'fieldBlinkHl'; if (!(par.count % 2)) $(fld).addClass(cname); else $(fld).removeClass(cname); par.count --; window.setTimeout(function() { pevents.fieldBlinkHl(fld, par); }, !par.period ? 300 : par.period); } pevents.modalBgClick = function() { for (var i in this.modals) if (this.modals[i].show && this.modals[i].bgClickClose) this.modalClose(this.modals[i].id); } pevents.modalClose = function(did) { var res = [], el; f_show = false; for (i in this.modals) { el = this.modals[i]; if (!did && el.show || did && el.id == did) { did = el.id; if (el.onClose) el.onClose(); this.modals[i].element.hide(); continue; } res.push(el); } if (res.length) { el = res[res.length - 1]; el.show = true; $(el.element).show(); } else { $('#modalBg').hide(); } this.modals = res; } pevents.slideBackgroundColor = function(par) { if (!par.current) par.current = par.max; if (!par.back) { while (par.current > par.min) { par.current -= par.step; //$(par.obj).css('background-color', '#' + par.current.toString(16)); $(par.obj).css('opacity', par.current); setTimeout(function() { pevents.slideBackgroundColor(par) }, 50); return; } par.back = true; } par.current += par.step; par.current = Math.min(par.current, par.max); //$(par.obj).css('background-color', '#' + par.current.toString(16)); $(par.obj).css('opacity', par.current); if (par.current >= par.max) return; setTimeout(function() { pevents.slideBackgroundColor(par) }, 50); } pevents.modalMessage = function(par) { if (typeof par != 'object') par = {message: par}; var darea = $('#messageDialog'); var tarea = darea.find('[eclass="title"]'); par.title && par.title.length > 0 ? tarea.show() : tarea.hide(); if (par.title && par.title.length) { tarea.find('span').html(par.title); if (par.closeIcon) tarea.find('img').show(); else tarea.find('img').hide(); } darea.find('[eclass="content"]').html(par.message); if (par.width && par.width > 0) darea.css('width', par.width + 'px'); if (par.textAlign) darea.find('[eclass="content"]').css('text-align', par.textAlign); this.modalShow('#messageDialog', par); } pevents.onWindowScroll = function() { if (!pevents.onScrollList) pevents.onScrollList = {}; for (i in pevents.onScrollList) if (typeof pevents.onScrollList[i] == 'function') pevents.onScrollList[i](); } pevents.dialogErrors = function (errors, form) { var d = null; if (typeof form != 'undefined') d = $(form); else for (var i in this.modals) if (this.modals[i].show) d = $(this.modals[i].id); if (!d) return; d.find('.dialog-messages').hide(); el = d.find('.dialog-errors'); el.hide(); if (!errors || !olength(errors)) return; el.show(); var s = ''; for (i in errors) s += '
' + (errors.length > 1 ? '• ' : '') + errors[i] + '
'; el.html(s); pevents.blinkEffect(el, 5); } pevents.blinkEffect = function(el, times) { if (times <= 0) { $(el).attr('blink', '0'); return; } $(el).attr('blink', pint($(el).attr('blink')) > 0 ? '0' : '1'); window.setTimeout(function() { pevents.blinkEffect(el, times - 1); }, 500); } pevents.dialogMessage = function (message) { var d = null; for (var i in this.modals) if (this.modals[i].show) d = $(this.modals[i].id); if (!d) return; d.find('div[eclass="errors"]').hide(); d.find('div[eclass="messages"]').show().html(message); } pevents.loaderCache = {js: {}, html: {}}; pevents.loader = {}; pevents.loaderTs = []; pevents.loadData = function(dname, cback) { if (!this.loader[dname]) { clog('ERROR (pevents.loadData): id #' + dname + ' not found!'); return false; } var edata = this.loader[dname]; if (edata.html && !this.loaderCache.html[edata.html]) pevents.loadHtml(edata.html, function() { $('#SYS_DATA_LOADER').append(pevents.loaderCache.html[edata.html]); pevents.loadData(dname, cback); }); else if (edata.js && !this.loaderCache.js[edata.js]) pevents.loadJS(edata.js, function() { pevents.loadData(dname, cback); }); else if (cback) cback(); } pevents.loadHtml = function(dname, cback) { $.get('/loader.html', {id: dname}, function(data) { console.log(data); if (data[dname].result == 1) { pevents.loaderCache.html[dname] = data[dname].html; cback(); } }, 'json').fail(function() { clog('ERROR (pevens.loadHtml): /loader.html?id=' + dname + ' FAILED'); }); } pevents.loadJS = function(sname, cback) { if (this.loaderCache.js[sname]) { if (cback) cback(); return; } var script = document.createElement('script'); document.head.appendChild(script); script.type = 'text/javascript'; var n = ''; for (var i in this.loaderTs) if (!this.loaderTs[i].name.localeCompare(sname)) n = this.loaderTs[i].lname; script.src = ('/scripts/' + (n = !n.length ? sname : n)).replace('//', '/'); script.onload = function() { pevents.loaderCache.js[sname] = true; if (cback) cback(); }; } pevents.showLoaderImg = function(aid, par) { if (!par) par = {}; this.currentLoaderArea = $(aid); this.currentLoaderArea.html(' 0 ? ' width="' + par.width + '"' : '') + (parseInt(par.height) > 0 ? ' height="' + par.height + '"' : '') + '>'); } pevents.hideLoaderImg = function(aid, par) { if (!par) par = {}; if (!aid) aid = this.currentLoaderArea; this.hideLoaderImgPar = par; if (par.ok) { $(aid).html(' 0 ? ' width="' + par.width + '"' : '') + (parseInt(par.height) > 0 ? ' height="' + par.height + '"' : '') + '>'); } if (!par.time) par.time = 2000; if (pevents.hideLoaderHl) clearTimeout(pevents.hideLoaderHl); pevents.hideLoaderHl = setTimeout(function() {pevents.hideLoaderImgCall({id: aid, d: parseInt(par.time / 20), cop: 0}) }, 1000); } pevents.hideLoaderImgCall = function(p) { op = Math.min(p.cop + 0.05, 1); var img = $(p.id).find('img'); p.cop = op; if (op >= 1) { img.hide(); return; } img.css('opacity', 1 - op); if (pevents.hideLoaderHl) clearTimeout(pevents.hideLoaderHl); pevents.hideLoaderHl = setTimeout(function() { pevents.hideLoaderImgCall(p);}, p.d); } pevents.get = {actions: {}, tid: 0, tstamp: 0, f_debug: false}; pevents.post = {}; pevents.post.query = function(action, par, cback, cbackErr) { return pevents.get.query(action, par, cback, cbackErr, 'post'); }; pevents.get.query = function(action, par, cback, cbackErr, method) { if (typeof par == 'undefined') par = {}; par.jaction = action; par.transactionId = ++this.tid; par.tstamp = this.tstamp; par.tstampms = new Date().getTime(); var func = typeof method != 'undefined' && method == 'post' ? $.post : $.get; func(par.url ? par.url : '', par, function(data) { if (this.f_debug) { jclog(stringit(data)); return; } this.resultData = data; this.tstamp = data.tstamp; if (data) for (act in data) if (typeof pevents.get.actions[act] != 'undefined' && typeof pevents.get.actions[act].func != 'undefined') pevents.get.actions[act].func(data[act], pevents.get.tid == data.transactionId); }, this.f_debug ? 'html' : 'json' ).fail(function(data) { if (this.f_admin) alert('SERVER ERROR: ' + data.responseText); if (typeof pevents.get.actions[action] != 'undefined' && typeof pevents.get.actions[action].funcErr != 'undefined') pevents.get.actions[action].funcErr(par); }); if (typeof cback != 'undefined') pevents.get.action(action, cback, cbackErr); } pevents.get.action = function(action, foo, fooErr) { this.actions[action] = { func: foo, funcErr: fooErr }; } window.onscroll = pevents.onWindowScroll; function centerBlock(el, offy, offx) { if (typeof el == 'string') el = $(el); if (el.css('display') == 'none') { return; } var offx = Math.max(0, parseInt(($(window).width() - el.innerWidth()) / 2)); var offy = Math.max(0, parseInt(($(window).height() - el.innerHeight()) / 2)); var sx = parseInt($(window).scrollLeft()); var sy = parseInt($(window).scrollTop()); el.css('left', x = offx + sx); el.css('top', y = offy + sy); } function joffset(el) { var e = $(el).offset(); for (var i in e) e[i] = parseInt(e[i]); return e; } var autoResizeHeightData = {}; function autoResizeHeight(id, aspect) { var el = $(id); if (!el.length) return; aspect = typeof aspect == 'undefined' ? parseFloat($(el).attr('aspect')) : aspect; var w; if (!(w = $(el).width())) { window.setTimeout(function() { autoResizeHeight(id, aspect); }, 1000); return; } var mwidth = parseInt($(el).css('max-width')); if (mwidth && w > mwidth) $(el).css('width', w = mwidth); var h = parseInt(w * aspect); $(el).css('height', h); if (autoResizeHeightData[id]) return; autoResizeHeightData[id] = {bind: true}; $(window).resize(function() { autoResizeHeight(id, aspect); }); } // ���������� ��������� stats = {}; stats.save = function(code, par, id) { $.get('/s.php', {code: code, par : (typeof par == 'undefined' ? '' : par), id : (typeof id == 'undefined' ? '' : id)}, function(data) { stats.result(data) }); }; stats.result = function(data) { } pevents.icheck = function(el, cback) { var nval = parseInt($(el).attr('check')) > 0 ? 0 : 1; var img = $(el).find('img'); nval ? img.show() : img.hide(); $(el).attr('check', nval); if (cback) cback(el); } pevents.checkbox = function(el, clicked) { //clog($(el).attr('check')); var f = !!parseInt($(el).attr('checked')); clog(f); return; if (typeof clicked == 'undefined') return f; el.attr('checked', f ? 0 : 1); return !f; } function addpar(url, par) { for (i in par) { eval(e = 'url = url.replace(/' + i.replace('[', '\\[').replace(']', '\\]') + '=[^&]*&*/, \'\');'); if (url.indexOf('?') >= 0) url += '&'; else url += '?'; url += i + '=' + par[i]; } return url; } function windowScrollTo(px) { $('html, body').animate({scrollTop: px}, 100); } function typeofval(el) { return (typeof el == 'function') ? el() : el; } pevents.overShow = function(el, eid, cback) { if (pevents.overHl) { window.clearTimeout(this.overHl); this.overHl = 0; } if (this.overId && this.overId.localeCompare(eid.toString())) $(this.overElement).hide(); this.overId = eid.toString(); this.overElement = el; if (typeof cback != 'undefined') this.overElement._onOverCloseCallback = cback; } pevents.overOut = function() { this.overHl = window.setTimeout(function() { pevents.overClose() }, 1000); } pevents.overStop = function() { this.overId = 0; if (this.overHl) window.clearTimeout(this.overHl); this.overHl = 0; this.overElement = ''; } pevents.overWait = function(el, eid) { this.overId = eid.toString(); this.overElement = el; this.overHl = window.setTimeout(function() { pevents.overClose() }, 3000); } pevents.overClose = function() { if (typeof this.overId != 'undefined' && this.overId.toString().length) { $(this.overElement).hide(); if (typeof this.overElement._onOverCloseCallback != 'undefined') this.overElement._onOverCloseCallback(); this.overHl = 0; this.overElement = ''; this.overId = 0; } } function cloneIt(a, level) { return jQuery.extend(true, {}, a); } function nl2br(s) { return s.replace(/\r\n/g, "\n").replace(/\n/g, '
'); } pevents.logout = function() { location.href="/logout.html"; } pevents.escapeAreas = {}; pevents.escapeHandler = false; function startEscHandler() { if (pevents.escapeHandler) return; if (!jQuery || !document.body) { window.setTimeout(function() { startEscHandler() }, 100); return; } pevents.escapeHandler = true; $(document.body).keydown(function(e) { if (e.which == 27 && olength(pevents.escapeAreas)) for (var i in pevents.escapeAreas) if (typeof pevents.escapeAreas[i] == 'function') pevents.escapeAreas[i](); else $(pevents.escapeAreas[i]).hide(); }); }; startEscHandler(); pevents.outClickHandlers = {}; pevents.outClickHandlerIsSet = false; pevents.outClickHandler = function(handler_name, el, func) { if (!this.outClickHandlerIsSet) { this.outClickHandlerIsSet = true; $('body').click(function() { pevents.outClickHandlerCheck(); }); } if (typeof this.outClickHandlers[handler_name] == 'undefined') $(el).click(function(ev) { ev.stopPropagation(); }); this.outClickHandlers[handler_name] = func; } pevents.outClickHandlerCheck = function() { for (var i in this.outClickHandlers) { this.outClickHandlers[i](); delete this.outClickHandlers[i]; } } pevents.outClickHandlerStop = function(handler_name) { delete this.outClickHandlers[handler_name]; } function eventSource(el, attr, val) { if (typeof val == 'undefined' && !$(el).attr(attr)) el = $(el).parents('[' + attr + ']'); else if (typeof val != 'undefined' && (!$(el).attr(attr) || $(el).attr(attr).localeCompare(val.toString()))) el = $(el).parents(a = '[' + attr + '="' + val + '"]'); if (el.length) el = el[0]; return el; } function minutes2str(m) { var ms = m; m = Math.abs(m); var res = (v = Math.floor(m / 60)) ? {hours: v, minutes: (m - v * 60)} : {hours: 0, minutes: m}; res = (res.hours ? (res.hours + _lang.abbr_hour) : '') + (res.minutes ? (res.minutes + _lang.abbr_minute) : ''); return ms > 0 ? res : ('-' + res); } pevents.eventOnChange = function(par, oldVal) { var el = par.object; if (typeof el == 'undefined' || typeof el.val == 'undefined') return; var hl, tout = typeof par.timeout == 'undefined' ? 100 : par.timeout; var currentValue = el.val(); if (typeof oldVal == 'undefined' || !oldVal.localeCompare(el.val())) { hl = setTimeout(function() { pevents.eventOnChange(par, currentValue) }, tout); return; } if (par.callback(el) != -1) this.eventOnChange(par); } function pint(i) { return isNaN(parseInt(i)) ? 0 : parseInt(i); } function pbool(i) { return (typeof i == 'undefined' || !i) ? false : true; } pevents.optionsPanel = null; pevents.showOptionsPanel = function(par) { if (this.optionsPanel) { this.optionsPanel._area.hide(); if (!par.id.localeCompare(this.optionsPanel.id)) { this.optionsPanel = null; return; } } var area = $(par.relativeTo).find('.optionsPanel'); if (!area.length) { var na = $(par.relativeTo).append('
'); area = $(par.relativeTo).find('.optionsPanel'); area.mouseover(function() { pevents.overShow(this, 'options_' + par.id, function() { pevents.closeOptionsPanel(); }) }); area.mouseout(function() { pevents.overOut() }); } if (typeof par.className != 'undefined' && !area.hasClass(par.className)) area.addClass(par.className); area.show(); if (typeof par.top != 'undefined') area.css('top', par.top); this.optionsPanel = par; this.optionsPanel._area = area; return area; } pevents.closeOptionsPanel = function() { if (!this.optionsPanel) return; this.optionsPanel._area.hide(); this.optionsPanel = null; pevents.overStop(); } pevents.elementMessage = function(el, f_show, mes) { if (f_show) { if (!el.find('.overMessage').length) { el.append('
'); el.append('
'); el.find('[close="1"]').click(function() { el.find('.overMessage').hide(); el.find('.overMessageBg').hide(); event.stopPropagation() }); } else { el.find('.overMessageBg').show(); el.find('.overMessage').show(); } el.find('.overMessage span').html(mes); } else { el.find('.overMessageBg').hide(); el.find('.overMessage').hide(); } } var _lang = {}; _lang.countStr = function(n, word) { n = n.toString(); var l, pl; if (n) { l = pint(n.substr(n.length - 1, 1)); pl = (n > 9) ? pint(n.substr(n.length - 2, 1)) : 0; } else l = 0; if (l >= 2 && l <= 4 && pl != 1 && typeof _lang['m1_' + word] != 'undefined') return _lang['m1_' + word]; else if ((l >= 5 && l <= 9 || l == 0 || pl == 1) && typeof _lang['m2_' + word] != 'undefined') return _lang['m2_' + word]; else if (typeof _lang['m0_' + word] != 'undefined') return _lang['m0_' + word]; return word; } is_set = function(v, index) { if (typeof index == 'undefined') return typeof v == 'undefined' ? false : true; return typeof v[index] == 'undefined' ? false : true; }