(function ($) {
var hasIntrospection = (function () {
_;
}
).toString().indexOf("_") > - 1, emptyBase = function () {

}
, objCreate = Object.create || function (ptp) {
var inheritance = function () {

}
;
inheritance.prototype = ptp;
return new inheritance();
}
, needCheckProps = true, testPropObj = {
toString: ""};
for(var i in testPropObj) {
testPropObj.hasOwnProperty(i) && (needCheckProps = false);
}

var specProps = needCheckProps ? ["toString", "valueOf"] : null;
function override(base, result, add) {
var hasSpecProps = false;
if (needCheckProps)
{
var addList = [];
$.each(specProps,function () {
add.hasOwnProperty(this) && (hasSpecProps = true) && addList.push({
name: this,
val: add[this]});
}
);
if (hasSpecProps)
{
$.each(add,function (name) {
addList.push({
name: name,
val: this});
}
);
add = addList;
}

}

$.each(add,function (name, prop) {
if (hasSpecProps)
{
name = prop.name;
prop = prop.val;
}

if ($.isFunction(prop) && (! hasIntrospection || prop.toString().indexOf(".__base") > - 1))
{
var baseMethod = base[name] || function () {

}
;
result[name] = function () {
var baseSaved = this.__base;
this.__base = baseMethod;
var result = prop.apply(this,arguments);
this.__base = baseSaved;
return result;
}
;
}
 else
{
result[name] = prop;
}

}
);
}

$.inherit = function () {
var args = arguments, hasBase = $.isFunction(args[0]), base = hasBase ? args[0] : emptyBase, props = args[hasBase ? 1 : 0] || {
}, staticProps = args[hasBase ? 2 : 1], result = props.__constructor || hasBase && base.prototype.__constructor ? function () {
return this.__constructor.apply(this,arguments);
}
 : function () {

}
;
if (! hasBase)
{
result.prototype = props;
result.prototype.__self = result.prototype.constructor = result;
return $.extend(result,staticProps);
}

$.extend(result,base);
var basePtp = base.prototype, resultPtp = result.prototype = objCreate(basePtp);
resultPtp.__self = resultPtp.constructor = result;
override(basePtp,resultPtp,props);
staticProps && override(base,result,staticProps);
return result;
}
;
$.inheritSelf = function (base, props, staticProps) {
var basePtp = base.prototype;
override(basePtp,basePtp,props);
staticProps && override(base,base,staticProps);
return base;
}
;
}
)(jQuery);
;
(function ($) {
var counter = 0, expando = "__" + + new Date(), get = function () {
return "uniq" + ++counter;
}
;
$.identify = function (obj, onlyGet) {
if (! obj)
return get();
var key = "uniqueID" in obj ? "uniqueID" : expando;
return onlyGet || key in obj ? obj[key] : (obj[key] = get());
}
;
}
)(jQuery);
;
(function ($) {
$.isEmptyObject || ($.isEmptyObject = function (obj) {
for(var i in obj) return false;
return true;
}
);
}
)(jQuery);
;
(function ($) {
$.extend({
debounce: function (fn, timeout, invokeAsap, ctx) {
if (arguments.length == 3 && typeof invokeAsap != "boolean")
{
ctx = invokeAsap;
invokeAsap = false;
}

var timer;
return function () {
var args = arguments;
ctx = ctx || this;
invokeAsap && ! timer && fn.apply(ctx,args);
clearTimeout(timer);
timer = setTimeout(function () {
invokeAsap || fn.apply(ctx,args);
timer = null;
}
,timeout);
}
;
}
,
throttle: function (fn, timeout, ctx) {
var timer, args, needInvoke;
return function () {
args = arguments;
needInvoke = true;
ctx = ctx || this;
timer || (function () {
if (needInvoke)
{
fn.apply(ctx,args);
needInvoke = false;
timer = setTimeout(arguments.callee,timeout);
}
 else
{
timer = null;
}

}
)();
}
;
}
});
}
)(jQuery);
;
(function ($) {
var storageExpando = "__" + + new Date() + "storage", getFnId = function (fn, ctx) {
return $.identify(fn) + (ctx ? $.identify(ctx) : "");
}
, Observable = {
buildEventName: function (e) {
return e;
}
,
on: function (e, data, fn, ctx, _special) {
if (typeof e == "string")
{
if ($.isFunction(data))
{
ctx = fn;
fn = data;
data = undefined;
}

var id = getFnId(fn,ctx), storage = this[storageExpando] || (this[storageExpando] = {
}), eList = e.split(" "), i = 0, eStorage;
while (e = eList[i++]) {
e = this.buildEventName(e);
eStorage = storage[e] || (storage[e] = {
ids: {
},
list: {
}});
if (! (id in eStorage.ids))
{
var list = eStorage.list, item = {
fn: fn,
data: data,
ctx: ctx,
special: _special};
if (list.last)
{
list.last.next = item;
item.prev = list.last;
}
 else
{
list.first = item;
}

eStorage.ids[id] = list.last = item;
}

}

}
 else
{
var _this = this;
$.each(e,function (e, fn) {
_this.on(e,fn,data,_special);
}
);
}

return this;
}
,
onFirst: function (e, data, fn, ctx) {
return this.on(e,data,fn,ctx,{
one: true});
}
,
un: function (e, fn, ctx) {
if (typeof e == "string" || typeof e == "undefined")
{
var storage = this[storageExpando];
if (storage)
{
if (e)
{
var eList = e.split(" "), i = 0, eStorage;
while (e = eList[i++]) {
e = this.buildEventName(e);
if (eStorage = storage[e])
{
if (fn)
{
var id = getFnId(fn,ctx), ids = eStorage.ids;
if (id in ids)
{
var list = eStorage.list, item = ids[id], prev = item.prev, next = item.next;
if (prev)
{
prev.next = next;
}
 else
if (item === list.first)
{
list.first = next;
}

if (next)
{
next.prev = prev;
}
 else
if (item === list.last)
{
list.last = prev;
}

delete ids[id];
}

}
 else
{
delete this[storageExpando][e];
}

}

}

}
 else
{
delete this[storageExpando];
}

}

}
 else
{
var _this = this;
$.each(e,function (e, fn) {
_this.un(e,fn,ctx);
}
);
}

return this;
}
,
trigger: function (e, data) {
var _this = this, storage = _this[storageExpando], rawType;
typeof e === "string" ? (e = $.Event(_this.buildEventName(rawType = e))) : (e.type = _this.buildEventName(rawType = e.type));
e.target || (e.target = _this);
if (storage && (storage = storage[e.type]))
{
var item = storage.list.first, ret;
while (item) {
e.data = item.data;
ret = item.fn.call(item.ctx || _this,e,data);
if (typeof ret !== "undefined")
{
e.result = ret;
if (ret === false)
{
e.preventDefault();
e.stopPropagation();
}

}

item.special && item.special.one && _this.un(rawType,item.fn,item.ctx);
item = item.next;
}

}

return this;
}
};
$.observable = $.inherit(Observable,Observable);
}
)(jQuery);
;
(function ($, undefined) {
var afterCurrentEventFns = [], blocks = {
}, channels = {
};
function buildModFnName(elemName, modName, modVal) {
return (elemName ? "__elem_" + elemName : "") + "__mod" + (modName ? "_" + modName : "") + (modVal ? "_" + modVal : "");
}

function modFnsToProps(modFns, props, elemName) {
$.isFunction(modFns) ? (props[buildModFnName(elemName,"*","*")] = modFns) : $.each(modFns,function (modName, modFn) {
$.isFunction(modFn) ? (props[buildModFnName(elemName,modName,"*")] = modFn) : $.each(modFn,function (modVal, modFn) {
props[buildModFnName(elemName,modName,modVal)] = modFn;
}
);
}
);
}

function buildCheckMod(modName, modVal) {
return modVal ? Array.isArray(modVal) ? function (block) {
var i = 0, len = modVal.length;
while (i < len) if (block.hasMod(modName,modVal[i++]))
return true;
return false;
}
 : function (block) {
return block.hasMod(modName,modVal);
}
 : function (block) {
return block.hasMod(modName);
}
;
}

this.BEM = $.inherit($.observable,{
__constructor: function (mods, params, initImmediately) {
var _this = this;
_this._modCache = mods || {
};
_this._processingMods = {
};
_this._params = params;
_this.params = null;
initImmediately !== false ? _this._init() : _this.afterCurrentEvent(function () {
_this._init();
}
);
}
,
_init: function () {
if (! this._initing && ! this.hasMod("js","inited"))
{
this._initing = true;
if (! this.params)
{
this.params = $.extend(this.getDefaultParams(),this._params);
delete this._params;
}

this.setMod("js","inited");
delete this._initing;
this.hasMod("js","inited") && this.trigger("init");
}

return this;
}
,
changeThis: function (fn, ctx) {
return fn.bind(ctx || this);
}
,
afterCurrentEvent: function (fn, ctx) {
this.__self.afterCurrentEvent(this.changeThis(fn,ctx));
}
,
trigger: function (e, data) {
this.__base(e = this.buildEvent(e),data).__self.trigger(e,data);
return this;
}
,
buildEvent: function (e) {
typeof e == "string" && (e = $.Event(e));
e.block = this;
return e;
}
,
hasMod: function (elem, modName, modVal) {
var len = arguments.length, invert = false;
if (len == 1)
{
modVal = "";
modName = elem;
elem = undefined;
invert = true;
}
 else
if (len == 2)
{
if (typeof elem == "string")
{
modVal = modName;
modName = elem;
elem = undefined;
}
 else
{
modVal = "";
invert = true;
}

}

var res = this.getMod(elem,modName) === modVal;
return invert ? ! res : res;
}
,
getMod: function (elem, modName) {
var type = typeof elem;
if (type === "string" || type === "undefined")
{
modName = elem || modName;
var modCache = this._modCache;
return modName in modCache ? modCache[modName] : (modCache[modName] = this._extractModVal(modName));
}

return this._getElemMod(modName,elem);
}
,
_getElemMod: function (modName, elem, elemName) {
return this._extractModVal(modName,elem,elemName);
}
,
getMods: function (elem) {
var hasElem = elem && typeof elem != "string", _this = this, modNames = [].slice.call(arguments,hasElem ? 1 : 0), res = _this._extractMods(modNames,hasElem ? elem : undefined);
if (! hasElem)
{
modNames.length ? modNames.forEach(function (name) {
_this._modCache[name] = res[name];
}
) : (_this._modCache = res);
}

return res;
}
,
setMod: function (elem, modName, modVal) {
if (typeof modVal == "undefined")
{
modVal = modName;
modName = elem;
elem = undefined;
}

var _this = this;
if (! elem || elem[0])
{
var modId = (elem && elem[0] ? $.identify(elem[0]) : "") + "_" + modName;
if (this._processingMods[modId])
return _this;
var elemName, curModVal = elem ? _this._getElemMod(modName,elem,elemName = _this.__self._extractElemNameFrom(elem)) : _this.getMod(modName);
if (curModVal === modVal)
return _this;
this._processingMods[modId] = true;
var needSetMod = true, modFnParams = [modName, modVal, curModVal];
elem && modFnParams.unshift(elem);
[["*", "*"], [modName, "*"], [modName, modVal]].forEach(function (mod) {
needSetMod = _this._callModFn(elemName,mod[0],mod[1],modFnParams) !== false && needSetMod;
}
);
! elem && needSetMod && (_this._modCache[modName] = modVal);
needSetMod && _this._afterSetMod(modName,modVal,curModVal,elem,elemName);
delete this._processingMods[modId];
}

return _this;
}
,
_afterSetMod: function (modName, modVal, oldModVal, elem, elemName) {

}
,
toggleMod: function (elem, modName, modVal1, modVal2, condition) {
if (typeof elem == "string")
{
condition = modVal2;
modVal2 = modVal1;
modVal1 = modName;
modName = elem;
elem = undefined;
}

if (typeof modVal2 == "undefined")
{
modVal2 = "";
}
 else
if (typeof modVal2 == "boolean")
{
condition = modVal2;
modVal2 = "";
}

var modVal = this.getMod(elem,modName);
(modVal == modVal1 || modVal == modVal2) && this.setMod(elem,modName,typeof condition === "boolean" ? condition ? modVal1 : modVal2 : this.hasMod(elem,modName,modVal1) ? modVal2 : modVal1);
return this;
}
,
delMod: function (elem, modName) {
if (! modName)
{
modName = elem;
elem = undefined;
}

return this.setMod(elem,modName,"");
}
,
_callModFn: function (elemName, modName, modVal, modFnParams) {
var modFnName = buildModFnName(elemName,modName,modVal);
return this[modFnName] ? this[modFnName].apply(this,modFnParams) : undefined;
}
,
_extractModVal: function (modName, elem) {
return "";
}
,
_extractMods: function (modNames, elem) {
return {
};
}
,
channel: function (id, drop) {
return this.__self.channel(id,drop);
}
,
getDefaultParams: function () {
return {
};
}
,
del: function (obj) {
var args = [].slice.call(arguments);
typeof obj == "string" && args.unshift(this);
this.__self.del.apply(this.__self,args);
return this;
}
,
destruct: function () {

}
},{
_name: "i-bem",
blocks: blocks,
decl: function (decl, props, staticProps) {
if (typeof decl == "string")
decl = {
block: decl}; else
if (decl.name)
{
decl.block = decl.name;
}

if (decl.baseBlock && ! blocks[decl.baseBlock])
throw "baseBlock \"" + decl.baseBlock + "\" for \"" + decl.block + "\" is undefined";
props || (props = {
});
if (props.onSetMod)
{
modFnsToProps(props.onSetMod,props);
delete props.onSetMod;
}

if (props.onElemSetMod)
{
$.each(props.onElemSetMod,function (elemName, modFns) {
modFnsToProps(modFns,props,elemName);
}
);
delete props.onElemSetMod;
}

var baseBlock = blocks[decl.baseBlock || decl.block] || this;
if (decl.modName)
{
var checkMod = buildCheckMod(decl.modName,decl.modVal);
$.each(props,function (name, prop) {
$.isFunction(prop) && (props[name] = function () {
var method;
if (checkMod(this))
{
method = prop;
}
 else
{
var baseMethod = baseBlock.prototype[name];
baseMethod && baseMethod !== props[name] && (method = this.__base);
}

return method ? method.apply(this,arguments) : undefined;
}
);
}
);
}

if (staticProps && typeof staticProps.live === "boolean")
{
var live = staticProps.live;
staticProps.live = function () {
return live;
}
;
}

var block;
decl.block == baseBlock._name ? (block = $.inheritSelf(baseBlock,props,staticProps))._processLive(true) : ((block = blocks[decl.block] = $.inherit(baseBlock,props,staticProps))._name = decl.block);
return block;
}
,
_processLive: function (heedLive) {
return false;
}
,
create: function (block, params) {
typeof block == "string" && (block = {
block: block});
return new blocks[block.block](block.mods, params);
}
,
getName: function () {
return this._name;
}
,
_extractElemNameFrom: function (elem) {

}
,
afterCurrentEvent: function (fn, ctx) {
afterCurrentEventFns.push({
fn: fn,
ctx: ctx}) == 1 && setTimeout(this._runAfterCurrentEventFns,0);
}
,
_runAfterCurrentEventFns: function () {
var fnsLen = afterCurrentEventFns.length;
if (fnsLen)
{
var fnObj, fnsCopy = afterCurrentEventFns.splice(0,fnsLen);
while (fnObj = fnsCopy.shift()) fnObj.fn.call(fnObj.ctx || this);
}

}
,
changeThis: function (fn, ctx) {
return fn.bind(ctx || this);
}
,
del: function (obj) {
var delInThis = typeof obj == "string", i = delInThis ? 0 : 1, len = arguments.length;
delInThis && (obj = this);
while (i < len) delete obj[arguments[i++]];
return this;
}
,
channel: function (id, drop) {
if (typeof id == "boolean")
{
drop = id;
id = undefined;
}

id || (id = "default");
if (drop)
{
if (channels[id])
{
channels[id].un();
delete channels[id];
}

return;
}

return channels[id] || (channels[id] = new $.observable());
}
});
}
)(jQuery);
;
(function () {
Object.keys || (Object.keys = function (obj) {
var res = [];
for(var i in obj) obj.hasOwnProperty(i) && res.push(i);
return res;
}
);
}
)();
;
(function () {
var ptp = Array.prototype, toStr = Object.prototype.toString, methods = {
indexOf: function (item, fromIdx) {
fromIdx = + (fromIdx || 0);
var t = this, len = t.length;
if (len > 0 && fromIdx < len)
{
fromIdx = fromIdx < 0 ? Math.ceil(fromIdx) : Math.floor(fromIdx);
fromIdx < - len && (fromIdx = 0);
fromIdx < 0 && (fromIdx = fromIdx + len);
while (fromIdx < len) {
if (fromIdx in t && t[fromIdx] === item)
return fromIdx;
++fromIdx;
}

}

return - 1;
}
,
forEach: function (callback, ctx) {
var i = - 1, t = this, len = t.length;
while (++i < len) i in t && (ctx ? callback.call(ctx,t[i],i,t) : callback(t[i],i,t));
}
,
map: function (callback, ctx) {
var i = - 1, t = this, len = t.length, res = new Array(len);
while (++i < len) i in t && (res[i] = ctx ? callback.call(ctx,t[i],i,t) : callback(t[i],i,t));
return res;
}
,
filter: function (callback, ctx) {
var i = - 1, t = this, len = t.length, res = [];
while (++i < len) i in t && (ctx ? callback.call(ctx,t[i],i,t) : callback(t[i],i,t)) && res.push(t[i]);
return res;
}
,
reduce: function (callback, initialVal) {
var i = - 1, t = this, len = t.length, res;
if (arguments.length < 2)
{
while (++i < len) {
if (i in t)
{
res = t[i];
break;
}

}

}
 else
{
res = initialVal;
}

while (++i < len) i in t && (res = callback(res,t[i],i,t));
return res;
}
,
some: function (callback, ctx) {
var i = - 1, t = this, len = t.length;
while (++i < len) if (i in t && (ctx ? callback.call(ctx,t[i],i,t) : callback(t[i],i,t)))
return true;
return false;
}
,
every: function (callback, ctx) {
var i = - 1, t = this, len = t.length;
while (++i < len) if (i in t && ! (ctx ? callback.call(ctx,t[i],i,t) : callback(t[i],i,t)))
return false;
return true;
}
};
for(var name in methods) ptp[name] || (ptp[name] = methods[name]);
Array.isArray || (Array.isArray = function (obj) {
return toStr.call(obj) === "[object Array]";
}
);
}
)();
;
(function () {
var slice = Array.prototype.slice;
Function.prototype.bind || (Function.prototype.bind = function (ctx) {
var fn = this, args = slice.call(arguments,1);
return function () {
return fn.apply(ctx,args.concat(slice.call(arguments)));
}
;
}
);
}
)();
;
(function (BEM, $, undefined) {
var MOD_DELIM = "_", ELEM_DELIM = "__", NAME_PATTERN = "[a-zA-Z0-9-]+";
function buildModPostfix(modName, modVal, buffer) {
buffer.push(MOD_DELIM,modName,MOD_DELIM,modVal);
}

function buildBlockClass(name, modName, modVal, buffer) {
buffer.push(name);
modVal && buildModPostfix(modName,modVal,buffer);
}

function buildElemClass(block, name, modName, modVal, buffer) {
buildBlockClass(block,undefined,undefined,buffer);
buffer.push(ELEM_DELIM,name);
modVal && buildModPostfix(modName,modVal,buffer);
}

BEM.INTERNAL = {
NAME_PATTERN: NAME_PATTERN,
MOD_DELIM: MOD_DELIM,
ELEM_DELIM: ELEM_DELIM,
buildModPostfix: function (modName, modVal, buffer) {
var res = buffer || [];
buildModPostfix(modName,modVal,res);
return buffer ? res : res.join("");
}
,
buildClass: function (block, elem, modName, modVal, buffer) {
var typeOf = typeof modName;
if (typeOf == "string")
{
if (typeof modVal != "string" && typeof modVal != "number")
{
buffer = modVal;
modVal = modName;
modName = elem;
elem = undefined;
}

}
 else
if (typeOf != "undefined")
{
buffer = modName;
modName = undefined;
}
 else
if (elem && typeof elem != "string")
{
buffer = elem;
elem = undefined;
}

if (! (elem || modName || buffer))
{
return block;
}

var res = buffer || [];
elem ? buildElemClass(block,elem,modName,modVal,res) : buildBlockClass(block,modName,modVal,res);
return buffer ? res : res.join("");
}
,
buildClasses: function (block, elem, mods, buffer) {
if (elem && typeof elem != "string")
{
buffer = mods;
mods = elem;
elem = undefined;
}

var res = buffer || [];
elem ? buildElemClass(block,elem,undefined,undefined,res) : buildBlockClass(block,undefined,undefined,res);
mods && $.each(mods,function (modName, modVal) {
if (modVal)
{
res.push(" ");
elem ? buildElemClass(block,elem,modName,modVal,res) : buildBlockClass(block,modName,modVal,res);
}

}
);
return buffer ? res : res.join("");
}
};
}
)(BEM,jQuery);
;
jQuery.cookie = function (name, value, options) {
if (typeof value != "undefined")
{
options = options || {
};
if (value === null)
{
value = "";
options.expires = - 1;
}

var expires = "";
if (options.expires && (typeof options.expires == "number" || options.expires.toUTCString))
{
var date;
if (typeof options.expires == "number")
{
date = new Date();
date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1000);
}
 else
{
date = options.expires;
}

expires = "; expires=" + date.toUTCString();
}

var path = options.path ? "; path=" + options.path : "";
var domain = options.domain ? "; domain=" + options.domain : "";
var secure = options.secure ? "; secure" : "";
document.cookie = [name, "=", encodeURIComponent(value), expires, path, domain, secure].join("");
}
 else
{
var cookieValue = null;
if (document.cookie && document.cookie != "")
{
var cookies = document.cookie.split(";");
for (var i = 0;i < cookies.length;i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0,name.length + 1) == name + "=")
{
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}

}

}

