window.__debugMode = true; // Don't turn it off
var cur = {destroy: [], nav: []}; // Current page variables and navigation map.
var _ua = navigator.userAgent.toLowerCase();
var browser = {
version: (_ua.match( /.+(?:me|ox|on|rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
opera: /opera/i.test(_ua),
msie: (/msie/i.test(_ua) && !/opera/i.test(_ua)),
msie6: (/msie 6/i.test(_ua) && !/opera/i.test(_ua)),
msie7: (/msie 7/i.test(_ua) && !/opera/i.test(_ua)),
msie8: (/msie 8/i.test(_ua) && !/opera/i.test(_ua)),
msie9: (/msie 9/i.test(_ua) && !/opera/i.test(_ua)),
mozilla: /firefox/i.test(_ua),
chrome: /chrome/i.test(_ua),
safari: (!(/chrome/i.test(_ua)) && /webkit|safari|khtml/i.test(_ua)),
iphone: /iphone/i.test(_ua),
ipod: /ipod/i.test(_ua),
iphone4: /iphone.*OS 4/i.test(_ua),
ipod4: /ipod.*OS 4/i.test(_ua),
ipad: /ipad/i.test(_ua),
safari_mobile: /iphone|ipod|ipad/i.test(_ua),
android: /android/i.test(_ua),
opera_mobile: /opera mini|opera mobi/i.test(_ua),
mobile: /iphone|ipod|ipad|opera mini|opera mobi/i.test(_ua),
mac: /mac/i.test(_ua)
};
if (!window.vk) window.vk = {loginscheme: 'http', ip_h: ''};
(function() {
var flash = [0, 0, 0], axon = 'ShockwaveFlash.ShockwaveFlash';
var wrapType = 'embed', wrapParam = 'type="application/x-shockwave-flash" ';
var escapeAttr = function(v) {
return v.toString().replace('&', '&').replace('"', '"');
}
if (navigator.plugins && navigator.mimeTypes.length) {
var x = navigator.plugins['Shockwave Flash'];
if (x && x.description) {
var ver = x.description.replace(/([a-zA-Z]|\s)+/, '').replace(/(\s+r|\s+b[0-9]+)/, '.').split('.');
for (var i = 0; i < 3; ++i) flash[i] = ver[i] || 0;
}
} else {
if (_ua.indexOf('Windows CE') >= 0) {
var axo = true, ver = 6;
while (axo) {
try {
++ver;
axo = new ActiveXObject(axon + '.' + ver);
flash[0] = ver;
} catch(e) {}
}
} else {
try {
var axo = new ActiveXObject(axon + '.7');
flash = axo.GetVariable('$version').split(' ')[1].split(',');
} catch (e) {}
}
wrapType = 'object';
wrapParam = 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
}
browser.flashwrap = (wrapType == 'embed') ? function(opts, params) {
params = extend({
id: opts.id,
name: opts.id,
width: opts.width,
height: opts.height,
style: opts.style,
preventhide: opts.preventhide
}, params);
if (browser.flash >= opts.version) {
params.src = opts.url;
} else {
params.src = opts.express;
}
var paramsStr = [];
for (var i in params) {
var p = params[i];
if (p !== undefined && p !== null) {
paramsStr.push(i + '="' + escapeAttr(p) + '" ');
}
}
return '';
} : function(opts, params) {
if (browser.flash >= opts.version) {
params.movie = opts.url;
} else {
params.movie = opts.express;
}
var attr = {
id: opts.id,
width: opts.width,
height: opts.height,
style: opts.style,
preventhide: opts.preventhide
}
var attrStr = [];
for (var i in attr) {
var p = attr[i];
if (p !== undefined && p !== null) {
attrStr.push(i + '="' + escapeAttr(p) + '" ');
}
}
var paramsStr = [];
for (var i in params) {
var p = params[i];
if (p !== undefined && p !== null) {
paramsStr.push('');
}
}
return '';
}
if (flash[0] < 7) flash = [0, 0, 0];
browser.flash = intval(flash[0]);
browser.flashfull = {
major: browser.flash,
minor: intval(flash[1]),
rev: intval(flash[2])
}
})();
if (!browser.msie6) {
delete StaticFiles['ie6.css'];
}
if (!browser.msie7) {
delete StaticFiles['ie7.css'];
}
for (var i in StaticFiles) {
var f = StaticFiles[i];
f.t = (i.indexOf('.css') != -1) ? 'css' : 'js';
f.n = i.replace(/[\\/\\.]/g, '_');
f.l = 0;
f.c = 0;
}
window.locHost = location.host;
window.locProtocol = location.protocol;
window.__dev = /[a-z0-9_\-]+\.[a-z0-9_\-]+\.[a-z0-9_\-]+\.[a-z0-9_\-]+/i.test(locHost);
if (!__dev) __debugMode = false;
window.locHash = location.hash.replace('#/', '').replace('#!', '');
window.locDomain = locHost.toString().match(/[a-zA-Z]+\.[a-zA-Z]+\.?$/)[0];
window.locBase = location.toString().replace(/#.+$/, '');
if (!browser.msie6 || document.domain != locDomain) document.domain = locDomain;
function topMsg(text, seconds, color) {
if (!color) color = '#D6E5F7';
if (!text) {
hide('system_msg');
} else {
clearTimeout(window.topMsgTimer);
var el = ge('system_msg');
el.style.backgroundColor = color;
el.innerHTML = text;
show(el);
if (seconds) {
window.topMsgTimer = setTimeout(topMsg.pbind(false), seconds * 1000);
}
}
}
function topError(text, seconds) {
if (text.message) {
var e = text;
text = 'JavaScript error: ' + e.message;
if (e.stack && __debugMode) text += '
' + e.stack.replace(/\n/g, '
');
}
topMsg(text, seconds, '#FFB4A3');
}
function langNumeric(count, vars, formatNum) {
if (!vars || !window.langConfig) { return count; }
var res;
if (!isArray(vars)) {
result = vars;
} else {
res = vars[1];
if(count != Math.floor(count)) {
res = vars[langConfig.numRules['float']];
} else {
each(langConfig.numRules['int'], function(i,v){
if (v[0] == '*') { res = vars[v[2]]; return false; }
var c = v[0] ? count % v[0] : count;
if(indexOf(v[1], c) != -1) { res = vars[v[2]]; return false; }
});
}
}
if (formatNum) {
var n = count.toString().split('.'), c = [];
for(var i = n[0].length - 3; i > -3; i -= 3) {
c.unshift(n[0].slice(i > 0 ? i : 0, i + 3));
}
n[0] = c.join(langConfig.numDel);
count = n.join(langConfig.numDec);
}
res = (res || '%s').replace('%s', count);
return res;
}
function langSex(sex, vars) {
if (!isArray(vars)) return vars;
var res = vars[1];
if (!window.langConfig) return res;
each(langConfig.sexRules, function(i,v){
if (v[0] == '*') { res = vars[v[1]]; return false; }
if (sex == v[0] && vars[v[1]]) { res = vars[v[1]]; return false; }
});
return res;
}
function getLang() {
try {
var args = Array.prototype.slice.call(arguments);
var key = args.shift();
if (!key) return '...';
var val = (window.cur.lang && window.cur.lang[key]) || (window.lang && window.lang[key]) || (window.langpack && window.langpack[key]) || window[key];
if (!val) {
var res = key.split('_');
res.shift();
return res.join(' ');
}
if (isFunction(val)) {
return val.apply(null, args);
} else if (isArray(val)) {
return langNumeric(args[0], val, args[1]);
} else {
return val;
}
} catch(e) {
debugLog('lang error:' + e.message + '(' + Array.prototype.slice.call(arguments).join(', ') + ')');
}
}
// Debug Log
var _logTimer = (new Date()).getTime();
function debugLog(msg){
try {
var t = '[' + (((new Date()).getTime() - _logTimer) / 1000) + '] ';
if (ge('debuglog')) {
if (msg === null) {
msg = '[NULL]';
} else if (msg === undefined) {
msg = '[UNDEFINED]';
}
ge('debuglog').innerHTML += t + msg.toString().replace('<', '<').replace('>', '>')+'
';
}
if (window.console && console.log) {
Array.prototype.unshift.call(arguments, t);
console.log.apply(console, arguments);
}
} catch (e) {
}
}
// DOM
function ge(el) {
return (typeof el == 'string' || typeof el == 'number') ? document.getElementById(el) : el;
}
function geByTag(searchTag, node) {
return (node || document).getElementsByTagName(searchTag);
}
function geByTag1(searchTag, node) {
node = node || document;
return node.querySelector && node.querySelector(searchTag) || geByTag(searchTag, node)[0];
}
function geByClass(searchClass, node, tag) {
node = node || document;
tag = tag || '*';
var classElements = [];
if (node.querySelectorAll && tag != '*') {
return node.querySelectorAll(tag + '.' + searchClass);
}
if (node.getElementsByClassName) {
var nodes = node.getElementsByClassName(searchClass);
if (tag != '*') {
tag = tag.toUpperCase();
for (var i = 0, l = nodes.length; i < l; ++i) {
if (nodes[i].tagName.toUpperCase() == tag) {
classElements.push(nodes[i]);
}
}
} else {
classElements = Array.prototype.slice.call(nodes);
}
return classElements;
}
var els = geByTag(tag, node);
var pattern = new RegExp('(^|\\s)' + searchClass + '(\\s|$)');
for (var i = 0, l = els.length; i < l; ++i) {
if (pattern.test(els[i].className)) {
classElements.push(els[i]);
}
}
return classElements;
}
function geByClass1(searchClass, node, tag) {
node = node || document;
tag = tag || '*';
return node.querySelector && node.querySelector(tag + '.' + searchClass) || geByClass(searchClass, node, tag)[0];
}
function ce(tagName, attr, style) {
var el = document.createElement(tagName);
if (attr) extend(el, attr);
if (style) setStyle(el, style);
return el;
}
function re(el) {
el = ge(el);
if (el && el.parentNode) el.parentNode.removeChild(el);
return el;
}
function se(html) {return ce('div', {innerHTML: html}).firstChild;}
function rs(html, repl) {
each (repl, function (k, v) {
html = html.replace(new RegExp('%' + k + '%', 'g'), v);
});
return html;
}
function show(elem) {
if (arguments.length > 1) {
for (var i = 0; i < arguments.length; ++i) {
show(arguments[i]);
}
return;
}
elem = ge(elem);
if (!elem || !elem.style) return;
var old = elem.olddisplay, newStyle = 'block', tag = elem.tagName.toLowerCase();
elem.style.display = old || '';
if (getStyle(elem, 'display') == 'none') {
if (hasClass(elem, 'inline')) {
newStyle = 'inline';
} else if (tag == 'tr' && !browser.msie) {
newStyle = 'table-row';
} else if (tag == 'table' && !browser.msie) {
newStyle = 'table';
} else {
newStyle = 'block';
}
elem.style.display = elem.olddisplay = newStyle;
}
}
function hide(elem) {
if (arguments.length > 1) {
for (var i = 0; i < arguments.length; i++) {
hide(arguments[i]);
}
return;
}
elem = ge(elem);
if (!elem || !elem.style) return;
var d = getStyle(elem, 'display');
elem.olddisplay = (d != 'none') ? d : '';
elem.style.display = 'none';
}
function isVisible(elem) {
elem = ge(elem);
if (!elem || !elem.style) return false;
return getStyle(elem, 'display') != 'none';
}
function toggle(elem, val) {
if (val === undefined) {
val = !isVisible(elem);
}
if (val) {
show(elem);
} else {
hide(elem);
}
}
var hfTimeout = 0;
function toggleFlash(show, timeout) {
//if (/mac/i.test(navigator.userAgent)) return;
clearTimeout(hfTimeout);
if (timeout > 0) {
hfTimeout = setTimeout(function() {toggleFlash(show, 0)}, timeout);
return;
}
var vis = show ? 'visible' : 'hidden';
triggerEvent(document, show ? 'unblock' : 'block');
var f = function() {
if (this.getAttribute('preventhide')) {
return;
} else if (this.id == 'app_container' && browser.msie) {
show ? setStyle(this, {position: 'static', top: 0}) : setStyle(this, {position: 'absolute', top: '-5000px'});
} else {
this.style.visibility = vis;
}
};
each(geByTag('embed'), f);
each(geByTag('object'), f);
}
function getXY(obj, forFixed) {
if (!obj || obj == undefined) return;
var left = 0, top = 0, pos, lastLeft;
if (obj.offsetParent) {
do {
left += (lastLeft = obj.offsetLeft);
top += obj.offsetTop;
pos = getStyle(obj, 'position');
if (pos == 'fixed' || pos == 'absolute' || pos == 'relative') {
left -= obj.scrollLeft;
top -= obj.scrollTop;
if (pos == 'fixed' && !forFixed) {
left += ((obj.offsetParent || {}).scrollLeft || bodyNode.scrollLeft || htmlNode.scrollLeft);
top += ((obj.offsetParent || {}).scrollTop || bodyNode.scrollTop || htmlNode.scrollTop);
}
}
} while (obj = obj.offsetParent);
}
if (forFixed && browser.msie && !browser.msie9) {
if (lastLeft) {
left += ge('page_layout').offsetLeft;
}
}
return [left,top];
}
function getSize(elem, withoutBounds) {
var s = [0, 0], de = document.documentElement;
if (elem == document) {
s = [Math.max(
de.clientWidth,
bodyNode.scrollWidth, de.scrollWidth,
bodyNode.offsetWidth, de.offsetWidth
), Math.max(
de.clientHeight,
bodyNode.scrollHeight, de.scrollHeight,
bodyNode.offsetHeight, de.offsetHeight
)];
} else if (elem){
function getWH() {
s = [elem.offsetWidth, elem.offsetHeight];
if (!withoutBounds) return;
var padding = 0, border = 0;
each(s, function(i, v) {
var which = i ? ['Top', 'Bottom'] : ['Left', 'Right'];
each(which, function(){
s[i] -= parseFloat(getStyle(elem, 'padding' + this)) || 0;
s[i] -= parseFloat(getStyle(elem, 'border' + this + 'Width')) || 0;
});
});
s = [Math.round(s[0]), Math.round(s[1])];
}
if (!isVisible(elem)) {
var props = {position: 'absolute', visibility: 'hidden', display: 'block'};
var old = {};
each(props, function(i, val){
old[i] = elem.style[i];
elem.style[i] = val;
});
getWH();
each(props, function(i, val){
elem.style[i] = old[i];
});
} else getWH();
}
return s;
}
/**
* Useful utils
*/
Function.prototype.pbind = function() {
var args = Array.prototype.slice.call(arguments);
args.unshift(window);
return this.bind.apply(this, args);
};
Function.prototype.bind = function() {
var func = this, args = Array.prototype.slice.call(arguments);
var obj = args.shift();
return function() {
var curArgs = Array.prototype.slice.call(arguments);
return func.apply(obj, args.concat(curArgs));
}
}
function rand(mi, ma) { return Math.random() * (ma - mi + 1) + mi; }
function irand(mi, ma) { return Math.floor(rand(mi, ma)); }
function isFunction(obj) {return Object.prototype.toString.call(obj) === '[object Function]'; }
function isArray(obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }
function isEmpty(o) { if(Object.prototype.toString.call(o) !== '[object Object]') {return false;} for(var i in o){ if(o.hasOwnProperty(i)){return false;} } return true; }
function vkNow() { return +new Date; }
function trim(text) { return (text || '').replace(/^\s+|\s+$/g, ''); }
function stripHTML(text) { return text ? text.replace(/<(?:.|\s)*?>/g, '') : ''; }
function escapeRE(s) { return s ? s.replace(/[.*+?^${}()|[\]\/\\]/g, '\\$0') : ''; }
function intval(value) {
if (value === true) return 1;
return parseInt(value) || 0;
}
function floatval(value) {
if (value === true) return 1;
return parseFloat(value) || 0;
}
function positive(value) {
value = intval(value);
return value < 0 ? 0 : value;
}
function winToUtf(text) {
var m, i, j, code;
m = text.match(/[0-9]{2}[0-9]*;/gi);
for (j in m) {
var val = '' + m[j]; // buggy IE6
code = intval(val.substr(2, val.length - 3));
if (code >= 32 && ('' + code + ';' == val)) { // buggy IE6
text = text.replace(val, String.fromCharCode(code));
}
}
text = text.replace(/"/gi, '"').replace(/&/gi, '&').replace(/</gi, '<').replace(/>/gi, '>');
return text;
}
function replaceEntities(str) {
str = str.replace(//g, '>').replace(/"/g, '"');
return ce('div', {innerHTML: ''}).firstChild.value;
}
/**
* Arrays, objects
**/
function each(object, callback) {
var name, i = 0, length = object.length;
if (length === undefined) {
for (name in object)
if (callback.call(object[name], name, object[name]) === false)
break;
} else {
for (var value = object[0];
i < length && callback.call(value, i, value) !== false;
value = object[++i]) {}
}
return object;
}
function indexOf(arr, value, from) {
for (var i = from || 0; i < arr.length; i++) {
if (arr[i] == value) return i;
}
return -1;
}
function inArray(value, arr) {
return indexOf(arr, value) != -1;
}
function clone(obj) {
var newObj = isArray(obj) ? [] : {};
for (var i in obj) {
newObj[i] = obj[i];
}
return newObj;
}
// Extending object by another
function extend() {
var a = arguments, target = a[0] || {}, i = 1, length = a.length, deep = false, options;
if (typeof target === 'boolean') {
deep = target;
target = a[1] || {};
i = 2;
}
if (typeof target !== 'object' && !isFunction(target)) target = {};
if (length == i) return target;
for (; i < length; i++) {
if ((options = a[i]) != null) {
for (var name in options) {
var src = target[name], copy = options[name];
if (target === copy) continue;
if (deep && copy && typeof copy === 'object' && !copy.nodeType) {
target[name] = extend(deep, src || (copy.length != null ? [] : {}), copy);
} else if (copy !== undefined) {
target[name] = copy;
}
}
}
}
return target;
}
/**
* CSS classes
**/
function hasClass(obj, name) {
obj = ge(obj);
return obj && (new RegExp('(\\s|^)' + name + '(\\s|$)')).test(obj.className);
}
function addClass(obj, name) {
if ((obj = ge(obj)) && !hasClass(obj, name)) {
obj.className = (obj.className ? obj.className + ' ' : '') + name;
}
}
function removeClass(obj, name) {
if (obj = ge(obj)) {
obj.className = trim((obj.className || '').replace((new RegExp('(\\s|^)' + name + '(\\s|$)')), ' '));
}
}
function toggleClass(obj, name, val) {
if (val === undefined) {
val = !hasClass(obj, name);
}
(val ? addClass : removeClass)(obj, name);
}
function replaceClass(obj, oldName, newName) {
removeClass(obj, oldName);
addClass(obj, newName);
}
// Get computed style
function getStyle(elem, name, force) {
elem = ge(elem);
if (isArray(name)) { var res = {}; each(name, function(i,v){res[v] = getStyle(elem, v);}); return res; }
if (force === undefined) {
force = true;
}
if (!force && name == 'opacity' && browser.msie) {
var filter = elem.style['filter'];
return filter ? (filter.indexOf('opacity=') >= 0 ?
(parseFloat(filter.match(/opacity=([^)]*)/)[1] ) / 100) + '' : '1') : '';
}
if (!force && elem.style && (elem.style[name] || name == 'height')) {
return elem.style[name];
}
if (force && (name == 'width' || name == 'height')) {
return getSize(elem, true)[({'width': 0, 'height': 1})[name]] + 'px';
}
var ret, defaultView = document.defaultView || window;
if (defaultView.getComputedStyle) {
name = name.replace(/([A-Z])/g, '-$1').toLowerCase();
var computedStyle = defaultView.getComputedStyle(elem, null);
if (computedStyle) {
ret = computedStyle.getPropertyValue(name);
}
} else if (elem.currentStyle) {
if (name == 'opacity' && browser.msie) {
var filter = elem.currentStyle['filter'];
return filter && filter.indexOf('opacity=') >= 0 ?
(parseFloat(filter.match(/opacity=([^)]*)/)[1]) / 100) + '' : '1';
}
var camelCase = name.replace(/\-(\w)/g, function(all, letter){
return letter.toUpperCase();
});
ret = elem.currentStyle[name] || elem.currentStyle[camelCase];
//dummy fix for ie
if (ret == 'auto') {
ret = 0;
}
if (!/^\d+(px)?$/i.test(ret) && /^\d/.test(ret)) {
var style = elem.style, left = style.left, rsLeft = elem.runtimeStyle.left;
elem.runtimeStyle.left = elem.currentStyle.left;
style.left = ret || 0;
ret = style.pixelLeft + 'px';
style.left = left;
elem.runtimeStyle.left = rsLeft;
}
}
return ret;
}
function setStyle(elem, name, value){
elem = ge(elem);
if (!elem) return;
if (typeof name == 'object') return each(name, function(k, v) { setStyle(elem,k,v); });
if (name == 'opacity') {
if (browser.msie) {
if ((value + '').length) {
elem.style.filter = 'alpha(opacity=' + value * 100 + ')';
} else {
elem.style.filter = '';
}
elem.style.zoom = 1;
};
elem.style.opacity = value;
} else {
try{
var isN = typeof(value) == 'number';
if (isN && (/height|width/i).test(name)) value = Math.abs(value);
elem.style[name] = isN && !(/z-?index|font-?weight|opacity|zoom|line-?height/i).test(name) ? value + 'px' : value;
} catch(e){debugLog([name, value]);}
}
}
/**
* Store data connected to element
**/
var vkExpand = 'VK' + vkNow(), vkUUID = 0, vkCache = {};
function data(elem, name, data) {
var id = elem[vkExpand], undefined;
if (!id) {
id = elem[vkExpand] = ++vkUUID;
}
if (name && !vkCache[id]) {
vkCache[id] = {};
if (__debugMode) vkCache[id].__elem = elem;
}
if (data !== undefined) {
vkCache[id][name] = data;
}
return name ? vkCache[id][name] : id;
}
function removeAttr(el) {
for (var i = 0; i < arguments.length; ++i) {
var n = arguments[i];
if (el[n] === undefined) continue;
try {
delete el[n];
} catch(e) {
try {
el.removeAttribute(n);
} catch(e) {}
}
}
}
function removeData(elem, name) {
var id = elem ? elem[vkExpand] : false;
if (!id) return;
if (name) {
if (vkCache[id]) {
delete vkCache[id][name];
name = '';
for (name in vkCache[id]) {
break;
}
if (!name) {
removeData(elem);
}
}
} else {
removeEvent(elem);
removeAttr(elem, vkExpand);
delete vkCache[id];
}
}
function cleanElems() {
var a = arguments;
for (var i = 0; i < a.length; ++i) {
var el = ge(a[i]);
if (el) {
removeData(el);
removeAttr(el, 'btnevents');
}
}
}
// Simple FX
function animate(el, params, speed, callback) {
el = ge(el);
if (!el) return;
var _cb = isFunction(callback) ? callback : function() {};
var options = extend({}, typeof speed == 'object' ? speed : {duration: speed, onComplete: _cb});
var fromArr = {}, toArr = {}, visible = isVisible(el), self = this, p;
options.orig = {};
params = clone(params);
if (browser.iphone)
options.duration = 0;
var tween = data(el, 'tween'), i, name, toggleAct = visible ? 'hide' : 'show';
if (tween && tween.isTweening) {
options.orig = extend(options.orig, tween.options.orig);
tween.stop(false);
if (tween.options.show) toggleAct = 'hide';
else if (tween.options.hide) toggleAct = 'show';
}
for (p in params) {
if (!tween && (params[p] == 'show' && visible || params[p] == 'hide' && !visible)) {
return options.onComplete.call(this, el);
}
if ((p == 'height' || p == 'width') && el.style) {
if (options.orig.overflow == undefined) {
options.orig.overflow = getStyle(el, 'overflow');
}
el.style.overflow = 'hidden';
if (!hasClass(el, 'inl_bl')) {
el.style.display = 'block';
}
}
if (/show|hide|toggle/.test(params[p])) {
if (params[p] == 'toggle') {
params[p] = toggleAct;
}
if (params[p] == 'show') {
var from = 0;
options.show = true;
if (options.orig[p] == undefined) {
options.orig[p] = getStyle(el, p, false) || '';
setStyle(el, p, 0);
}
var o;
if (p == 'height' && browser.msie6) {
o = '0px';
el.style.overflow = '';
} else {
o = options.orig[p];
}
var old = el.style[p];
el.style[p] = o;
params[p] = parseFloat(getStyle(el, p, true));
el.style[p] = old;
if (p == 'height' && browser.msie) {
el.style.overflow = 'hidden';
}
} else {
if (options.orig[p] == undefined) {
options.orig[p] = getStyle(el, p, false) || '';
}
options.hide = true;
params[p] = 0;
}
}
}
if (options.show && !visible) {
show(el);
}
tween = new Fx.Base(el, options);
each(params, function(name, to) {
if (/backgroundColor|borderBottomColor|borderLeftColor|borderRightColor|borderTopColor|color|borderColor|outlineColor/.test(name)) {
var p = (name == 'borderColor') ? 'borderTopColor' : name;
from = getColor(el, p);
to = getRGB(to);
} else {
var parts = to.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
start = tween.cur(name, true) || 0;
if (parts) {
to = parseFloat(parts[2]);
if (parts[1]) {
to = ((parts[1] == '-=' ? -1 : 1) * to) + to;
}
}
if (options.hide && name == 'height' && browser.msie6) {
el.style.height = '0px';
el.style.overflow = '';
}
from = tween.cur(name, true);
if (options.hide && name == 'height' && browser.msie6) {
el.style.height = '';
el.style.overflow = 'hidden';
}
if (from == 0 && (name == 'width' || name == 'height'))
from = 1;
if (name == 'opacity' && to > 0 && !visible) {
setStyle(el, 'opacity', 0);
from = 0;
show(el);
}
}
if (from != to || (isArray(from) && from.join(',') == to.join(','))) {
fromArr[name] = from;
toArr[name] = to;
}
});
tween.start(fromArr, toArr);
data(el, 'tween', tween);
return tween;
}
function fadeTo(el, speed, to, callback) {
return animate(el, {opacity: to}, speed, callback);
}
var Fx = fx = {
Transitions: {
linear: function(t, b, c, d) { return c*t/d + b; },
sineInOut: function(t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; },
halfSine: function(t, b, c, d) { return c * (Math.sin(Math.PI * (t/d) / 2)) + b; },
easeOutBack: function(t, b, c, d) { var s = 1.70158; return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; },
easeInCirc: function(t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; },
easeOutCirc: function(t, b, c, d) { return c * Math.sqrt(1 - (t=t/d-1)*t) + b; },
easeInQuint: function(t, b, c, d) { return c*(t/=d)*t*t*t*t + b; },
easeOutQuint: function(t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; }
},
Attrs: [
[ 'height', 'marginTop', 'marginBottom', 'paddingTop', 'paddingBottom' ],
[ 'width', 'marginLeft', 'marginRight', 'paddingLeft', 'paddingRight' ],
[ 'opacity', 'left', 'top' ]
],
Timers: [],
TimerId: null
}
Fx.Base = function(el, options, name) {
this.el = ge(el);
this.name = name;
this.options = extend({
onComplete: function() {},
transition: Fx.Transitions.sineInOut,
duration: 500
}, options || {});
}
function genFx(type, num) {
var obj = {};
each(Fx.Attrs.concat.apply([], Fx.Attrs.slice(0, num)), function() {
obj[this] = type;
});
return obj;
};
// Shortcuts for custom animations
each({slideDown: genFx('show', 1),
slideUp: genFx('hide', 1),
slideToggle: genFx('toggle', 1),
fadeIn: {opacity: 'show'},
fadeOut: {opacity: 'hide'},
fadeToggle: {opacity: 'toggle'}}, function(f, val) {
window[f] = function(el, speed, callback) { return animate(el, val, speed, callback); }
});
Fx.Base.prototype = {
start: function(from, to){
this.from = from;
this.to = to;
this.time = vkNow();
this.isTweening = true;
var self = this;
function t(gotoEnd) {
return self.step(gotoEnd);
}
t.el = this.el;
if (t() && Fx.Timers.push(t) && !Fx.TimerId) {
Fx.TimerId = setInterval(function() {
var timers = Fx.Timers;
for (var i = 0; i < timers.length; i++) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
clearInterval(Fx.TimerId);
Fx.TimerId = null;
}
}, 13);
}
return this;
},
stop: function(gotoEnd) {
var timers = Fx.Timers;
for (var i = timers.length - 1; i >= 0; i--) {
if (timers[i].el == this.el ) {
if (gotoEnd) {
timers[i](true);
}
timers.splice(i, 1);
}
}
this.isTweening = false;
},
step: function(gotoEnd) {
var time = vkNow();
if (!gotoEnd && time < this.time + this.options.duration) {
this.cTime = time - this.time;
this.now = {};
for (p in this.to) {
// color fx
if (isArray(this.to[p])) {
var color = [], j;
for (j = 0; j < 3; j++) {
if (this.from[p] === undefined || this.to[p] === undefined) {
return false;
}
color.push(Math.min(parseInt(this.compute(this.from[p][j], this.to[p][j])), 255));
}
this.now[p] = color;
} else {
this.now[p] = this.compute(this.from[p], this.to[p]);
}
}
this.update();
return true;
} else {
setTimeout(this.options.onComplete.bind(this, this.el), 10);
this.now = extend(this.to, this.options.orig);
this.update();
if (this.options.hide) hide(this.el);
this.isTweening = false;
return false;
}
},
compute: function(from, to){
var change = to - from;
return this.options.transition(this.cTime, from, change, this.options.duration);
},
update: function(){
for (var p in this.now) {
if (isArray(this.now[p])) setStyle(this.el, p, 'rgb(' + this.now[p].join(',') + ')');
else this.el[p] != undefined ? (this.el[p] = this.now[p]) : setStyle(this.el, p, this.now[p]);
}
},
cur: function(name, force){
if (this.el[name] != null && (!this.el.style || this.el.style[name] == null))
return this.el[name];
return parseFloat(getStyle(this.el, name, force)) || 0;
}
};
// Parse strings looking for color tuples [255,255,255]
function getRGB(color) {
var result;
if (color && isArray(color) && color.length == 3)
return color;
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
}
function getColor(elem, attr) {
var color;
do {
color = getStyle(elem, attr);
if (!color.indexOf('rgba')) color = '';
if (color != '' && color != 'transparent' || elem.nodeName.toLowerCase() == 'body') {
break;
}
attr = 'backgroundColor';
} while (elem = elem.parentNode);
return getRGB(color);
}
function scrollToTop(speed) {
if (speed == undefined) speed = 400;
if (speed) {
if (browser.msie6) {
animate(pageNode, {scrollTop: 0}, speed);
} else {
animate(htmlNode, {scrollTop: 0}, speed);
animate(bodyNode, {scrollTop: 0}, speed);
}
} else {
window.scroll(0, 0);
if (browser.msie6) {
pageNode.scrollTop = 0;
}
}
}
function notaBene(el, color, nofocus) {
el = ge(el);
if (!el) return;
if (!nofocus) elfocus(el);
var oldBack = data(el, 'back') || data(el, 'back', getStyle(el, 'backgroundColor'));
var colors = {notice: '#FFFFE0', warning: '#FAEAEA'};
setStyle(el, 'backgroundColor', colors[color] || color || colors.warning);
setTimeout(animate.pbind(el, {backgroundColor: oldBack}, 300), 400);
}
/**
* Events
**/
var KEY = window.KEY = {
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
DEL: 8,
TAB: 9,
RETURN: 13,
ENTER: 13,
ESC: 27,
PAGEUP: 33,
PAGEDOWN: 34,
SPACE: 32
};
function addEvent(elem, types, handler, custom, context) {
elem = ge(elem);
if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
return;
var realHandler = context ? function (e) {
var prevData = e.data;
e.data = context;
var ret = handler.apply(this, [e]);
e.data = prevData;
return ret;
} : handler;
// For IE
if (elem.setInterval && elem != window) elem = window;
var events = data(elem, 'events') || data(elem, 'events', []),
handle = data(elem, 'handle') || data(elem, 'handle', function() {
_eventHandle.apply(arguments.callee.elem, arguments);
});
// to prevent a memory leak
handle.elem = elem;
each(types.split(/\s+/), function(index, type) {
if (!events[type]) {
events[type] = [];
if (!custom && elem.addEventListener) {
elem.addEventListener(type, handle, false);
} else if (!custom && elem.attachEvent) {
elem.attachEvent('on' + type, handle);
}
}
events[type].push(realHandler);
});
elem = null;
}
function removeEvent(elem, types, handler) {
elem = ge(elem);
if (!elem) return;
var events = data(elem, 'events');
if (!events) return;
if (typeof(types) != 'string') {
for (var i in events) {
removeEvent(elem, i);
}
return;
}
each(types.split(/\s+/), function(index, type) {
if (!isArray(events[type])) return;
if (isFunction(handler)) {
for (var i = 0; i < events[type].length; i++) {
if (events[type][i] == handler) {
for (var j = i + 1; j < events[type].length; j++) {
events[type][j - 1] = events[type][j];
}
events[type].pop();
break;
}
}
} else {
for (var i = 0; i < events[type].length; i++) {
delete events[type][i];
}
}
if (!events[type].length) {
if (elem.removeEventListener) {
elem.removeEventListener(type, data(elem, 'handle'), false);
} else if (elem.detachEvent) {
elem.detachEvent('on' + type, data(elem, 'handle'));
}
delete events[type];
}
});
}
function triggerEvent(elem, type, ev) {
var handle = data(elem, 'handle');
if (handle) {
setTimeout(function() {
handle.call(elem, extend((ev || {}), {type: type, target: elem}))
}, 0);
}
}
function cancelEvent(event) {
var e = event.originalEvent || event;
if (e.preventDefault) e.preventDefault();
if (e.stopPropagation) e.stopPropagation();
event.cancelBubble = e.cancelBubble = true;
event.returnValue = e.returnValue = false;
return false;
}
function _eventHandle(event) {
event = event || window.event;
var originalEvent = event;
event = clone(originalEvent);
event.originalEvent = originalEvent;
if (!event.target) {
event.target = event.srcElement || document;
}
// check if target is a textnode (safari)
if (event.target.nodeType == 3) {
event.target = event.target.parentNode;
}
if (!event.relatedTarget && event.fromElement) {
event.relatedTarget = event.fromElement == event.target;
}
if (event.pageX == null && event.clientX != null) {
var doc = document.documentElement, body = bodyNode || document.body;
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
}
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode)) {
event.which = event.charCode || event.keyCode;
}
if (!event.metaKey && event.ctrlKey) {
event.metaKey = event.ctrlKey;
}
// click: 1 == left; 2 == middle; 3 == right
if (!event.which && event.button) {
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
}
var handlers = data(this, 'events');
if (!handlers || typeof(event.type) != 'string' || !handlers[event.type] || !handlers[event.type].length) {
return;
}
for (var i in (handlers[event.type] || [])) {
if (event.type == 'mouseover' || event.type == 'mouseout') {
var parent = event.relatedElement;
while (parent && parent != this) {
try { parent = parent.parentNode; }
catch(e) { parent = this; }
}
if (parent == this) {
continue
}
}
var ret = handlers[event.type][i].apply(this, arguments);
if (ret === false) {
cancelEvent(event);
}
}
}
// Prevent memory leaks in IE
addEvent(window, 'unload', function() {
for (var id in vkCache) {
if (vkCache[id].handle && vkCache[id].handle.elem != window) {
removeEvent(vkCache[id].handle.elem);
}
}
});
function onCtrlEnter(ev, handler) {
ev = ev || window.event;
if (ev.keyCode == 10 || ev.ctrlKey && ev.keyCode == 13) {
handler();
}
}
var layoutWidth = 791;
function domStarted() {
window.headNode = geByTag1('head');
extend(window, {
icoNode: geByTag1('link', headNode),
bodyNode: geByTag1('body'),
htmlNode: geByTag1('html'),
utilsNode: ge('utils')
});
if (!utilsNode) return;
for (var i in StaticFiles) {
var f = StaticFiles[i];
f.l = 1;
if (f.t == 'css') {
utilsNode.appendChild(ce('div', {id: f.n}));
}
}
hab.init();
}
function domReady() {
if (!utilsNode) return;
extend(window, {
pageNode: ge('page_wrap')
});
onBodyResize();
var scrolledNode = browser.msie6 ? pageNode : window;
}
function onDomReady(f) {
f();
}
// Ajax
function serializeForm(form) {
if (typeof(form) != 'object') {
return false;
}
var result = {};
var g = function(n) {
return geByTag(n, form);
};
var nv = function(i, e){
if (!e.name) return;
if (e.type == 'text' || !e.type) {
result[e.name] = val(e);
} else {
result[e.name] = (browser.msie && !e.value && form[e.name]) ? form[e.name].value : e.value;
}
};
each(g('input'), function(i, e) {
if ((e.type != 'radio' && e.type != 'checkbox') || e.checked) return nv(i, e);
});
each(g('select'), nv);
each(g('textarea'), nv);
return result;
}
function ajx2q(qa) {
var query = [], enc = function (str) {
try {
return encodeURIComponent(str);
} catch (e) { return str;}
};
for (var key in qa) {
if (qa[key] == null || isFunction(qa[key])) continue;
if (isArray(qa[key])) {
for (var i = 0, c = 0; i < qa[key].length; ++i) {
if (qa[key][i] == null || isFunction(qa[key][i])) {
continue;
}
query.push(enc(key) + '[' + c + ']=' + enc(qa[key][i]));
++c;
}
} else {
query.push(enc(key) + '=' + enc(qa[key]));
}
}
query.sort();
return query.join('&');
}
function q2ajx(qa) {
if (!qa) return {};
var query = {}, dec = function (str) {
try {
return decodeURIComponent(str);
} catch (e) { return str;}
};
qa = qa.split('&');
each(qa, function(i, a) {
var t = a.split('=');
if (t[0]) {
var v = dec(t[1] + '');
if (t[0].substr(t.length - 2) == '[]') {
var k = dec(t[0].substr(0, t.length - 2));
if (!query[k]) {
query[k] = [];
}
query[k].push(v);
} else {
query[dec(t[0])] = v;
}
}
});
return query;
}
var stManager = {
_add: function(f, old) {
var name = f.replace(/[\/\.]/g, '_');
if (old && old.l && old.t == 'css') {
var elem = ce('style', {
type: 'text/css',
media: 'screen'
});
headNode.appendChild(elem);
var text = '#' + name + ' { display: block; }';
if (elem.sheet) {
elem.sheet.insertRule(text, 0);
} else if (elem.styleSheet) {
elem.styleSheet.cssText = text;
}
}
StaticFiles[f] = {v: stVersions[f], n: name, l: 0, c: 0};
var f_full = f + '?' + stVersions[f];
if (f.indexOf('.js') != -1) {
var p = 'js/';
if (stTypes.fromLib[f]) {
p += 'lib/';
} else if (!/^lang\d/i.test(f) && !stTypes.fromRoot[f] && f.indexOf('api')) {
p += 'al/';
}
headNode.appendChild(ce('script', {
type: 'text/javascript',
src: p + f_full
}));
StaticFiles[f].t = 'js';
} else if (f.indexOf('.css') != -1) {
var p = 'css/' + (stTypes.fromRoot[f] ? '' : 'al/');
headNode.appendChild(ce('link', {
type: 'text/css',
rel: 'stylesheet',
href: p + f_full
}));
StaticFiles[f].t = 'css';
if (!ge(name)) {
utilsNode.appendChild(ce('div', {id: name}));
}
}
},
add: function(files, callback) {
var wait = [], de = document.documentElement;
if (!isArray(files)) files = [files];
for (var i in files) {
var f = files[i];
if (f.indexOf('?') != -1) {
f = f.split('?')[0];
}
if (/^lang\d/i.test(f)) {
stVersions[f] = stVersions['lang'];
} else if (!stVersions[f]) {
stVersions[f] = 1;
}
var old = StaticFiles[f];
if (!old || old.v != stVersions[f]) {
stManager._add(f, old);
}
if (callback && !StaticFiles[f].l) {
wait.push(f);
}
}
if (!callback) return;
if (!wait.length) {
return callback();
}
var waiter = function() {
var nwait = [];
for (var i in wait) {
var f = wait[i];
if (!StaticFiles[f].l && StaticFiles[f].t == 'css' && getStyle(StaticFiles[f].n, 'display') == 'none') {
if (stVersions[f] < 0) {
topMsg('Warning: Something is bad, please clear your cache and restart your browser.', 10);
}
StaticFiles[f].l = 1;
}
if (!StaticFiles[f].l) {
if (++StaticFiles[f].c > 150) { // Can't load for 15 seconds.
if (stVersions[f] < 0) {
topError('Error: Could not load ' + f + '.', 3);
StaticFiles[f].l = 1;
} else {
topMsg('Some problems with loading ' + f + '...', 3);
stVersions[f] = irand(-10000, -1);
stManager._add(f, StaticFiles[f]);
}
}
}
if (!StaticFiles[f].l) {
nwait.push(f);
}
}
wait = nwait;
if (wait.length) {
return setTimeout(arguments.callee, 100);
}
callback();
}
setTimeout(waiter, 1);
},
done: function(f) {
StaticFiles[f].l = 1;
}
}
function requestBox(box, onDone, onFail) {
box.setOptions({onHide: onFail});
box.onDone = function() {
box.setOptions({onHide: false});
onDone();
}
return box;
}
function activateMobileBox(opts) {
return requestBox(showBox('activation.php', {
act: 'activate_mobile_box',
hash: opts.hash
}), function() {
vk.nophone = 0;
opts.onDone();
}, opts.onFail);
}
var ajaxCache = {};
var globalAjaxCache = {};
var ajax = {
_init: function() {
var r = false;
try {
if (r = new XMLHttpRequest()) {
ajax._req = function() { return new XMLHttpRequest(); }
return;
}
} catch(e) {}
each(['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], function() {
try {
var t = '' + this;
if (r = new ActiveXObject(t)) {
(function(n) {
ajax._req = function() { return new ActiveXObject(n); }
})(t);
return false;
}
} catch(e) {}
});
if (!ajax._req) {
location.replace('/badbrowser.php');
}
},
_getreq: function() {
if (!ajax._req) ajax._init();
return ajax._req();
},
_frameover: function() {
var node = iframeTransport.parentNode;
node.innerHTML = '';
utilsNode.removeChild(node);
iframeTransport = false;
if (cur.onFrameBlocksDone) {
cur.onFrameBlocksDone();
}
},
_receive: function(cont, html, js) {
cont = cont && ge(cont);
if (cont && html) {
html = ce('div', {innerHTML: html});
while (html.firstChild) {
cont.appendChild(html.firstChild);
}
}
if (js) {
eval('(function(){' + js + ';})()');
}
},
framedata: false,
framegot: function(c, h, j) {
if (ajax.framedata === false) {
setTimeout(ajax._receive.pbind(c, h, j), 0);
} else {
ajax.framedata.push([c, h, j]);
}
},
framepost: function(url, query, done) {
if (window.iframeTransport) {
ajax._frameover();
}
window.iframeTransport = utilsNode.appendChild(ce('div', {innerHTML: ''})).firstChild;
ajax._framedone = done;
iframeTransport.src = url + '?' + ((typeof(query) != 'string') ? ajx2q(query) : query);
},
plainpost: function(url, query, done, fail) {
var r = ajax._getreq();
var q = (typeof(query) != 'string') ? ajx2q(query) : query;
r.onreadystatechange = function() {
if (r.readyState == 4) {
if (r.status >= 200 && r.status < 300) {
if (done) done(r.responseText, r);
} else if (r.status) {
if (fail) fail(r.responseText, r);
}
}
}
try {
r.open('POST', url, true);
} catch(e) {
topMsg('Ajax Error: ' + e.message);
}
r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
r.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
r.send(q);
return r;
},
post: function(url, query, options) {
if (url.substr(0, 1) != '/') url = '/' + url;
var o = extend({_captcha: false, _box: false}, options || {}), q = extend({al: o.frame ? -1 : 1}, query);
if (o.progress) {
if (!o.showProgress) {
o.showProgress = show.pbind(o.progress);
}
if (!o.hideProgress) {
o.hideProgress = hide.pbind(o.progress);
}
}
return ajax._post(url, q, o);
},
preload: function(url, query, data) {
if (url.substr(0, 1) != '/') url = '/' + url;
ajaxCache[url + '#' + ajx2q(query)] = data;
},
_debugLog: function(text) {
window._updateDebug = function() {
var dlw = ge('debuglogwrap');
if (dlw) {
dlw.innerHTML = text;
window._updateDebug = false;
}
}
},
_parseRes: function(answer) {
window._updateDebug = false;
for (var i = 0; i < answer.length; ++i) {
var ans = answer[i];
if (ans.substr(0, 2) == '');
var type = ans.substr(2, from - 2);
ans = ans.substr(from + 1);
switch (type) {
case 'json' : answer[i] = eval('(' + ans + ')'); break;
case 'int' : answer[i] = intval(ans); break;
case 'float': answer[i] = floatval(ans); break;
case 'bool' : answer[i] = intval(ans) ? true : false; break;
case 'null' : answer[i] = null; break;
case 'debug':
ajax._debugLog(ans);
answer.pop(); // must be last one
break;
}
}
}
},
_post: function(url, q, o) {
if (!q.captcha_sid && o.showProgress) o.showProgress();
var cacheKey = false;
if (o.ads && vk.id) q.al_ad = 1;
if (o.cache) {
var boldq = clone(q);
delete boldq.al;
delete boldq.al_ad;
delete boldq.captcha_sid;
delete boldq.captcha_key;
cacheKey = url + '#' + ajx2q(boldq);
}
var hideBoxes = function() {
for (var i = 0; i < arguments.length; ++i) {
var box = arguments[i];
if (box && box.isVisible()) {
box.setOptions({onHide: false});
box.hide();
}
}
return false;
}
var fail = function(text) {
if (o.hideProgress) o.hideProgress();
if (o._suggest) cleanElems(o._suggest);
o._suggest = o._captcha = o._box = hideBoxes(o._box, o._captcha);
if (isFunction(o.onFail)) {
if (o.onFail(text)) {
return;
}
}
topError(text);
}
// Process response function
var processResponse = function(code, answer) {
if (o.cache && !o.forceGlobalCache) {
if (!code) {
ajaxCache[cacheKey] = answer;
}
if (o.cache === 2) {
return;
}
}
// Parse response
if (o.hideProgress) o.hideProgress();
o._box = hideBoxes(o._box);
if (o._captcha && code != 2) {
if (o._suggest) cleanElems(o._suggest);
o._suggest = o._captcha = hideBoxes(o._captcha);
}
switch (code) {
case 1: // email not confirmed
if (ge('confirm_mail')) {
showFastBox({
width: 430,
title: ge('confirm_mail_title').value,
onHide: o.onFail
}, '