return cookieValue;
}

}
;
;
(function (BEM, $, undefined) {
var INTERNAL = BEM.INTERNAL, ELEM_DELIM = INTERNAL.ELEM_DELIM, SHORT_TAGS = {
area: 1,
base: 1,
br: 1,
col: 1,
command: 1,
embed: 1,
hr: 1,
img: 1,
input: 1,
keygen: 1,
link: 1,
meta: 1,
param: 1,
source: 1,
wbr: 1}, buildClass = INTERNAL.buildClass, buildClasses = INTERNAL.buildClasses, decls = {
};
function addPropToDecl(decl, name, fn) {
(decl[name] || (decl[name] = [])).unshift(fn);
}

function buildDeclFn(fn, desc) {
return desc.modName ? function (ctx) {
(ctx._curBlock.mods || {
})[desc.modName] === desc.modVal && fn(ctx);
}
 : fn;
}

function join(a, b) {
var isArrayB = $.isArray(b), res;
$.isArray(a) ? isArrayB ? (res = a.concat(b)) : (res = a).push(b) : isArrayB ? (res = b).unshift(a) : (res = [a, b]);
return res;
}

var attrEscapes = {
"\"": "&quot;",
"&": "&amp;",
"<": "&lt;",
">": "&gt;"}, attrEscapesRE = /["&<>]/g;
function escapeAttr(attrVal) {
return attrVal.replace(attrEscapesRE,function (needToEscape) {
return attrEscapes[needToEscape];
}
);
}

BEM.HTML = {
decl: function (desc, props) {
typeof desc == "string" && (desc = {
block: desc});
desc.name && (desc.block = desc.name);
var decl = decls[desc.block] || (decls[desc.block] = {
});
props.onBlock && addPropToDecl(decl,"_block",buildDeclFn(props.onBlock,desc));
if (props.onElem)
{
$.isFunction(props.onElem) ? addPropToDecl(decl,"_elem",buildDeclFn(props.onElem,desc)) : $.each(props.onElem,function (elem, fn) {
addPropToDecl(decl,"_elem" + (elem === "*" ? "" : ELEM_DELIM + elem),buildDeclFn(fn,desc));
}
);
}

}
,
build: function (params) {
var builder = new this.Ctx(params);
builder._buildAll();
return builder._flush();
}
,
Ctx: $.inherit({
__constructor: function (params) {
this._buffer = [];
this._params = params;
this._tParams = null;
this._tParamsChanges = null;
this._curBlock = undefined;
}
,
pos: function () {
return this._params._pos;
}
,
isFirst: function () {
return this._params._pos === 1;
}
,
isLast: function () {
var params = this._params;
return params._pos === params._siblingsCount;
}
,
params: function (params) {
var _this = this;
if (typeof params == "undefined")
return _this._params;
_this._params = params;
return _this;
}
,
param: function (name, val, force, needExtend) {
var _this = this, params = _this._params;
if (typeof val == "undefined")
return params[name];
if (force || ! (name in params))
{
params[name] = val;
}
 else
if (needExtend)
{
params[name] = $.extend(val,params[name]);
}

return _this;
}
,
attrs: function (val, force) {
return this.param("attrs",val,force,true);
}
,
attr: function (name, val, force) {
var _this = this;
if (typeof val == "undefined")
return (_this._params.attrs || {
})[name];
var attrs = _this._params.attrs;
attrs ? (force || ! (name in attrs)) && (attrs[name] = val) : ((_this._params.attrs = {
})[name] = val);
return _this;
}
,
tag: function (val, force) {
return this.param("tag",val,force);
}
,
cls: function (val, force) {
return this.param("cls",val,force);
}
,
mods: function (val, force) {
return this.param("mods",val,force,true);
}
,
mod: function (name, val, force) {
var _this = this;
if (typeof val == "undefined")
return (_this._params.mods || {
})[name];
var mods = _this._params.mods;
mods ? (force || ! (name in mods)) && (mods[name] = val) : ((_this._params.mods = {
})[name] = val);
return _this;
}
,
mix: function (val, force) {
var _this = this, params = _this._params;
if (typeof val == "undefined")
return params.mix;
if (force || ! ("mix" in params))
{
params.mix = val;
}
 else
{
params.mix = params.mix.concat(val);
}

return _this;
}
,
js: function (val) {
return this.param("js",val);
}
,
content: function (val, force) {
return this.param("content",val,force);
}
,
wrapContent: function (obj) {
var _this = this, params = _this._params;
obj.content = params.content;
params.content = obj;
return _this;
}
,
beforeContent: function (obj) {
var _this = this, params = _this._params;
params.content = join(obj,params.content);
return _this;
}
,
afterContent: function (obj) {
var _this = this, params = _this._params;
params.content = join(params.content,obj);
return _this;
}
,
wrap: function (obj) {
var _this = this, params = _this._params;
obj.block || (obj._curBlock = _this._curBlock);
obj.content = params._wrapper ? params._wrapper : params;
params._wrapper = obj;
return _this;
}
,
tParam: function (name, val) {
var _this = this, tParams = _this._tParams || (_this._tParams = {
});
if (typeof val == "undefined")
return tParams[name];
var tParamsChanges = _this._tParamsChanges || (_this._tParamsChanges = {
});
name in tParamsChanges || (tParamsChanges[name] = tParams[name]);
tParams[name] = val;
return _this;
}
,
generateId: function () {
return $.identify();
}
,
stop: function () {
this._params._isStopped = true;
}
,
_buildAll: function () {
var _this = this, buffer = _this._buffer, params = _this._params, paramsType = typeof params;
if (paramsType == "string" || paramsType == "number")
{
buffer.push(params);
}
 else
if ($.isArray(params))
{
var i = 0, len = params.length, currParams, currParamsType;
while (i < len) {
_this._params = currParams = params[i++];
currParamsType = typeof currParams;
if (currParamsType == "string" || currParamsType == "number")
{
buffer.push(currParams);
}
 else
if (currParams)
{
currParams._pos = i;
currParams._siblingsCount = len;
_this._buildByDecl();
}

}

}
 else
if (params)
{
_this._params._pos = _this._params._siblingsCount = 1;
_this._buildByDecl();
}

}
,
_build: function () {
var _this = this, buffer = _this._buffer, params = _this._params, tag = params.tag || "div", jsParams, isBEM = params.block || params.elem, curBlock = isBEM && (params.block || _this._curBlock.block), addInitingCls = false;
if (params.js)
{
(jsParams = {
})[buildClass(curBlock,params.elem)] = params.js === true ? {
} : params.js;
addInitingCls = ! params.elem;
}

buffer.push("<",tag);
if (isBEM || params.cls)
{
buffer.push(" class=\"");
if (isBEM)
{
buildClasses(curBlock,params.elem,params.mods,buffer);
params.mix && $.each(params.mix,function (i, mix) {
if (mix)
{
buffer.push(" ");
buildClasses(mix.block,mix.elem,mix.mods,buffer);
if (mix.js)
{
(jsParams || (jsParams = {
}))[buildClass(mix.block,mix.elem)] = mix.js === true ? {
} : mix.js;
addInitingCls || (addInitingCls = ! mix.elem);
}

}

}
);
}

params.cls && buffer.push(isBEM ? " " : "",params.cls);
addInitingCls && buffer.push(" i-bem");
buffer.push("\"");
}

jsParams && buffer.push(" onclick=\"return ",escapeAttr(JSON.stringify(jsParams)),"\"");
params.attrs && $.each(params.attrs,function (name, val) {
typeof val != "undefined" && val !== null && val !== false && buffer.push(" ",name,"=\"",val.toString().replace(/"/g,"&quot;"),"\"");
}
);
if (SHORT_TAGS[tag])
{
buffer.push("/>");
}
 else
{
buffer.push(">");
if (typeof params.content != "undefined")
{
_this._params = params.content;
_this._buildAll();
}

buffer.push("</",tag,">");
}

}
,
_flush: function () {
var res = this._buffer.join("");
delete this._buffer;
return res;
}
,
_buildByDecl: function () {
var _this = this, currBlock = _this._curBlock, params = _this._params;
params._curBlock && (_this._curBlock = params._curBlock);
params.block && (_this._curBlock = params);
if (! params._wrapper)
{
if (params.block || params.elem)
{
var decl = decls[_this._curBlock.block];
if (decl)
{
var fns;
if (params.elem)
{
fns = decl["_elem" + ELEM_DELIM + params.elem];
decl._elem && (fns = fns ? fns.concat(decl._elem) : decl._elem);
}
 else
{
fns = decl._block;
}

if (fns)
{
var i = 0, fn;
while (fn = fns[i++]) {
fn(_this);
if (params._isStopped)
break;
}

}

}

}

if (params._wrapper)
{
params._curBlock = _this._curBlock;
_this._params = params._wrapper;
return _this._buildAll();
}

}

var tParamsChanges = _this._tParamsChanges;
_this._tParamsChanges = null;
_this._build();
_this._curBlock = currBlock;
if (tParamsChanges)
{
var tParams = _this._tParams;
$.each(tParamsChanges,function (name, val) {
typeof val == "undefined" ? delete tParams[name] : (tParams[name] = val);
}
);
}

}
})};
}
)(BEM,jQuery);
;
(function (undefined) {
if (window.JSON)
return;
var _toString = Object.prototype.toString, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, meta = {
"\b": "\\b",
"\t": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
"\"": "\\\"",
"\\": "\\\\"}, stringify;
window.JSON = {
stringify: stringify = function (val) {
if (val === null)
{
return "null";
}

if (typeof val === "undefined")
{
return undefined;
}

switch (_toString.call(val)) {
case "[object String]":
escapable.lastIndex = 0;
return "\"" + (escapable.test(val) ? val.replace(escapable,function (a) {
var c = meta[a];
return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(- 4);
}
) : val) + "\"";
case "[object Number]":

case "[object Boolean]":
return "" + val;
case "[object Array]":
var res = "[", i = 0, len = val.length, strVal;
while (i < len) {
strVal = stringify(val[i]);
res += (i++ ? "," : "") + (typeof strVal === "undefined" ? "null" : strVal);
}

return res + "]";
case "[object Object]":
if (_toString.call(val.toJSON) === "[object Function]")
{
return stringify(val.toJSON());
}

var res = "{", i = 0, strVal;
for(var key in val) {
if (val.hasOwnProperty(key))
{
strVal = stringify(val[key]);
typeof strVal !== "undefined" && (res += (i++ ? "," : "") + "\"" + key + "\":" + strVal);
}

}

return res + "}";
default:
return undefined;
}

}
};
}
)();
;
(function (BEM, $, undefined) {
var win = $(window), doc = $(document), uniqIdToDomElems = {
}, uniqIdToBlock = {
}, domElemToParams = {
}, liveEventCtxStorage = {
}, liveClassEventStorage = {
}, blocks = BEM.blocks, INTERNAL = BEM.INTERNAL, NAME_PATTERN = INTERNAL.NAME_PATTERN, MOD_DELIM = INTERNAL.MOD_DELIM, ELEM_DELIM = INTERNAL.ELEM_DELIM, buildModPostfix = INTERNAL.buildModPostfix, buildClass = INTERNAL.buildClass;
function init(domElem, uniqInitId) {
var domNode = domElem[0];
$.each(getParams(domNode),function (blockName, params) {
processParams(params,domNode,blockName,uniqInitId);
var block = uniqIdToBlock[params.uniqId];
if (block)
{
if (block.domElem.index(domNode) < 0)
{
block.domElem = block.domElem.add(domElem);
$.extend(block._params,params);
}

}
 else
{
initBlock(blockName,domElem,params);
}

}
);
}

function initBlock(blockName, domElem, params, forceLive, callback) {
if (typeof params == "boolean")
{
callback = forceLive;
forceLive = params;
params = undefined;
}

var domNode = domElem[0];
params = processParams(params || getParams(domNode)[blockName],domNode,blockName);
var uniqId = params.uniqId;
if (uniqIdToBlock[uniqId])
{
return uniqIdToBlock[uniqId]._init();
}

uniqIdToDomElems[uniqId] = uniqIdToDomElems[uniqId] ? uniqIdToDomElems[uniqId].add(domElem) : domElem;
var parentDomNode = domNode.parentNode;
if (! parentDomNode || parentDomNode.nodeType === 11)
{
$.unique(uniqIdToDomElems[uniqId]);
}

var blockClass = blocks[blockName] || DOM.decl(blockName,{
},{
live: true});
if (! (blockClass._liveInitable = ! ! blockClass._processLive()) || forceLive || params.live === false)
{
var block = new blockClass(uniqIdToDomElems[uniqId], params, ! ! forceLive);
delete uniqIdToDomElems[uniqId];
callback && callback.apply(block,Array.prototype.slice.call(arguments,4));
return block;
}

}

function processParams(params, domNode, blockName, uniqInitId) {
(params || (params = {
})).uniqId || (params.uniqId = (params.id ? blockName + "-id-" + params.id : $.identify()) + (uniqInitId || $.identify()));
var domUniqId = $.identify(domNode), domParams = domElemToParams[domUniqId] || (domElemToParams[domUniqId] = {
});
domParams[blockName] || (domParams[blockName] = params);
return params;
}

function findDomElem(ctx, selector, excludeSelf) {
var res = ctx.find(selector);
return excludeSelf ? res : res.add(ctx.filter(selector));
}

function getParams(domNode) {
var uniqId = $.identify(domNode);
return domElemToParams[uniqId] || (domElemToParams[uniqId] = extractParams(domNode));
}

function extractParams(domNode) {
var fn = domNode.onclick || domNode.ondblclick;
if (! fn && domNode.tagName.toLowerCase() == "body")
{
var elem = $(domNode), attr = elem.attr("onclick") || elem.attr("ondblclick");
attr && (fn = Function(attr));
}

return fn ? fn() : {
};
}

function cleanupDomNode(domNode) {
delete domElemToParams[$.identify(domNode)];
}

function removeDomNodeFromBlock(block, domNode) {
block.domElem.length === 1 ? block.destruct(true) : (block.domElem = block.domElem.not(domNode));
}

function getClientNode() {
return doc[0][$.support.boxModel ? "documentElement" : "body"];
}

$.fn.bem = function (blockName, params) {
return initBlock(blockName,this,params,true);
}
;
var DOM = BEM.DOM = BEM.decl("i-bem__dom",{
__constructor: function (domElem, params, initImmediately) {
var _this = this;
_this.domElem = domElem;
_this._eventNameCache = {
};
_this._elemCache = {
};
uniqIdToBlock[_this._uniqId = params.uniqId || $.identify(_this)] = _this;
_this._needSpecialUnbind = false;
_this.__base(null,params,initImmediately);
}
,
findBlocksInside: function (elem, block) {
return this._findBlocks("find",elem,block);
}
,
findBlockInside: function (elem, block) {
return this._findBlocks("find",elem,block,true);
}
,
findBlocksOutside: function (elem, block) {
return this._findBlocks("parents",elem,block);
}
,
findBlockOutside: function (elem, block) {
return this._findBlocks("closest",elem,block)[0] || null;
}
,
findBlocksOn: function (elem, block) {
return this._findBlocks("",elem,block);
}
,
findBlockOn: function (elem, block) {
return this._findBlocks("",elem,block,true);
}
,
_findBlocks: function (select, elem, block, onlyFirst) {
if (! block)
{
block = elem;
elem = undefined;
}

var ctxElem = elem ? typeof elem == "string" ? this.findElem(elem) : elem : this.domElem, isSimpleBlock = typeof block == "string", blockName = isSimpleBlock ? block : block.block || block.blockName, selector = "." + (isSimpleBlock ? buildClass(blockName) : buildClass(blockName,block.modName,block.modVal)) + (onlyFirst ? ":first" : ""), domElems = ctxElem.filter(selector);
select && (domElems = domElems.add(ctxElem[select](selector)));
if (onlyFirst)
{
return domElems[0] ? initBlock(blockName,domElems.eq(0),true) : null;
}

var res = [], uniqIds = {
};
$.each(domElems,function (i, domElem) {
var block = initBlock(blockName,$(domElem),true);
if (! uniqIds[block._uniqId])
{
uniqIds[block._uniqId] = true;
res.push(block);
}

}
);
return res;
}
,
bindToDomElem: function (domElem, event, fn) {
var _this = this;
fn ? domElem.bind(_this._buildEventName(event),function (e) {
(e.data || (e.data = {
})).domElem = $(this);
return fn.apply(_this,arguments);
}
) : $.each(event,function (event, fn) {
_this.bindToDomElem(domElem,event,fn);
}
);
return _this;
}
,
bindToDoc: function (event, fn) {
this._needSpecialUnbind = true;
return this.bindToDomElem(doc,event,fn);
}
,
bindToWin: function (event, fn) {
var _fn = fn, currentHeight, currentWidth;
if (event === "resize")
{
fn = function () {
var height = win.height(), width = win.width();
if (currentHeight !== height || currentWidth !== width)
{
currentHeight = height;
currentWidth = width;
_fn.apply(this,arguments);
}

}
;
}

this._needSpecialUnbind = true;
return this.bindToDomElem(win,event,fn);
}
,
bindTo: function (elem, event, fn) {
if (! event || $.isFunction(event))
{
fn = event;
event = elem;
elem = this.domElem;
}
 else
if (typeof elem == "string")
{
elem = this.elem(elem);
}

return this.bindToDomElem(elem,event,fn);
}
,
unbindFromDomElem: function (domElem, event) {
domElem.unbind(this._buildEventName(event));
return this;
}
,
unbindFromDoc: function (event) {
return this.unbindFromDomElem(doc,event);
}
,
unbindFromWin: function (event) {
return this.unbindFromDomElem(win,event);
}
,
unbindFrom: function (elem, event) {
if (! event)
{
event = elem;
elem = this.domElem;
}
 else
if (typeof elem == "string")
{
elem = this.elem(elem);
}

return this.unbindFromDomElem(elem,event);
}
,
_buildEventName: function (event) {
var _this = this;
return event.indexOf(" ") > 1 ? event.split(" ").map(function (e) {
return _this._buildOneEventName(e);
}
).join(" ") : _this._buildOneEventName(event);
}
,
_buildOneEventName: function (event) {
var _this = this, eventNameCache = _this._eventNameCache;
if (event in eventNameCache)
return eventNameCache[event];
var uniq = "." + _this._uniqId;
if (event.indexOf(".") < 0)
return eventNameCache[event] = event + uniq;
var lego = ".bem_" + _this.__self._name;
return eventNameCache[event] = event.split(".").map(function (e, i) {
return i == 0 ? e + lego : lego + "_" + e;
}
).join("") + uniq;
}
,
trigger: function (e, data) {
this.__base(e = this.buildEvent(e),data).domElem && this._ctxTrigger(e,data);
return this;
}
,
_ctxTrigger: function (e, data) {
var _this = this, storage = liveEventCtxStorage[_this.__self._buildCtxEventName(e.type)], ctxIds = {
};
storage && _this.domElem.each(function () {
var ctx = this, counter = storage.counter;
while (ctx && counter) {
var ctxId = $.identify(ctx,true);
if (ctxId)
{
if (ctxIds[ctxId])
break;
var storageCtx = storage.ctxs[ctxId];
if (storageCtx)
{
$.each(storageCtx,function (uniqId, handler) {
handler.fn.call(handler.ctx || _this,e,data);
}
);
counter--;
}

ctxIds[ctxId] = true;
}

ctx = ctx.parentNode;
}

}
);
}
,
setMod: function (elem, modName, modVal) {
if (elem && typeof modVal != "undefined" && elem.length > 1)
{
var _this = this;
elem.each(function () {
var item = $(this);
item.__bemElemName = elem.__bemElemName;
_this.setMod(item,modName,modVal);
}
);
return _this;
}

return this.__base(elem,modName,modVal);
}
,
_extractModVal: function (modName, elem, elemName) {
var domNode = (elem || this.domElem)[0], matches;
domNode && (matches = domNode.className.match(this.__self._buildModValRE(modName,elemName || elem)));
return matches ? matches[2] : "";
}
,
_extractMods: function (modNames, elem) {
var res = {
}, extractAll = ! modNames.length, countMatched = 0;
((elem || this.domElem)[0].className.match(this.__self._buildModValRE("(" + (extractAll ? NAME_PATTERN : modNames.join("|")) + ")",elem,"g")) || []).forEach(function (className) {
var iModVal = (className = className.trim()).lastIndexOf(MOD_DELIM), iModName = className.substr(0,iModVal - 1).lastIndexOf(MOD_DELIM);
res[className.substr(iModName + 1,iModVal - iModName - 1)] = className.substr(iModVal + 1);
++countMatched;
}
);
countMatched < modNames.length && modNames.forEach(function (modName) {
modName in res || (res[modName] = "");
}
);
return res;
}
,
_afterSetMod: function (modName, modVal, oldModVal, elem, elemName) {
var _self = this.__self, classPrefix = _self._buildModClassPrefix(modName,elemName), classRE = _self._buildModValRE(modName,elemName), needDel = modVal === "";
(elem || this.domElem).each(function () {
var className = this.className;
className.indexOf(classPrefix) > - 1 ? (this.className = className.replace(classRE,needDel ? "" : "$1" + classPrefix + modVal)) : needDel || $(this).addClass(classPrefix + modVal);
}
);
elemName && this.dropElemCache(elemName,modName,oldModVal).dropElemCache(elemName,modName,modVal);
}
,
findElem: function (ctx, names, modName, modVal) {
if (arguments.length % 2)
{
modVal = modName;
modName = names;
names = ctx;
ctx = this.domElem;
}
 else
if (typeof ctx == "string")
{
ctx = this.findElem(ctx);
}

var _self = this.__self, selector = "." + names.split(" ").map(function (name) {
return buildClass(_self._name,name,modName,modVal);
}
).join(",.");
return findDomElem(ctx,selector);
}
,
_elem: function (name, modName, modVal) {
var key = name + buildModPostfix(modName,modVal), res;
if (! (res = this._elemCache[key]))
{
res = this._elemCache[key] = this.findElem(name,modName,modVal);
res.__bemElemName = name;
}

return res;
}
,
elem: function (names, modName, modVal) {
if (modName && typeof modName != "string")
{
modName.__bemElemName = names;
return modName;
}

if (names.indexOf(" ") < 0)
{
return this._elem(names,modName,modVal);
}

var res = $([]), _this = this;
names.split(" ").forEach(function (name) {
res = res.add(_this._elem(name,modName,modVal));
}
);
return res;
}
,
dropElemCache: function (names, modName, modVal) {
if (names)
{
var _this = this, modPostfix = buildModPostfix(modName,modVal);
names.indexOf(" ") < 0 ? delete _this._elemCache[names + modPostfix] : names.split(" ").forEach(function (name) {
delete _this._elemCache[name + modPostfix];
}
);
}
 else
{
this._elemCache = {
};
}

return this;
}
,
elemParams: function (elem) {
var elemName;
if (typeof elem == "string")
{
elemName = elem;
elem = this.elem(elem);
}
 else
{
elemName = this.__self._extractElemNameFrom(elem);
}

return extractParams(elem[0])[buildClass(this.__self.getName(),elemName)] || {
};
}
,
elemify: function (elem, elemName) {
(elem = $(elem)).__bemElemName = elemName;
return elem;
}
,
containsDomElem: function (domElem) {
var res = false;
this.domElem.each(function () {
return ! (res = domElem.parents().andSelf().index(this) > - 1);
}
);
return res;
}
,
buildSelector: function (elem, modName, modVal) {
return this.__self.buildSelector(elem,modName,modVal);
}
,
destruct: function (keepDOM) {
var _this = this, _self = _this.__self;
_this._isDestructing = true;
_this._needSpecialUnbind && _self.doc.add(_self.win).unbind("." + _this._uniqId);
_this.dropElemCache().domElem.each(function (i, domNode) {
var params = getParams(domNode);
$.each(params,function (blockName, blockParams) {
var block = uniqIdToBlock[blockParams.uniqId];
if (block)
{
if (! block._isDestructing)
{
removeDomNodeFromBlock(block,domNode);
delete params[blockName];
}

}
 else
{
delete uniqIdToDomElems[blockParams.uniqId];
}

}
);
$.isEmptyObject(params) && cleanupDomNode(domNode);
}
);
keepDOM || _this.domElem.remove();
delete uniqIdToBlock[_this.un()._uniqId];
delete _this.domElem;
delete _this._elemCache;
_this.__base();
}
},{
scope: null,
doc: doc,
win: win,
_processLive: function (heedLive) {
var _this = this, res = _this._liveInitable;
if ("live" in _this)
{
var noLive = typeof res == "undefined";
if (noLive ^ heedLive)
{
res = _this.live() !== false;
_this.live = function () {

}
;
}

}

return res;
}
,
init: function (ctx, callback, callbackCtx) {
if (! ctx || $.isFunction(ctx))
{
callbackCtx = callback;
callback = ctx;
ctx = doc;
}

var uniqInitId = $.identify();
findDomElem(ctx,".i-bem").each(function () {
init($(this),uniqInitId);
}
);
callback && this.afterCurrentEvent(function () {
callback.call(callbackCtx || this,ctx);
}
);
this._runAfterCurrentEventFns();
return ctx;
}
,
destruct: function (keepDOM, ctx, excludeSelf) {
if (typeof keepDOM != "boolean")
{
excludeSelf = ctx;
ctx = keepDOM;
keepDOM = undefined;
}

findDomElem(ctx,".i-bem",excludeSelf).each(function (i, domNode) {
var params = getParams(this);
$.each(params,function (blockName, blockParams) {
if (blockParams.uniqId)
{
var block = uniqIdToBlock[blockParams.uniqId];
if (block)
{
removeDomNodeFromBlock(block,domNode);
delete params[blockName];
}
 else
{
delete uniqIdToDomElems[blockParams.uniqId];
}

}

}
);
$.isEmptyObject(params) && cleanupDomNode(this);
}
);
keepDOM || (excludeSelf ? ctx.empty() : ctx.remove());
}
,
update: function (ctx, content, callback, callbackCtx) {
this.destruct(ctx,true);
this.init(ctx.html(content),callback,callbackCtx);
}
,
replace: function (ctx, content) {
this.destruct(true,ctx);
this.init($(content).replaceAll(ctx));
}
,
append: function (ctx, content) {
this.init($(content).appendTo(ctx));
}
,
prepend: function (ctx, content) {
this.init($(content).prependTo(ctx));
}
,
before: function (ctx, content) {
this.init($(content).insertBefore(ctx));
}
,
after: function (ctx, content) {
this.init($(content).insertAfter(ctx));
}
,
_buildCtxEventName: function (e) {
return this._name + ":" + e;
}
,
_liveClassBind: function (className, e, callback, invokeOnInit) {
var _this = this;
if (e.indexOf(" ") > - 1)
{
e.split(" ").forEach(function (e) {
_this._liveClassBind(className,e,callback,invokeOnInit);
}
);
}
 else
{
var storage = liveClassEventStorage[e], uniqId = $.identify(callback);
if (! storage)
{
storage = liveClassEventStorage[e] = {
};
doc.bind(e,_this.changeThis(_this._liveClassTrigger,_this));
}

storage = storage[className] || (storage[className] = {
uniqIds: {
},
fns: []});
if (! (uniqId in storage.uniqIds))
{
storage.fns.push({
uniqId: uniqId,
fn: _this._buildLiveEventFn(callback,invokeOnInit)});
storage.uniqIds[uniqId] = storage.fns.length - 1;
}

}

return this;
}
,
_liveClassUnbind: function (className, e, callback) {
var storage = liveClassEventStorage[e];
if (storage)
{
if (callback)
{
if (storage = storage[className])
{
var uniqId = $.identify(callback);
if (uniqId in storage.uniqIds)
{
var i = storage.uniqIds[uniqId], len = storage.fns.length - 1;
storage.fns.splice(i,1);
while (i < len) storage.uniqIds[storage.fns[i++].uniqId] = i - 1;
delete storage.uniqIds[uniqId];
}

}

}
 else
{
delete storage[className];
}

}

return this;
}
,
_liveClassTrigger: function (e) {
var storage = liveClassEventStorage[e.type];
if (storage)
{
var node = e.target, classNames = [];
for(var className in storage) storage.hasOwnProperty(className) && classNames.push(className);
do {
var nodeClassName = " " + node.className + " ", i = 0;
while (className = classNames[i++]) {
if (nodeClassName.indexOf(" " + className + " ") > - 1)
{
var j = 0, fns = storage[className].fns, fn, stopPropagationAndPreventDefault = false;
while (fn = fns[j++]) if (fn.fn.call($(node),e) === false)
stopPropagationAndPreventDefault = true;
stopPropagationAndPreventDefault && e.preventDefault();
if (stopPropagationAndPreventDefault || e.isPropagationStopped())
return;
classNames.splice(--i,1);
}

}

}
 while (classNames.length && (node = node.parentNode));
}

}
,
_buildLiveEventFn: function (callback, invokeOnInit) {
var _this = this;
return function (e) {
var args = [_this._name, ((e.data || (e.data = {
})).domElem = $(this)).closest(_this.buildSelector()), true], block = initBlock.apply(null,invokeOnInit ? args.concat([callback, e]) : args);
if (block && ! invokeOnInit && callback)
return callback.apply(block,arguments);
}
;
}
,
liveInitOnEvent: function (elemName, event, callback) {
return this.liveBindTo(elemName,event,callback,true);
}
,
liveBindTo: function (to, event, callback, invokeOnInit) {
if (! event || $.isFunction(event))
{
callback = event;
event = to;
to = undefined;
}

if (! to || typeof to == "string")
{
to = {
elem: to};
}

to.elemName && (to.elem = to.elemName);
var _this = this;
if (to.elem && to.elem.indexOf(" ") > 0)
{
to.elem.split(" ").forEach(function (elem) {
_this._liveClassBind(buildClass(_this._name,elem,to.modName,to.modVal),event,callback,invokeOnInit);
}
);
return _this;
}

return _this._liveClassBind(buildClass(_this._name,to.elem,to.modName,to.modVal),event,callback,invokeOnInit);
}
,
liveUnbindFrom: function (elem, event, callback) {
var _this = this;
if (elem.indexOf(" ") > 1)
{
elem.split(" ").forEach(function (elem) {
_this._liveClassUnbind(buildClass(_this._name,elem),event,callback);
}
);
return _this;
}

return _this._liveClassUnbind(buildClass(_this._name,elem),event,callback);
}
,
_liveInitOnBlockEvent: function (event, blockName, callback, findFnName) {
var name = this._name;
blocks[blockName].on(event,function (e) {
var args = arguments, blocks = e.block[findFnName](name);
callback && blocks.forEach(function (block) {
callback.apply(block,args);
}
);
}
);
return this;
}
,
liveInitOnBlockEvent: function (event, blockName, callback) {
return this._liveInitOnBlockEvent(event,blockName,callback,"findBlocksOn");
}
,
liveInitOnBlockInsideEvent: function (event, blockName, callback) {
return this._liveInitOnBlockEvent(event,blockName,callback,"findBlocksOutside");
}
,
liveInitOnBlockInit: function (blockName, callback) {
return this.liveInitOnBlockEvent("init",blockName,callback);
}
,
liveInitOnBlockInsideInit: function (blockName, callback) {
return this.liveInitOnBlockInsideEvent("init",blockName,callback);
}
,
on: function (ctx, e, data, fn, fnCtx) {
return ctx.jquery ? this._liveCtxBind(ctx,e,data,fn,fnCtx) : this.__base(ctx,e,data,fn);
}
,
un: function (ctx, e, fn, fnCtx) {
return ctx.jquery ? this._liveCtxUnbind(ctx,e,fn,fnCtx) : this.__base(ctx,e,fn);
}
,
liveCtxBind: function (ctx, e, data, fn, fnCtx) {
return this._liveCtxBind(ctx,e,data,fn,fnCtx);
}
,
_liveCtxBind: function (ctx, e, data, fn, fnCtx) {
var _this = this;
if (typeof e == "string")
{
if ($.isFunction(data))
{
fnCtx = fn;
fn = data;
data = undefined;
}

if (e.indexOf(" ") > - 1)
{
e.split(" ").forEach(function (e) {
_this._liveCtxBind(ctx,e,data,fn,fnCtx);
}
);
}
 else
{
var ctxE = _this._buildCtxEventName(e), storage = liveEventCtxStorage[ctxE] || (liveEventCtxStorage[ctxE] = {
counter: 0,
ctxs: {
}});
ctx.each(function () {
var ctxId = $.identify(this), ctxStorage = storage.ctxs[ctxId];
if (! ctxStorage)
{
ctxStorage = storage.ctxs[ctxId] = {
};
++storage.counter;
}

ctxStorage[$.identify(fn) + (fnCtx ? $.identify(fnCtx) : "")] = {
fn: fn,
data: data,
ctx: fnCtx};
}
);
}

}
 else
{
$.each(e,function (e, fn) {
_this._liveCtxBind(ctx,e,fn,data);
}
);
}

return _this;
}
,
liveCtxUnbind: function (ctx, e, fn, fnCtx) {
return this._liveCtxUnbind(ctx,e,fn,fnCtx);
}
,
_liveCtxUnbind: function (ctx, e, fn, fnCtx) {
var _this = this, storage = liveEventCtxStorage[e = _this._buildCtxEventName(e)];
if (storage)
{
ctx.each(function () {
var ctxId = $.identify(this,true), ctxStorage;
if (ctxId && (ctxStorage = storage.ctxs[ctxId]))
{
fn && delete ctxStorage[$.identify(fn) + (fnCtx ? $.identify(fnCtx) : "")];
if (! fn || $.isEmptyObject(ctxStorage))
{
storage.counter--;
delete storage.ctxs[ctxId];
}

}

}
);
storage.counter || delete liveEventCtxStorage[e];
}

return _this;
}
,
_extractElemNameFrom: function (elem) {
if (elem.__bemElemName)
return elem.__bemElemName;
var matches = elem[0].className.match(this._buildElemNameRE());
return matches ? matches[1] : undefined;
}
,
extractParams: extractParams,
_buildModClassPrefix: function (modName, elem) {
return buildClass(this._name) + (elem ? ELEM_DELIM + (typeof elem === "string" ? elem : this._extractElemNameFrom(elem)) : "") + MOD_DELIM + modName + MOD_DELIM;
}
,
_buildModValRE: function (modName, elem, quantifiers) {
return new RegExp("(\\s|^)" + this._buildModClassPrefix(modName,elem) + "(" + NAME_PATTERN + ")(?=\\s|$)", quantifiers);
}
,
_buildElemNameRE: function () {
return new RegExp(this._name + ELEM_DELIM + "(" + NAME_PATTERN + ")(?:\\s|$)");
}
,
buildSelector: function (elem, modName, modVal) {
return "." + buildClass(this._name,elem,modName,modVal);
}
,
getBlockByUniqId: function (uniqId) {
return uniqIdToBlock[uniqId];
}
,
getWindowSize: function () {
return {
width: win.width(),
height: win.height()};
}
});
$(function () {
BEM.DOM.scope = $("body");
}
);
}
)(BEM,jQuery);
;
(function () {
String.prototype.trim || (String.prototype.trim = function () {
var str = this.replace(/^\s\s*/,""), ws = /\s/, i = str.length;
while (ws.test(str.charAt(--i))) ;
return str.slice(0,i + 1);
}
);
}
)();
;
(function (Lego) {
if (! Lego)
Lego = window.Lego = {
};
Lego.isSessionValid = function () {
return ! ! Lego.getCookie("yandex_login");
}
;
}
)(window.Lego);
;
BEM.DOM.decl("i-global",{
onSetMod: {
"js": function () {
this.del(this.__self._params = $.extend({
},this.params),"uniqId","name");
var params = this.__self._params;
params["passport-msg"] || (params["passport-msg"] = params.id);
if (params["show-counters"] === undefined)
{
params["show-counters"] = Math.round(Math.random() * 100) <= params["show-counters-percent"];
}

params.locale = params.lang;
$(function () {
params.oframebust && Lego.oframebust(params.oframebust);
}
);
}
},
getDefaultParams: function () {
return {
id: "",
login: Lego.isSessionValid() ? $.cookie("yandex_login") || "" : "",
yandexuid: $.cookie("yandexuid"),
lang: "ru",
retpath: window.location.toString(),
"passport-host": "https://passport.yandex.ru",
"pass-host": "//pass.yandex.ru",
"social-host": "//social.yandex.ru",
"lego-path": "/lego",
"show-counters-percent": 100};
}
},{
param: function (name) {
return (this._params || {
})[name];
}
});
;
(function (Lego) {
if (! Lego)
Lego = window.Lego = {
};
! Lego.params && (Lego.params = {
});
function preparseHost(h) {
return h.replace(/^(?:https?:)?\/\//,"");
}

Lego.c = function (w, a, opts) {
var host = preparseHost(opts && opts.host || BEM.blocks["i-global"].param("click-host") || "clck.yandex.ru"), url = function (w, h, t, a) {
h = h.replace("'","%27");
return h.indexOf("/dtype=") > - 1 ? h : location.protocol + "//" + host + "/" + t + "/dtype=" + w + "/rnd=" + ((new Date()).getTime() + Math.round(Math.random() * 100)) + (a ? "/*" + (h.match(/^http/) ? h : location.protocol + "//" + location.host + (h.match("^/") ? h : "/" + h)) : "/*data=" + encodeURIComponent("url=" + encodeURIComponent(h.match(/^http/) ? h : location.protocol + "//" + location.host + (h.match("^/") ? h : "/" + h))));
}
, click = function () {
var head = document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0];
var script = document.createElement("script");
script.setAttribute("src",url(w,location.href,"jclck"));
head.insertBefore(script,head.firstChild);
}
;
if (a)
{
if (a.className.match(/b-link_pseudo_yes/) || a.href && a.href.match(/^mailto:/) || opts && opts.noRedirect === true)
{
click();
}
 else
if (a.href)
{
var h = a.href;
a.href = url(w,h,"redir");
setTimeout(function () {
a.href = h;
}
,500);
}
 else
if (a.form)
{
if (a.type.match(/submit|button|image/))
{
var h = a.form.action;
a.form.action = url(w,h,"redir",true);
setTimeout(function () {
a.form.action = h;
}
,500);
}
 else
{
click();
}

}
 else
if (a.action)
{
a.action = url(w,a.action,"redir",true);
}
 else
{
throw "counter.js: not link and not form!";
}

}
 else
{
click();
}

}
;
}
)(window.Lego);
(function (Lego) {
if (! Lego)
Lego = window.Lego = {
};
Lego.cp = function (pi, ci, p, a, opts) {
Lego.c("stred/pid=" + pi + "/cid=" + ci + (p ? "/path=" + p : ""),a,opts);
}
;
}
)(window.Lego);
(function (Lego) {
if (! Lego)
Lego = window.Lego = {
};
Lego.ch = function (p, a) {
BEM.blocks["i-global"].param("show-counters") && Lego.cp(0,2219,p,a);
}
;
}
)(window.Lego);
;
(function (Lego) {
if (! Lego)
Lego = window.Lego = {
};
Lego.getCookie = function (n) {
var c = document.cookie;
if (c.length < 1)
return false;
var b = c.indexOf(n + "=");
if (b == - 1)
return false;
b += n.length + 1;
var e = c.indexOf(";",b);
return decodeURIComponent(e == - 1 ? c.substring(b) : c.substring(b,e));
}
;
}
)(window.Lego);
;
(function ($, Lego) {
if (! Lego)
Lego = window.Lego = {
};
Lego.init || (Lego.init = function (params) {
(params = Lego.params = $.extend({
id: "",
login: Lego.isSessionValid() ? Lego.getCookie("yandex_login") || "" : "",
yandexuid: Lego.getCookie("yandexuid"),
locale: "ru",
retpath: window.location.toString(),
"passport-host": "//passport.yandex.ru",
"pass-host": "//pass.yandex.ru",
"passport-msg": params.id,
"social-host": "//social.yandex.ru",
"lego-path": "/lego",
"show-counters-percent": 100},params,Lego.params))["show-counters"] = Math.round(Math.random() * 100) <= params["show-counters-percent"];
BEM.blocks["i-global"]._params || $.extend(BEM.blocks["i-global"]._params = {
},params);
$(function () {
params.oframebust && Lego.oframebust(params.oframebust);
}
);
return params;
}
);
Lego.block || (Lego.block = {
});
Lego.blockInit || (Lego.blockInit = function (context, blockSelector) {
context = context || document;
blockSelector = blockSelector || ".g-js";
$(context).find(blockSelector).each(function () {
var block = $(this), params = this.onclick ? this.onclick() : {
}, name = params.name || "", init = Lego.block[name];
if (init && ! block.data(name))
{
init.call(block,params);
block.data(name,true).addClass(name + "_js_inited");
}

}
);
}
);
Lego.blockInitBinded || (Lego.blockInitBinded = ! ! $(document).ready(function () {
Lego.blockInit();
}
));
}
)(jQuery,window.Lego);
;
(function (Lego) {
if (! Lego)
Lego = window.Lego = {
};
Lego.messages = Lego.messages || {
};
Lego.message = function (id, text) {
return Lego.params.locale == "ru" ? text : Lego.messages[id] || text;
}
;
}
)(window.Lego);
;
$(function () {
BEM.DOM.init();
}
);
;
(function () {
window.console = window.console;
(function () {
var map = {
"&": "&amp;",
"  ": "&nbsp; ",
"<": "&lt;",
">": "&gt;",
"\n": "<br />",
"\r\n": "<br />",
"\"": "&quot;"};
var map2 = {
"&amp;": "&",
"&nbsp;": " ",
"&lt;": "<",
"&gt;": ">",
"<br />": "\n",
"<br/>": "\n",
"<br>": "\n",
"&quot;": "\""};
var funcReplace = function (str) {
return map[str];
}
;
var funcReplace2 = function (str) {
return map2[str.toLowerCase()];
}
;
String.prototype.toHTML = function () {
return this.replace(/&|  |<|>|\r\n|\n|"|"/g,funcReplace);
}
;
String.prototype.fromHTML = function () {
return this.replace(/&amp;|&nbsp;|&lt;|&gt;|<(br|BR)\s*\/?>|&quot;/g,funcReplace2);
}
;
}
)();
Function.empty = function () {

}
;
Function.prototype.callbackDelay = function (minTimeout) {
if (! minTimeout || minTimeout < 1)
{
return this;
}

var endTime = (new Date()).valueOf() + minTimeout;
var func = this;
return function () {
var interval = endTime - (new Date()).valueOf();
var args = arguments, self = this;
if (interval > 0)
{
setTimeout(function () {
func.apply(self,args);
}
,interval);
}
 else
{
func.apply(self,args);
}

}
;
}
;
BEM.decl("i-widget-helper",{
},{
_localStringPrefix: "",
_initialized: false,
init: function (platform, localStringPrefix) {
if (this._initialized)
{
return this;
}

this._initialized = true;
this._platform = platform;
this._localStringPrefix = localStringPrefix || "";
BEM.I18N.lang(platform.language);
var self = this;
this._helperPlatformListener = function (message) {
if (! message)
{
return;
}

var topic, data;
try {
topic = message.message || message;
data = message.data || null;
self._platform.logger.debug("getMessage::",topic,data);
}
catch (exc) {
self._platform.logger.error("[slice] onMessage: parameter error");
return;
}

self.fireEvent(topic,data);
}
;
this._platform.onMessage.addListener(this._helperPlatformListener);
var notunloaded = true;
function unload() {
if (notunloaded)
{
try {
self.clearInterval();
self._removePlatformListener();
notunloaded = false;
}
catch (exc) {

}

}

}

window.onunload = unload;
window.onbeforeunload = unload;
jQuery.ajaxSetup({
crossDomain: false,
xhr: function () {
return new platform.XMLHttpRequest();
}
});
if (! this._enableContextMenu)
{
document.oncontextmenu = function (e) {
e = e || window.event;
var tag = (e.target || e.srcElement).tagName;
return tag === "INPUT" || tag === "TEXTAREA";
}
;
window.onerror = function (e, ur, ln) {
return false;
}
;
}

;
return this;
}
,
setInterval: function (ms) {
this.clearInterval();
var curtime = (new Date()).valueOf();
var self = this;
this._workTimer = setInterval(function () {
var time = (new Date()).valueOf();
self.fireEvent(":timer",time - curtime);
curtime = time;
}
,ms || 10);
}
,
clearInterval: function () {
if (this._workTimer)
{
clearInterval(this._workTimer);
this._workTimer = null;
}

}
,
logDebug: function (str) {
this._platform.logger.debug(str);
}
,
logError: function (str) {
this._platform.logger.error(str);
}
,
branding: function (conf) {
if (! conf.current)
{
conf.current = {
};
var bran = (conf.branding || {
})[this._platform.brandID];
$.extend(conf.current,conf.common || {
},bran || {
});
}

return conf.current;
}
,
getScript: function (url, callback) {
this.ajax({
type: "GET",
url: url,
success: callback,
dataType: "script"});
}
,
ajax: function (config, attemptsCount) {
attemptsCount = attemptsCount || 1;
if (config.dataType == "script" || config.dataType == "jsonp")
{
config.crossDomain = true;
}

function request() {
attemptsCount--;
return $.ajax(config);
}

if (attemptsCount > 1)
{
var oldError = config.error || Function.empty;
config.error = function () {
if (attemptsCount)
{
request();
}
 else
{
oldError.apply(this,arguments);
}

}
;
}

request();
}
,
getCookie: function (url, name, http) {
if (! /^https?:/.test(url))
{
url = "http://" + url;
}

return this._platform.getCookie(url,name,! ! http);
}
,
openSettings: function () {
if (! window.closed)
{
window.close();
}

this._platform.showSettings();
}
,
parseDate: function (str) {
if (typeof str !== "string" || ! str)
{
return str;
}

var i, part = str.match(/\d+/g);
for (i = 0;i < part.length;++i) {
part[i] = parseInt(part[i],10);
}

return new Date(part[0], part[1] - 1, part[2], part[3], part[4], part[5]);
}
,
openNewTab: function (url) {
this._platform.navigate(url,"new tab");
window.close();
}
,
localStr: function (key) {
var str = this._platform.getLocalizedString(this._localStringPrefix + key) || "";
if (! str)
{
this._platform.logger.error("[slice] getLocalizedString: (" + this.lang() + ") empty string \"" + this._localStringPrefix + key + "\"");
}

return str;
}
,
lang: function () {
return this._platform.language;
}
,
getParam: function (param, url) {
return (RegExp("[?&]" + param + "=([^&#]*)","i").exec(url || document.location.href) || "")[1] || "";
}
,
platformLocalization: function (mainBlock) {
if (mainBlock.platform_i18n)
{
mainBlock.platform_i18n(this);
}

for(var bl in BEM.blocks) {
if (/^b-/.test(bl))
{
var blocks = mainBlock.findBlocksInside(bl);
if (blocks)
{
for (var i = 0;i < blocks.length;++i) {
if (blocks[i].platform_i18n)
{
blocks[i].platform_i18n(this,i);
}

}

}

}

}

}
,
logAction: function (actionCode) {
this._platform.logCustomAction(actionCode);
}
,
_helperPlatformListener: null,
_pltfListeners: {
},
_removePlatformListener: function () {
if (this._helperPlatformListener)
{
this._platform.onMessage.removeListener(this._helperPlatformListener);
this._helperPlatformListener = null;
}

}
,
reloadSlice: function () {
this._removePlatformListener();
window.location.reload(true);
}
,
removeListener: function (topic, callback) {
if (! this._pltfListeners[topic])
{
return;
}

if (! callback)
{
this._pltfListeners[topic] = null;
}
 else
{
var listeners = this._pltfListeners[topic];
for (var i = 0;i < listeners.length;++i) {
if (listeners[i].func == callback)
{
listeners.splice(i,1);
--i;
}

}

}

}
,
addListener: function (topic, callback, scope) {
this._pltfListeners[topic] = this._pltfListeners[topic] || [];
this._pltfListeners[topic].push({
func: callback,
scope: scope});
return this;
}
,
addBlockListeners: function (block) {
var handlers = block.handlers;
if (handlers && ! block.__addBlockListeners_called)
{
for(var i in handlers) {
if (handlers.hasOwnProperty(i))
{
var val = handlers[i];
if (typeof val == "string" && handlers.hasOwnProperty(val))
{
val = handlers[val];
}

if (typeof val == "function")
{
this.addListener(i,val,block);
}

}

}

block.__addBlockListeners_called = true;
}

return this;
}
,
initAllHandlers: function (mainBlock) {
this.addBlockListeners(mainBlock);
for(var bl in BEM.blocks) {
if (/^b-/.test(bl))
{
var blocks = mainBlock.findBlocksInside(bl);
if (blocks)
{
for (var i = 0;i < blocks.length;++i) {
this.addBlockListeners(blocks[i]);
}

}

}
 else
{
if (/^i-/.test(bl))
{
this.addBlockListeners(BEM.blocks[bl]);
}

}

}

}
,
sendMessage: function (msg, data) {
var obj = {
message: msg};
if (data !== undefined)
{
obj.data = data;
}

this._platform.sendMessage(obj);
}
,
fireEvent: function (topic, data) {
var listeners = this._pltfListeners[topic];
if (listeners)
{
for (var i = 0;i < listeners.length;++i) {
var ret = listeners[i].func.call(listeners[i].scope || window,topic,data);
if (ret === false)
{
break;
}

}

}

}
,
md5: function (str, callback, scope) {
this.addListener("md5",function md5Callback(topic, data) {
if (typeof callback === "function")
scope ? callback.call(scope,data) : callback(data);
this.removeListener("md5",md5Callback);
}
,this);
window.platform.sendMessage({
message: "md5",
data: str});
}
,
shuffle: function (inArray) {
var outArray = Array.prototype.slice.call(inArray);
for (var j, x, i = outArray.length;i;(j = parseInt(Math.random() * i), x = outArray[--i], outArray[i] = outArray[j], outArray[j] = x)) ;
return outArray;
}
});
}
)();
;
(function ($) {
BEM.decl("i-widget-weather",{
},{
init: function (platform) {
this._platform = platform;
this._helper = BEM.blocks["i-widget-helper"];
this._config = BEM.blocks["i-widget-weather__config"].current;
this._updating = false;
this._update();
}
,
handlers: {
"update": function () {
this._update();
}
},
_update: function () {
if (this._updating)
{
return;
}

this._updating = true;
this._helper.fireEvent("w:loading");
var self = this;
$.ajax({
url: this._config.EXPORT_URL,
data: {
region: this._helper.getParam("region"),
lang: this._platform.language,
brid: this._platform.brandID,
_rand: Math.round((new Date()).valueOf() / 7000)},
dataType: "xml",
success: function (data) {
self._updating = false;
data = self._extractData(data);
if (data)
{
self._helper.fireEvent("w:data",data);
self._helper.fireEvent("w:resize",self._config.windowSize);
}
 else
{
self._helper.fireEvent("w:error","server");
self._helper.fireEvent("w:resize",self._config.windowSize);
}

}
,
error: function (jqXHR, textStatus) {
self._updating = false;
var status = jqXHR.status;
var errorType = status < 200 || status > 600 ? "net" : "server";
self._helper.fireEvent("w:error",errorType);
self._helper.fireEvent("w:resize",self._config.windowSize);
}
});
}
,
_extractData: function (xml) {
var weatherNode = $("info>weather",xml);
if (! weatherNode.length)
{
return null;
}

var day = weatherNode.children("day");
var dparts = day.children("day_part");
var dpart = dparts.eq(0);
var temp = dpart.children("temperature");
var r = {
now: {
url: weatherNode.children("url").text() + "?elmt=pogoda",
title: day.children("title").text(),
temp: this._temperature(temp.text()),
bgcolor: "#" + temp.attr("color"),
color: "#" + this._divColor(temp.attr("color"),2),
img: dpart.children("image-v3[size=\"48x48\"]").text(),
more: dpart.children("weather_type").text(),
windDir: dpart.children("wind_direction").attr("id"),
windSpeed: dpart.children("wind_speed").text(),
dampness: dpart.children("dampness").text(),
pressure: dpart.children("pressure").text()},
period: []};
var dpTypes = ["", "morning", "day", "evening", "night"];
for (var i = 1;i < dparts.length;++i) {
dpart = dparts.eq(i);
var tem1 = dpart.children("temperature_from");
var tem2 = dpart.children("temperature_to");
var tem0 = tem1.length && tem2.length ? null : dpart.children("temperature");
var bgcolor = tem0 ? tem0.attr("color") : this._avgColor(tem1.attr("color"),tem2.attr("color"));
r.period.push({
type: dpTypes[dpart.attr("typeid")],
img: dpart.children("image-v3[size=\"30x30\"]").text(),
hint: "",
temp: this._temperature(tem0 ? tem0.text() : this._avgTemp(tem1.text(),tem2.text())),
bgcolor: "#" + bgcolor,
color: "#" + this._divColor(bgcolor,2)});
}

return r;
}
,
_temperature: function (t) {
return t ? this._config.formatTemperature(t,this._helper.lang()) : "";
}
,
_divColor: function (color, k) {
return color.replace(/../g,function (m) {
var r = Math.round(parseInt(m,16) / k).toString(16);
return r.length > 1 ? r : "0" + r;
}
);
}
,
_avgColor: function (c1, c2) {
var r = "";
for (var i = 0;i < 6;i += 2) {
var c = Math.round((parseInt(c1.substr(i,2),16) + parseInt(c2.substr(i,2),16)) / 2).toString(16);
r += c.length > 1 ? c : "0" + c;
}

return r;
}
,
_avgTemp: function (t1, t2) {
return Math.round((parseInt(t1,10) + parseInt(t2,10)) / 2).toString(10).replace(/^([1-9])/,"+$1");
}
});
}
)(jQuery);
;
(function () {
BEM.decl("i-widget-weather__config",{
},{
current: null,
common: {
EXPORT_URL: "http://export.yandex.ru/bar/reginfo.xml",
formatTemperature: function (t, lang) {
return t;
}
,
pressureUnit: "mm",
windowSize: [480, 560]},
branding: {
tb: {
EXPORT_URL: "http://export.yandex.com.tr/bar/reginfo.xml",
formatTemperature: function (t, lang) {
return t.replace(/^\+/,"");
}
,
pressureUnit: "hpa"},
ua: {
EXPORT_URL: "http://export.yandex.ua/bar/reginfo.xml"}}});
}
)();
;
(function ($) {
BEM.DOM.decl("b-weather-widget",{
onSetMod: {
js: function () {
if (this._initialized)
{
return;
}

this._initialized = true;
var self = this;
var loadListener = function () {
$(window).unbind("load",loadListener);
self.__init();
}
;
$(window).bind("load",loadListener);
}
},
__init: function (helper) {
this._helper = BEM.blocks["i-widget-helper"];
this._widget = BEM.blocks["i-widget-weather"];
this._configs = BEM.blocks["i-widget-weather__config"];
if (window.parent && window.parent.__debug_Tools_)
{
window.parent.__debug_Tools_(this,window);
}

if (! window.platform)
{
window.platform = window.external;
}

var platform = window.platform;
this._platform = platform;
this._helper.init(platform,"slice.weather.");
this.config = this._helper.branding(this._configs);
this._helper.platformLocalization(this);
this._helper.initAllHandlers(this);
this._resize();
this._widget.init(platform);
}
,
_resize: function () {
try {
this._platform.resizeWindowTo(this.domElem.width(),this.domElem.height());
}
catch (e) {
this._platform.logger.error("weather slice: resizeWindowTo failed");
}

}
,
handlers: {
"w:loading": function (t, data) {
this.setMod("type","loading");
}
,
"w:data": function (t, data) {
this.setMod("type","loaded");
}
,
"w:resize": function (t, data) {
this._resize();
}
,
"w:error": function (t, error) {
this.elem("error").html(BEM.I18N("b-weather","error." + error).replace(/##/g,"<br />"));
this.setMod("type","error");
}
}},{
});
}
)(jQuery);
;
(function ($) {
BEM.DOM.decl("b-weather-details",{
handlers: {
"w:data": function (t, data) {
var type = this.getMod("type");
this._setData[type].call(this,data[type]);
}
},
_setData: {
now: function (data) {
this.elem("title").text(data.title).css("color",data.color);
this.elem("temp").text(data.temp);
this.elem("icon").attr("title",data.more).css("backgroundImage","url(\"" + data.img + "\")");
this.elem("more").text(data.more);
}
,
period: function (data) {
var helper = BEM.blocks["i-widget-helper"];
var items = this.elem("item");
var heads = this.elem("head");
var whens = this.elem("when");
var icons = this.elem("icon");
var temps = this.elem("temp");
for (var i = 0;i < data.length;++i) {
this.setMod(items.eq(i),"time",data[i].type);
whens[i].parentNode.style.background = data[i].bgcolor;
heads.eq(i).text(data[i].type == "morning" ? BEM.I18N("b-weather","tomorrow") : i == 0 ? BEM.I18N("b-weather","today") : "");
whens.eq(i).text(BEM.I18N("b-weather","dp." + data[i].type)).css("color",data[i].color);
icons[i].style.backgroundImage = "url(\"" + data[i].img + "\")";
if (data[i].hint)
{
icons[i].title = data[i].hint;
}

temps.eq(i).text(data[i].temp);
}

}
}},{
});
}
)(jQuery);
;
(function ($) {
BEM.DOM.decl("b-weather-alert",{
handlers: {
"w:data": function (t, data) {
if (data.alert)
{
this.elem("text").text(data.alert.text);
this.delMod("hidden");
}
 else
{
this.setMod("hidden","yes");
}

}
}},{
});
}
)(jQuery);
;
(function ($) {
BEM.DOM.decl("b-weather",{
platform_i18n: function (helper) {
this._helper = helper;
this._config = BEM.blocks["i-widget-weather__config"].current;
var info = this.elem("info");
var nums = this.elem("num");
this._numWind = nums.eq(0);
this._numDampness = nums.eq(1);
this._numPressure = nums.eq(2);
this._link = this.findBlockInside(this.elem("foot"),"b-link").domElem;
info.eq(0).text(BEM.I18N("b-weather","wind"));
info.eq(1).text(BEM.I18N("b-weather","dampness"));
info.eq(2).text(BEM.I18N("b-weather","pressure"));
this._link.text(BEM.I18N("b-weather","url.title"));
var self = this;
this._link.click(function (e) {
e.preventDefault();
self._helper.logAction(11);
self._helper.openNewTab(this.href);
return false;
}
);
}
,
_windDirMap: {
sw: 5,
nw: 21,
ne: 37,
se: 52,
s: 69,
w: 85,
n: 101,
e: 117},
handlers: {
"w:data": function (t, data) {
data = data.now;
this._numWind.text(data.windSpeed.replace(/(\.|0)0*$/,"") + " " + BEM.I18N("b-weather","wind.ms"));
this._numWind.css("backgroundPosition","9px " + (11 - (this._windDirMap[data.windDir] || 5)) + "px");
this._numDampness.text(data.dampness + "%");
this._numPressure.text(data.pressure + " " + BEM.I18N("b-weather","pressure." + this._config.pressureUnit));
this._link.attr("href",data.url);
}
}},{
});
}
)(jQuery);
;
BEM.HTML.decl("b-link",{
onBlock: function (ctx) {
ctx.tag("a").attr("href",ctx.param("url"));
var props = ["title", "target"], p;
while (p = props.pop()) ctx.param(p) && ctx.attr(p,ctx.param(p));
}
});
;
(function ($) {
BEM.DOM.decl("b-weather-gradient",{
handlers: {
"w:data": function (t, data) {
this._setBGColor(data.now.bgcolor);
}
},
_setBGColor: function (c) {
var elem = this.domElem[0].style;
var arr = ["progid:DXImageTransform.Microsoft.gradient(startColorstr='" + c + "', endColorstr='#ffffff',GradientType=0)", "-webkit-linear-gradient(bottom, #fff, " + c + ")", "-moz-linear-gradient(bottom, #fff, " + c + ")", "-ms-linear-gradient(bottom, #fff, " + c + ")", "-o-linear-gradient(bottom, #fff, " + c + ")"];
var isIE = /MSIE\s(\d+)/i.test(navigator.userAgent);
if (isIE)
{
if (parseInt(RegExp.$1,10) > 9)
{
elem.background = arr[3];
}
 else
{
elem.filter = arr[0];
}

}
 else
{
var isFF = /Firefox/i.test(navigator.userAgent) ? 2 : 0;
var isO = /Opera/i.test(navigator.userAgent) ? 4 : 0;
var isWebKit = /WebKit/i.test(navigator.userAgent) ? 1 : 0;
elem.background = arr[isFF || isO || isWebKit];
}

}
},{
});
}
)(jQuery);
;
(function (global_, bem_, undefined) {
if (typeof bem_.I18N === "function" && bem_.I18N._proto)
{
return bem_.I18N;
}

if (typeof i18n === "undefined")
{
i18n = {
};
}

BEM = bem_;
var MOD_DELIM = "_", ELEM_DELIM = "__", DEFAULT_LANG = "ru", cache = {
}, stack = [], log = typeof console !== "undefined" && console.log ? console.log.bind(console) : function () {

}
;
function bemName(decl) {
typeof decl === "string" && (decl = {
block: decl});
return decl.block + (decl.elem ? ELEM_DELIM + decl.elem : "") + (decl.modName ? MOD_DELIM + decl.modName + MOD_DELIM + decl.modVal : "");
}

function bemParse(name) {
var bemitem = {
};
name.split(ELEM_DELIM).forEach(function (item, i) {
var keys = [i ? "elem" : "block", "mod", "val"];
item.split(MOD_DELIM).forEach(function (part, j) {
bemitem[keys[j]] = part;
}
);
}
);
return bemitem;
}

function _pushStack(name) {
if (! name)
return false;
return stack.push(name);
}

function _popStack() {
return stack.length && stack.pop();
}

function _i18n() {
this._lang = "";
this._prj = "lego";
this._keyset = "";
this._key = "";
}

_i18n.prototype = {
lang: function (name) {
this._lang = name;
return this;
}
,
project: function (name) {
this._prj = name;
return this;
}
,
keyset: function (name, saveCtx) {
saveCtx && _pushStack(this._keyset);
this._keyset = bemName(name);
return this;
}
,
key: function (name) {
this._key = name;
return this;
}
,
decl: function (v) {
var bemitem = bemParse(this._keyset), prj = bemitem.block === "i-tanker" ? "tanker" : this._prj, keyset = bemitem.elem || this._keyset, key = this._key;
prj = i18n[prj] || (i18n[prj] = {
});
keyset = prj[keyset] || (prj[keyset] = {
});
keyset[key] = typeof v === "function" ? v : function (p) {
return v;
}
;
var l = cache[this._lang] || (cache[this._lang] = {
}), k = l[this._keyset] || (l[this._keyset] = {
});
k[key] = v;
}
,
val: function (params, ctx) {
var value = cache[this._lang] && cache[this._lang][this._keyset], debugString = "keyset: " + this._keyset + " key: " + this._key + " (lang: " + this._lang + ")";
if (! value)
{
log("[I18N_NO_KEYSET] %s",debugString);
return "";
}

value = value[this._key];
var valtype = typeof value;
if (valtype === "undefined")
{
log("[I18N_NO_VALUE] %s",debugString);
return "";
}

if (valtype === "string")
{
return value;
}

ctx || (ctx = this);
return value.call(ctx,params);
}
,
_cache: function () {
return cache;
}
};
bem_.I18N = (function (base) {
var klass = function (keyset, key, params) {
return klass.keyset(keyset).key(key,params);
}
;
klass._proto = base;
klass.project = function (name) {
this._proto.project(name);
return this;
}
;
klass.keyset = function (name) {
this._proto.keyset(name,true);
return this;
}
;
klass.key = function (name, params) {
var proto = this._proto, result, ksetRestored;
proto.lang(this._lang).key(name);
result = proto.val.call(proto,params,klass);
ksetRestored = _popStack();
ksetRestored && proto.keyset(ksetRestored,false);
return result;
}
;
klass.decl = function (bemitem, keysets, params) {
var proto = this._proto, k;
params || (params = {
});
params.lang && proto.lang(params.lang);
proto.keyset(bemitem);
for(k in keysets) {
if (keysets.hasOwnProperty(k))
{
proto.key(k).decl(keysets[k]);
}

}

return this;
}
;
klass.lang = function (lang) {
typeof lang !== "undefined" && (this._lang = lang);
return this._lang;
}
;
klass.lang(DEFAULT_LANG);
return klass;
}
)(new _i18n());
}
)(this,typeof BEM === "undefined" ? {
} : BEM);
(function (bem_, undefined) {
var DEFAULT_BRAND = null;
var base = bem_.I18N._i18n;
bem_.I18N.brand = (function () {
var _brand = DEFAULT_BRAND;
var klass = function (brand) {
base.setDeclProp("brand",brand);
}
;
return klass;
}
)();
}
)(typeof BEM === "undefined" ? {
} : BEM);
BEM.I18N.decl("b-weather",{
"dampness": "Влажность",
"dp.day": "Днем",
"dp.evening": "Вечером",
"dp.morning": "Утром",
"dp.night": "Ночью",
"error.net": "Интернет##не подключен",
"error.server": "Отсутствует связь с сервером.##Попробуйте позднее",
"pressure": "Давление",
"pressure.hpa": "гПа",
"pressure.mm": "мм рт. ст.",
"settings": "Настройки",
"title": "Виджет погоды",
"today": "Сегодня",
"tomorrow": "Завтра",
"url.title": "Прогноз на 10 дней",
"wind": "Ветер",
"wind.ms": "м/с"},{
"lang": "ru"});
BEM.I18N.decl("b-weather",{
"dampness": "Humidity",
"dp.day": "Day",
"dp.evening": "Evening",
"dp.morning": "Morning",
"dp.night": "Night",
"error.net": "No##internet connection",
"error.server": "No server connection.##Please try again later",
"pressure": "Pressure",
"pressure.hpa": "hPa",
"pressure.mm": "mm Hg",
"settings": "Settings",
"title": "Weather widget",
"today": "Today",
"tomorrow": "Tomorrow",
"url.title": "10-day forecast",
"wind": "Wind",
"wind.ms": "m/s"},{
"lang": "en"});
BEM.I18N.decl("b-weather",{
"dampness": "Nem",
"dp.day": "Gündüz",
"dp.evening": "Akşam",
"dp.morning": "Sabah",
"dp.night": "Gece",
"error.net": "İnternet##bağlantısı yok",
"error.server": "Sunucu bağlantısı yok.##Daha sonra deneyin",
"pressure": "Basınç",
"pressure.hpa": "hPa",
"pressure.mm": "hPa",
"settings": "Ayarlar",
"title": "Hava durumu widgeti",
"today": "Bugün",
"tomorrow": "Yarın",
"url.title": "10 günlük hava tahmini",
"wind": "Rüzgar",
"wind.ms": "m/sn"},{
"lang": "tr"});
BEM.I18N.decl("b-weather",{
"dampness": "Ылғалдығы",
"dp.day": "Күндіз",
"dp.evening": "Кешке",
"dp.morning": "Таң ертең",
"dp.night": "Түнде",
"error.net": "Интернет##қосылмаған",
"error.server": "Сервермен қосылыс жоқ.##Кейінірек сынап көріңіз",
"pressure": "Ауа қысымы",
"pressure.hpa": "гПа",
"pressure.mm": "мм сын. бағ.",
"settings": "Баптаулар",
"title": "Ауа-райы виджеті",
"today": "Бүгін",
"tomorrow": "Ертең",
"url.title": "10 күндік болжам",
"wind": "Жел",
"wind.ms": "м/с"},{
"lang": "kk"});
BEM.I18N.decl("b-weather",{
"dampness": "Вологість",
"dp.day": "Вдень",
"dp.evening": "Увечері",
"dp.morning": "Зранку",
"dp.night": "Вночі",
"error.net": "Інтернет##не підключено",
"error.server": "Немає зв'язку із сервером.##Спробуйте пізніше",
"pressure": "Тиск",
"pressure.hpa": "гПа",
"pressure.mm": "мм рт. ст.",
"settings": "Налаштування",
"title": "Віджет погоди",
"today": "Сьогодні",
"tomorrow": "Завтра",
"url.title": "Прогноз на 10 днів",
"wind": "Вітер",
"wind.ms": "м/с"},{
"lang": "uk"});
BEM.I18N.decl("b-weather",{
"dampness": "Вільготнасць",
"dp.day": "Удзень",
"dp.evening": "Увечары",
"dp.morning": "Уранку",
"dp.night": "Уночы",
"error.net": "Інтэрнет##не далучаны",
"error.server": "Адсутнічае сувязь з серверам.##Паспрабуйце пазней",
"pressure": "Ціск",
"pressure.hpa": "гПа",
"pressure.mm": "мм рт. сл.",
"settings": "Наладкі",
"title": "Віджэт надвор'я",
"today": "Сёння",
"tomorrow": "Заўтра",
"url.title": "Прагноз на 10 дзён",
"wind": "Вецер",
"wind.ms": "м/с"},{
"lang": "be"});
