var base_domain = base_domain || "/";
var css_versions = {};
var _ua = navigator.userAgent.toLowerCase();
var browser = {
  version: (_ua.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
  opera: /opera/i.test(_ua),
  msie: (!this.opera && /msie/i.test(_ua)),
  msie6: (!this.opera && /msie 6/i.test(_ua)),
  msie8: (!this.opera && /msie 8/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)
}

function getLang() {
  try {
    var args = Array.prototype.slice.call(arguments);
    var key = args.shift();
    if (!key) return '...';
    var val = (window.lang &&  _proxy_jslib_handle(window.lang, (key), '', 0, 0)) || (window.langpack &&  _proxy_jslib_handle(window.langpack, (key), '', 0, 0)) ||  _proxy_jslib_handle(window, (key), '', 0, 0);
    if (!val) {
      return  _proxy_jslib_handle(key, 'replace', '', 1, 0)(/_/g, ' ');
    }
    if (isFunction(val)) {
      return val.apply(null, args);
    } else if (isArray(val)) {
      return langNumeric(args[0], val);
    } else {
      return val;
    }
  } catch(e) {
    debugLog('lang error:' + e.message + '(' + Array.prototype.slice.call(arguments).join(', ') + ')');
  }
}
/**
 * DOM
 **/
function ge() {
  var ea;
  for (var i = 0; i < arguments.length; i++) {
    var e =  _proxy_jslib_handle(arguments, (i), '', 0, 0);
    if (typeof e == 'string')
      e =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(e);
    if (arguments.length == 1)
      return e;
    if (!ea)
      ea = new (Array)();
    ea.push(e);
  }
  return ea;
}

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]';
       _proxy_jslib_assign('', ge('debuglog'), 'innerHTML', '+=', ( t +  _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle(msg, 'toString', '', 1, 0)(), 'replace', '', 1, 0)('<', '&lt;'), 'replace', '', 1, 0)('>', '&gt;')+'<br/>'));
    }
    if(window.console && console.log){console.log(t + msg);}
  } catch (e) {}
}

function geByClass(searchClass, node, tag) {
  var classElements = new (Array)();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  if (node.getElementsByClassName) {
    classElements = node.getElementsByClassName(searchClass);
    if (tag != '*') {
      for (i = 0; i < classElements.length; i++) {
        if (classElements.nodeName == tag)
          classElements.splice(i, 1);
      }
    }
    return classElements;
  }
  var els =  _proxy_jslib_handle(node, 'getElementsByTagName', '', 1, 0)(tag);
  var elsLen = els.length;
  var pattern = new (RegExp)("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test( _proxy_jslib_handle(els, (i), '', 0, 0).className) ) {
       _proxy_jslib_assign('', classElements, (j), '=', (  _proxy_jslib_handle(els, (i), '', 0, 0)));
      j++;
    }
  }
  return classElements;
}

function show(elem) {
  if (arguments.length > 1) {
    for (var i = 0; i < arguments.length; i++) {
      show( _proxy_jslib_handle(arguments, (i), '', 0, 0));
    }
    return;
  }
  elem = ge(elem);
  if (!elem) return;
  var old = data(elem, "olddisplay");
  elem.style.display = old || "";

  if (getStyle(elem, 'display') == "none" ) {
    if (elem.tagName.toLowerCase() == 'tr' && !browser.msie) {
      elem.style.display = 'table-row';
    } else if (elem.tagName.toLowerCase() == 'table' && !browser.msie) {
      elem.style.display = 'table';
    } else {
      elem.style.display = data(elem, "olddisplay", "block");
    }
  }
}

function hide(elem) {
  if (arguments.length > 1) {
    for (var i = 0; i < arguments.length; i++) {
      hide( _proxy_jslib_handle(arguments, (i), '', 0, 0));
    }
    return;
  }
  elem = ge(elem);
  if (!elem) return;
  if (getStyle(elem, 'display') != "none")
    data(elem, "olddisplay", elem.style.display);
  elem.style.display = "none";
}
function isVisible(elem) {
 elem = ge(elem);
 return getStyle(elem, 'display') != 'none' && getStyle(elem, 'visibility') != 'hidden';
}
function toggle(elem) {
  if (isVisible(elem)) {
    hide(elem);
  } else {
    show(elem);
  }
}
window.shide = toggle;

var hfTimeout;
function toggleFlash(show, timeout) {
 if (/mac/i.test(navigator.userAgent)) return;
 clearTimeout(hfTimeout);
 if (timeout > 0) {
   hfTimeout =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {toggleFlash(show, 0)}, timeout);
   return;
 }
 var body =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('body')[0];

 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 = show ? 'visible' : 'hidden';
 };
 each( _proxy_jslib_handle( _proxy_jslib_handle(null, 'body', body, 0, 0), 'getElementsByTagName', '', 1, 0)('embed'), f);
 each( _proxy_jslib_handle( _proxy_jslib_handle(null, 'body', body, 0, 0), 'getElementsByTagName', '', 1, 0)('object'), f);
}

function getXY(obj) {
 if (!obj || obj == undefined) return;
 var left = 0, top = 0;
 if (obj.offsetParent) {
  do {
   left += obj.offsetLeft;
    top= _proxy_jslib_assign_rval('', 'top', '+=', ( obj.offsetTop), (typeof top=='undefined' ? void 0 : top));
  } while (obj = obj.offsetParent);
 }
 return [left, _proxy_jslib_handle(null, 'top', top, 0, 0)];
}

function getSize(elem, withoutBounds) {
  var s = [0, 0];
  if (elem == document) {
    s =  [Math.max(
         _proxy_jslib_handle(document.documentElement, ("clientWidth"), '', 0, 0),
         _proxy_jslib_handle( _proxy_jslib_handle(document, 'body', '', 0, 0), ("scrollWidth"), '', 0, 0),  _proxy_jslib_handle(document.documentElement, ("scrollWidth"), '', 0, 0),
         _proxy_jslib_handle( _proxy_jslib_handle(document, 'body', '', 0, 0), ("offsetWidth"), '', 0, 0),  _proxy_jslib_handle(document.documentElement, ("offsetWidth"), '', 0, 0)
 ), Math.max(
         _proxy_jslib_handle(document.documentElement, ("clientHeight"), '', 0, 0),
         _proxy_jslib_handle( _proxy_jslib_handle(document, 'body', '', 0, 0), ("scrollHeight"), '', 0, 0),  _proxy_jslib_handle(document.documentElement, ("scrollHeight"), '', 0, 0),
         _proxy_jslib_handle( _proxy_jslib_handle(document, 'body', '', 0, 0), ("offsetHeight"), '', 0, 0),  _proxy_jslib_handle(document.documentElement, ("offsetHeight"), '', 0, 0)
 )];
  } 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() {
           _proxy_jslib_assign('', s, (i), '-=', ( parseFloat(getStyle(elem, "padding" + this)) || 0));
           _proxy_jslib_assign('', 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) {
         _proxy_jslib_assign('', old, (i), '=', (  _proxy_jslib_handle(elem.style, (i), '', 0, 0)));
         _proxy_jslib_assign('', elem.style, (i), '=', ( val));
      });
      getWH();
      each(props, function(i, val) {
         _proxy_jslib_assign('', elem.style, (i), '=', (  _proxy_jslib_handle(old, (i), '', 0, 0)));
      });
    } else getWH();

  }
  return s;
}


/**
 *  Useful utils
 */

Function.prototype.bind = function(object) {
  var __method = this;
  return function() {
    return __method.apply(object, arguments);
  }
};
function isFunction(obj) { return  _proxy_jslib_handle(Object.prototype, 'toString', '', 0, 0).call(obj) === "[object Function]"; }
function isArray(obj) { return  _proxy_jslib_handle(Object.prototype, 'toString', '', 0, 0).call(obj) === "[object Array]"; }
function isEmpty(o) { if( _proxy_jslib_handle(Object.prototype, 'toString', '', 0, 0).call(o) !== "[object Object]") {return false;} for(var i in o){ if(o.hasOwnProperty(i)){return false;} } return true; }
function now() { return +new (Date); }
function trim(text) { return  _proxy_jslib_handle((text || ""), 'replace', '', 1, 0)(/^\s+|\s+$/g, ""); }
function stripHTML(text) { return text ?  _proxy_jslib_handle(text, 'replace', '', 1, 0)(/<(?:.|\s)*?>/g, "") : ''; }
function escapeRE(s) { return s ?  _proxy_jslib_handle(s, 'replace', '', 1, 0)(/[.*+?^${}()|[\]\/\\]/g, '\\$0') : ''; }
function intval(value) {
  if ( _proxy_jslib_handle(null, 'value', value, 0, 0) === true) return 1;
  return isNaN(parseInt( _proxy_jslib_handle(null, 'value', value, 0, 0))) ? 0 : parseInt( _proxy_jslib_handle(null, 'value', value, 0, 0));
}
function winToUtf(text) {
  var m, i, j, code;
  m = text.match(/&#[0-9]{2}[0-9]*;/gi);
  for (j in m) {
    var val = '' +  _proxy_jslib_handle(m, (j), '', 0, 0); // buggy IE6
    code = intval(val.substr(2, val.length - 3));
    if (code >= 32 && ('&#' + code + ';' == val)) { // buggy IE6
      text =  _proxy_jslib_handle(text, 'replace', '', 1, 0)(val, String.fromCharCode(code));
    }
  }
  text =  _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle(text, 'replace', '', 1, 0)(/&quot;/gi, '"'), 'replace', '', 1, 0)(/&amp;/gi, '&'), 'replace', '', 1, 0)(/&lt;/gi, '<'), 'replace', '', 1, 0)(/&gt;/gi, '>');
  return text;
}

/**
 *  Arrays, objects
 **/

function each(object, callback) {
  var name, i = 0, length = object.length;

  if ( length === undefined ) {
    for ( name in object )
      if ( callback.call(  _proxy_jslib_handle(object, ( name ), '', 0, 0), name,  _proxy_jslib_handle(object, ( name ), '', 0, 0) ) === false )
        break;
  } else
    for ( var value = object[0];
      i < length && callback.call(  _proxy_jslib_handle(null, 'value', value, 0, 0), i,  _proxy_jslib_handle(null, 'value', value, 0, 0) ) !== false;  value= _proxy_jslib_assign_rval('', 'value', '=', (  _proxy_jslib_handle(object, ((i= _proxy_jslib_assign_rval('++', 'i', '', '', (typeof i=='undefined' ? void 0 : i)))), '', 0, 0) ), (typeof value=='undefined' ? void 0 : value))){}

  return object;
};
function indexOf(arr, value, from) {
  from = (from == null) ? 0 : from;
  var m = arr.length;
  for(var i = from; i < m; i++)
    if ( _proxy_jslib_handle(arr, (i), '', 0, 0) ==  _proxy_jslib_handle(null, 'value', value, 0, 0))
       return i;
   return -1;
}

function clone(obj) {
  var newObj = {};
  for (var i in obj) {
     _proxy_jslib_assign('', newObj, (i), '=', (  _proxy_jslib_handle(obj, (i), '', 0, 0)));
  }
  return newObj;
}

// Extending object by another
function extend() {
  var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;

  if (typeof target === "boolean") {
    deep = target;
    target = arguments[1] || {};
    i = 2;
  }

  if (typeof target !== "object" && !isFunction(target))
    target = {};

  if (length == i) {
    return target;
  }

  for (; i < length; i++)
    if ((options =  _proxy_jslib_handle(arguments, (i), '', 0, 0)) != null)
      for (var name in options) {
        var src =  _proxy_jslib_handle(target, (name), '', 0, 0), copy =  _proxy_jslib_handle(options, (name), '', 0, 0);

        if (target === copy)
          continue;

        if (deep && copy && typeof copy === "object" && !copy.nodeType)
           _proxy_jslib_assign('', target, (name), '=', ( extend(deep,
             _proxy_jslib_handle(null, 'src', src, 0, 0) || (copy.length != null ? [] : { })
 , copy)));

        else if (copy !== undefined)
           _proxy_jslib_assign('', 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) {
  obj=ge(obj);
  if (obj && !hasClass(obj, name)) obj.className = (obj.className ? obj.className + ' ' : '') + name;
}

function removeClass(obj, name) {
  obj=ge(obj);
  if (obj && hasClass(obj, name)) obj.className =  _proxy_jslib_handle(obj.className, 'replace', '', 1, 0)((new (RegExp)('(\\s|^)' + name + '(\\s|$)')), ' ');
}
//shortcuts
function btnOut(o) {removeClass(geByClass('box_button', o)[0], 'button_hover');}
function btnOver(o) {addClass(geByClass('box_button', o)[0], 'button_hover');}


// Get computed style
function getStyle(elem, name, force) {
  elem = ge(elem);
  if (force === undefined)
    force = true;
  if (!force && name == 'opacity' && browser.msie) {
    var filter =  _proxy_jslib_handle(elem.style, ('filter'), '', 0, 0);
    return filter ? (filter.indexOf("opacity=") >= 0 ?
      (parseFloat(filter.match(/opacity=([^)]*)/)[1] ) / 100) + '' : '1') : '';
  }
  if (!force && elem.style && ( _proxy_jslib_handle(elem.style, (name), '', 0, 0) || name == 'height'))
    return  _proxy_jslib_handle(elem.style, (name), '', 0, 0);

  if (force && (name == "width" || name == "height")) {
    return  _proxy_jslib_handle(getSize(elem, true), ( _proxy_jslib_handle(({'width':0, 'height':1}), (name), '', 0, 0)), '', 0, 0) + 'px';
  }

  var ret, defaultView = document.defaultView || window;
  if (defaultView.getComputedStyle) {
    name =  _proxy_jslib_handle(name, 'replace', '', 1, 0)( /([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 =  _proxy_jslib_handle(elem.currentStyle, ('filter'), '', 0, 0);
      return filter && filter.indexOf("opacity=") >= 0 ?
        (parseFloat(filter.match(/opacity=([^)]*)/)[1] ) / 100) + '' : '1';
    }
    var camelCase =  _proxy_jslib_handle(name, 'replace', '', 1, 0)(/\-(\w)/g, function(all, letter) {
      return letter.toUpperCase();
    });
    ret =  _proxy_jslib_handle(elem.currentStyle, (name), '', 0, 0) ||  _proxy_jslib_handle(elem.currentStyle, (camelCase), '', 0, 0);
    //dummy fix for ie
    if(ret == 'auto')ret = 0;
    // If we're not dealing with a regular pixel number
    // but a number that has a weird ending, we need to convert it to pixels
    if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
      // Remember the original values
      var left = style.left, rsLeft = elem.runtimeStyle.left;

      // Put in the new values to get a computed value out
      elem.runtimeStyle.left = elem.currentStyle.left;
      style.left = ret || 0;
      ret = style.pixelLeft + "px";

      // Revert the changed values
      style.left = left;
      elem.runtimeStyle.left = rsLeft;
    }
  }
  return ret;
}

function setStyle(elem, name, value) {
  elem = ge(elem);
  if (typeof name == 'object') return each(name, function(k,v) {setStyle(elem,k,v);});
  if (name == 'opacity'){
    if (browser.msie) {
      if (( _proxy_jslib_handle(null, 'value', value, 0, 0) + '').length) {
        elem.style.filter = "alpha(opacity=" +  _proxy_jslib_handle(null, 'value', value, 0, 0)*100 + ")";
      } else {
        elem.style.filter = '';
      }
      elem.style.zoom = 1;
    };
    elem.style.opacity =  _proxy_jslib_handle(null, 'value', value, 0, 0);
  } else {
    var isNum = typeof( _proxy_jslib_handle(null, 'value', value, 0, 0)) == 'number' && !(/z-?index|font-?weight|opacity|zoom|line-?height/i).test(name);
    if(isNum &&  _proxy_jslib_handle(null, 'value', value, 0, 0) < 0 && (/^(width|height)$/i).test(name)){
       value= _proxy_jslib_assign_rval('', 'value', '=', ( 0), (typeof value=='undefined' ? void 0 : value)); //fix for IE;
    }
     _proxy_jslib_assign('', elem.style, (name), '=', ( isNum ?  _proxy_jslib_handle(null, 'value', value, 0, 0) + 'px':  _proxy_jslib_handle(null, 'value', value, 0, 0)));
  }
}
function swapStyle(elem, options, callback) {
  elem = ge(elem);
  var old = {};
  for (var name in options) {
     _proxy_jslib_assign('', old, (name), '=', (  _proxy_jslib_handle(elem.style, (name), '', 0, 0)));
     _proxy_jslib_assign('', elem.style, (name), '=', (  _proxy_jslib_handle(options, (name), '', 0, 0)));
  }
  callback.call(elem);
  for (var name in options)
       _proxy_jslib_assign('', elem.style, (name), '=', (  _proxy_jslib_handle(old, ( name ), '', 0, 0)));
}

/**
 * Store data connected to element
 **/

var expand = "VK" + now(), vk_uuid = 0, vk_cache = {};

// Get or set element data
function data(elem, name, data) {
  var id =  _proxy_jslib_handle(elem, ( expand ), '', 0, 0), undefined;
  if ( !id )
    id =  _proxy_jslib_assign('', elem, ( expand ), '=', ( (vk_uuid= _proxy_jslib_assign_rval('++', 'vk_uuid', '', '', (typeof vk_uuid=='undefined' ? void 0 : vk_uuid)))));

  if (name && ! _proxy_jslib_handle(vk_cache, (id), '', 0, 0))
     _proxy_jslib_assign('', vk_cache, (id), '=', ( {}));

  if (data !== undefined)
     _proxy_jslib_assign('',  _proxy_jslib_handle(vk_cache, (id), '', 0, 0), (name), '=', ( data));

  return name ?
     _proxy_jslib_handle( _proxy_jslib_handle(vk_cache, (id), '', 0, 0), (name), '', 0, 0) :
    id;
}

function removeData(elem, name) {
  var id =  _proxy_jslib_handle(elem, (expand), '', 0, 0);
  if (name) {
    if ( _proxy_jslib_handle(vk_cache, (id), '', 0, 0)) {
       _proxy_jslib_assign('delete', ( _proxy_jslib_handle(vk_cache, (id), '', 0, 0)), (name), '');
      name = "";
      for (name in  _proxy_jslib_handle(vk_cache, (id), '', 0, 0))
        break;

      if (!name)
        removeData(elem);
    }
  } else {
    try {
       _proxy_jslib_assign('delete', (elem), (expand), '');
    } catch(e){ // fix for IE
      if (elem.removeAttribute)
        elem.removeAttribute(expand);
    }
     _proxy_jslib_assign('delete', (vk_cache), (id), '');
  }
}

/**
 * Simple FX
 **/
function animate(el, params, speed, callback) {
  el = ge(el);
  var options = extend({}, typeof speed == 'object' ? speed : {duration: speed, onComplete: callback || function() {}});
  var fromArr = {}, toArr = {}, visible = isVisible(el), self = this, p;
  options.orig = {};
  params = clone(params);

  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 && ( _proxy_jslib_handle(params, (p), '', 0, 0) == 'show' && visible ||  _proxy_jslib_handle(params, (p), '', 0, 0) == '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';
      el.style.display = 'block';
    }
    if (/show|hide|toggle/.test( _proxy_jslib_handle(params, (p), '', 0, 0))) {
      if ( _proxy_jslib_handle(params, (p), '', 0, 0) == 'toggle')
         _proxy_jslib_assign('', params, (p), '=', ( toggleAct));
      if ( _proxy_jslib_handle(params, (p), '', 0, 0) == 'show') {
        var from = 0;
        options.show = true;
        if ( _proxy_jslib_handle(options.orig, (p), '', 0, 0) == undefined) {
           _proxy_jslib_assign('', options.orig, (p), '=', ( getStyle(el, p, false) || ''));
          setStyle(el, p, 0);
        }
        var sopt = {};
        if (p == 'height' && browser.msie6) {
           _proxy_jslib_assign('', sopt, (p), '=', ( '0px'));
          el.style.overflow = '';
        } else {
           _proxy_jslib_assign('', sopt, (p), '=', (  _proxy_jslib_handle(options.orig, (p), '', 0, 0)));
        }
        swapStyle(el, sopt, function() {
           _proxy_jslib_assign('', params, (p), '=', ( parseFloat(getStyle(el, p, true))));
        });
        if (p == 'height' && browser.msie) {
          el.style.overflow = 'hidden';
        }
      } else {
        if ( _proxy_jslib_handle(options.orig, (p), '', 0, 0) == undefined) {
           _proxy_jslib_assign('', options.orig, (p), '=', ( getStyle(el, p, false) || ''));
        }
        options.hide = true;
         _proxy_jslib_assign('', 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 =  _proxy_jslib_handle(to, 'toString', '', 1, 0)().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(','))) {
       _proxy_jslib_assign('', fromArr, (name), '=', ( from));
       _proxy_jslib_assign('', 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; }
 },
 Attrs: [
  [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
  [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
  [ "opacity" ]
 ],
 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() {
     _proxy_jslib_assign('', 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) {
  _proxy_jslib_assign('', 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 = now();
    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 =  _proxy_jslib_handle(null, 'setInterval', setInterval, 1, 0)(function() {
        var timers = Fx.Timers;
        for (var i = 0; i < timers.length; i++)
          if (! _proxy_jslib_handle(timers, (i), '', 1, 0)())
            timers.splice(i--, 1);
        if (!timers.length) {
          clearInterval(Fx.TimerId);
          Fx.TimerId = null;
        }
      }, 13);
    }
    return this;
  },

  stop: function(gotoEnd) {
    var timers = Fx.Timers;
    // go in reverse order so anything added to the queue during the loop is ignored
    for (var i = timers.length - 1; i >= 0; i--)
      if ( _proxy_jslib_handle(timers, (i), '', 0, 0).el == this.el ) {
        if (gotoEnd)
          // force the next step to be the last
           _proxy_jslib_handle(timers, (i), '', 1, 0)(true);
        timers.splice(i, 1);
      }
    this.isTweening = false;
  },

  step: function(gotoEnd) {
    var time = now();
    if (!gotoEnd && time < this.time + this.options.duration){
      this.cTime = time - this.time;
      this.now = {};
      for (p in this.to) {
        // color fx
        if (isArray( _proxy_jslib_handle(this.to, (p), '', 0, 0))) {
          var color = [], j;
          for (j = 0; j < 3; j++)
            color.push(Math.min(parseInt(this.compute( _proxy_jslib_handle( _proxy_jslib_handle(this.from, (p), '', 0, 0), (j), '', 0, 0),  _proxy_jslib_handle( _proxy_jslib_handle(this.to, (p), '', 0, 0), (j), '', 0, 0))), 255));
           _proxy_jslib_assign('', this.now, (p), '=', ( color));
        } else
           _proxy_jslib_assign('', this.now, (p), '=', ( this.compute( _proxy_jslib_handle(this.from, (p), '', 0, 0),  _proxy_jslib_handle(this.to, (p), '', 0, 0))));
      }
      this.update();
      return true;
    } else {
//      if (this.el.className == 'im_tab3') alert('this.time: ' + this.time + ', ' + (time - this.time) + ' > ' + this.options.duration);
       _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(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( _proxy_jslib_handle(this.now, (p), '', 0, 0))) setStyle(this.el, p, 'rgb(' +  _proxy_jslib_handle(this.now, (p), '', 0, 0).join(',') + ')');
      else  _proxy_jslib_handle(this.el, (p), '', 0, 0) != undefined ? ( _proxy_jslib_assign('', this.el, (p), '=', (  _proxy_jslib_handle(this.now, (p), '', 0, 0)))) : setStyle(this.el, p,  _proxy_jslib_handle(this.now, (p), '', 0, 0));
    }
  },

  cur: function(name, force) {
    if ( _proxy_jslib_handle(this.el, (name), '', 0, 0) != null && (!this.el.style ||  _proxy_jslib_handle(this.el.style, (name), '', 0, 0) == null))
      return  _proxy_jslib_handle(this.el, (name), '', 0, 0);
    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 != '' && 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) {
  animate( _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('html')[0], {scrollTop: 0}, speed);
  animate( _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('body')[0], {scrollTop: 0}, speed);
 } else window.scroll(0, 0);
}

/**
 * Events
 **/
var KEY = window.KEY = {
  LEFT: 37,
  UP: 38,
  RIGHT: 39,
  DOWN: 40,
  DEL: 8,
  TAB: 9,
  RETURN: 13,
  ESC: 27,
  PAGEUP: 33,
  PAGEDOWN: 34,
  SPACE: 32
};

function addEvent(elem, types, handler, custom) {
  elem = ge(elem);
  if (!elem || elem.nodeType == 3 || elem.nodeType == 8 )
    return;

  // For whatever reason, IE has trouble passing the window object
  // around, causing it to be cloned in the process
  if ( _proxy_jslib_handle(elem, 'setInterval', '', 0, 0) && 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);
      });
  // Add elem as a property of the handle function
  // This is to prevent a memory leak with non-native
  // event in IE.
  handle.elem = elem;
  each(types.split(/\s+/), function(index, type) {
    var handlers =  _proxy_jslib_handle(events, (type), '', 0, 0);
    if (!handlers) {
      handlers =  _proxy_jslib_assign('', events, (type), '=', ( new (Array)()));
      if (!custom && elem.addEventListener)
        elem.addEventListener(type, handle, false);
      else if (!custom && elem.attachEvent)
        elem.attachEvent('on' + type, handle);
    }
    handlers.push(handler);
  });

  elem = null;
}

function triggerEvent(elem, type, ev) {
  var handle = data(elem, "handle");
  if (handle) {
     _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {handle.call(elem, extend((ev || {}), {type: type, target: elem}))}, 0);
  }
}

function removeEvent(elem, type, handler) {
  elem = ge(elem);
  if (!elem) return;
  var events = data(elem, "events");
  if (events) {
    if (typeof(type) == 'string' && isArray( _proxy_jslib_handle(events, (type), '', 0, 0))) {
      if (isFunction(handler)) {
        for (var i = 0; i <  _proxy_jslib_handle(events, (type), '', 0, 0).length; i++) {
          if ( _proxy_jslib_handle( _proxy_jslib_handle(events, (type), '', 0, 0), (i), '', 0, 0) == handler) {
             _proxy_jslib_assign('delete', ( _proxy_jslib_handle(events, (type), '', 0, 0)), (i), '');
            break;
          }
        }
      } else {
        for (var i = 0; i <  _proxy_jslib_handle(events, (type), '', 0, 0).length; i++) {
           _proxy_jslib_assign('delete', ( _proxy_jslib_handle(events, (type), '', 0, 0)), (i), '');
        }
      }
    } else {
      for (var i in events) {
        removeEvent(elem, i);
      }
      return;
    }
    for (var ret in  _proxy_jslib_handle(events, (type), '', 0, 0)) break;
    if (!ret) {
      if (elem.removeEventListener)
        elem.removeEventListener(type, data(elem, "handle"), false);
      else if (elem.detachEvent)
        elem.detachEvent("on" + type, data(elem, "handle"));
      ret = null;
       _proxy_jslib_assign('delete', (events), (type), '');
    }
  }
}

function cancelEvent(event) {
  var e = event.originalEvent || event;
  if (e.preventDefault)
      e.preventDefault();
  if (e.stopPropagation)
      e.stopPropagation();
  e.cancelBubble = true;
  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 =  _proxy_jslib_handle(document, 'body', '', 0, 0);
    event.pageX = event.clientX + (doc && doc.scrollLeft ||  _proxy_jslib_handle(null, 'body', body, 0, 0) &&  _proxy_jslib_handle(null, 'body', body, 0, 0).scrollLeft || 0) - (doc.clientLeft || 0);
    event.pageY = event.clientY + (doc && doc.scrollTop ||  _proxy_jslib_handle(null, 'body', body, 0, 0) &&  _proxy_jslib_handle(null, 'body', body, 0, 0).scrollTop || 0) - (doc.clientTop || 0);
  }

  if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
    event.which = event.charCode || event.keyCode;

  // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  if ( !event.metaKey && event.ctrlKey )
    event.metaKey = event.ctrlKey;

  // Add which for click: 1 == left; 2 == middle; 3 == right
  // Note: button is not normalized, so don't use it
  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' || ! _proxy_jslib_handle(handlers, (event.type), '', 0, 0) || ! _proxy_jslib_handle(handlers, (event.type), '', 0, 0).length) {
    return;
  }
  try {
  //fixed: handlers[event.type] = undefined
  for (var i in ( _proxy_jslib_handle(handlers, (event.type), '', 0, 0) || [])) {
    if (event.type == 'mouseover' || event.type == 'mouseout') {
      var parent = event.relatedElement;
      // Traverse up the tree
      while (  _proxy_jslib_handle(null, 'parent', parent, 0, 0) &&  _proxy_jslib_handle(null, 'parent', parent, 0, 0) != this )
        try {  parent= _proxy_jslib_assign_rval('', 'parent', '=', (  _proxy_jslib_handle(null, 'parent', parent, 0, 0).parentNode), (typeof parent=='undefined' ? void 0 : parent)); }
        catch(e) {  parent= _proxy_jslib_assign_rval('', 'parent', '=', ( this), (typeof parent=='undefined' ? void 0 : parent)); }
      if ( _proxy_jslib_handle(null, 'parent', parent, 0, 0) == this) {
        continue
      }
    }
    var ret =  _proxy_jslib_handle( _proxy_jslib_handle(handlers, (event.type), '', 0, 0), (i), '', 0, 0).apply(this, arguments);
    if (ret === false) {
      cancelEvent(event);
    }
  }
  } catch (e) {
    debugLog(event.target.id+"."+event.type+": "+e.message);
  }
}

// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events
addEvent(window, "unload", function() {
  for (var id in vk_cache)
    if ( _proxy_jslib_handle(vk_cache, (id), '', 0, 0).handle &&  _proxy_jslib_handle(vk_cache, (id), '', 0, 0).handle.elem != window)
      removeEvent( _proxy_jslib_handle(vk_cache, (id), '', 0, 0).handle.elem);
});

// Dom ready event handler
(function() {
  var isRdy = false, rdyBnd = false, rdyList = [];

  window.onDomReady = function(fn) {
    bindRdy();
    if (isRdy){
      fn.call(document);
    } else {
      rdyList.push(function() {
        fn.call(document);
      });
    }
  };

  var rdy = function() {
    if (!isRdy) {
      isRdy = true;
      if (rdyList) {
        var l = rdyList;
        l.reverse();
        while (fn = l.pop()) {
          fn.apply(document);
        }
        rdyList = null;
      }
    }
  };

  var bindRdy = function() {
    if (rdyBnd) return;
      rdyBnd = true;

    if(document.addEventListener && !browser.opera)
      document.addEventListener("DOMContentLoaded", rdy, false);
    if (browser.msie && window ==  _proxy_jslib_handle(null, 'top', top, 0, 0)) (function() {
        if (isRdy) return;
        try {document.documentElement.doScroll("left"); }
        catch (e) {  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(arguments.callee,0); return; }
        rdy();
      })();
    if (browser.opera) document.addEventListener("DOMContentLoaded", function() {
      if (isRdy) return;
        rdy();
    }, false);
    if (browser.safari) {
      (function() {
        if(isRdy) return;
        if (document.readyState != "loaded" && document.readyState != "complete") {
           _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(arguments.callee,0);
          return;
        }
        rdy();
      })();
    }
    addEvent(window, "load", rdy);
  }
})();

/**
 * Ajax
 **/
function serializeForm(form) {
  if (typeof(form) != 'object') {
    return false;
  }
  var result = new (Array)();
  var g = function(n) {
    return  _proxy_jslib_handle(form, 'getElementsByTagName', '', 1, 0)(n)
 };
  var nv = function(i, e) {
    if (e.name)  _proxy_jslib_assign('', result, (e.name), '=', ( (browser.msie && ! _proxy_jslib_handle(e, 'value', '', 0, 0)) ?  _proxy_jslib_handle( _proxy_jslib_handle(form, (e.name), '', 0, 0), 'value', '', 0, 0) :  _proxy_jslib_handle(e, 'value', '', 0, 0)));
  };
  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 = [], q, i =0;
 for (var key in qa) {
   if ( _proxy_jslib_handle(qa, (key), '', 0, 0) === undefined ||  _proxy_jslib_handle(qa, (key), '', 0, 0) === null || typeof( _proxy_jslib_handle(qa, (key), '', 0, 0)) == 'function') continue;
   if (isArray( _proxy_jslib_handle(qa, (key), '', 0, 0))) {
     for (var i = 0; i <  _proxy_jslib_handle(qa, (key), '', 0, 0).length; (i= _proxy_jslib_assign_rval('++', 'i', '', '', (typeof i=='undefined' ? void 0 : i)))) {
       if ( _proxy_jslib_handle( _proxy_jslib_handle(qa, (key), '', 0, 0), (i), '', 0, 0) === undefined ||  _proxy_jslib_handle( _proxy_jslib_handle(qa, (key), '', 0, 0), (i), '', 0, 0) === null || typeof( _proxy_jslib_handle( _proxy_jslib_handle(qa, (key), '', 0, 0), (i), '', 0, 0)) == 'function') continue;
       query.push(encodeURIComponent(key) + '[]=' + encodeURIComponent( _proxy_jslib_handle( _proxy_jslib_handle(qa, (key), '', 0, 0), (i), '', 0, 0)));
     }
   } else {
     query.push(encodeURIComponent(key) + '=' + encodeURIComponent( _proxy_jslib_handle(qa, (key), '', 0, 0)));
   }
 }
 return query.join('&');
}
function q2o(q) {
 var t = q;
 if (typeof q == 'string') {
   var d=q.split('&'),v,i; t={};
   for (i=0; i<d.length; i++) {
     v= _proxy_jslib_handle(d, (i), '', 0, 0).split('=');
      _proxy_jslib_assign('', t, (decodeURIComponent(v[0])), '=', ( decodeURIComponent(v[1])));
   }
 }
 return t;
}
function Ajax(onDone, onFail, eval_res) {
 var _t = this;
 this.onDone = onDone;
 this.onFail = onFail;
 var tram = null;
 try { tram = new (XMLHttpRequest)(); }
 catch(e) { tram = null; }
 if (!tram) {
  try { if(!tram) tram = new (ActiveXObject)("Msxml2.XMLHTTP"); }
  catch(e) { tram = null; }
 }
 if (!tram) {
  try { if(!tram) tram = new (ActiveXObject)("Microsoft.XMLHTTP"); }
  catch(e) { tram = null; }
 }

 var readystatechange = function(url, data) {
    if(tram.readyState == 4 ) {
     if(tram.status >= 200 && tram.status < 300) {
       if(eval_res) parseRes();
       if( _t.onDone ) _t.onDone(extend(_t, {url: url, data: data}), tram.responseText);
     } else {
       _t.status = tram.status;
       _t.readyState = tram.readyState;
       if( _t.onFail ) _t.onFail(extend(_t, {url: url, data: data}), tram.responseText);
     }
   }
 };

 var parseRes = function() {
   if(!tram || !tram.responseText)return;
   var res =  _proxy_jslib_handle(tram.responseText, 'replace', '', 1, 0)(/^[\s\n]+/g, '');

   if(res.substr(0,10)=="<noscript>")
   {
     try{
       var arr = res.substr(10).split("</noscript>");
       eval(_proxy_jslib_proxify_js((arr[0]), 0, 0) );
       tram.responseText = arr[1];
     }catch(e){
       debugLog('eval ajax script:' + e.message);
     }
   }else{}
  };
  this.get = function(u, d, f) {
   tram.onreadystatechange = function() { readystatechange(u, d); };
   f = f || false;
   var q = (typeof(d) != 'string') ? ajx2q(d) : d;
   u = u + (q ? ('?'+q) : '');
    _proxy_jslib_handle(tram, 'open', '', 1, 0)('GET', u, !f);

   tram.setRequestHeader("X-Requested-With", "XMLHttpRequest");
   tram.send('');
  };
  this.post = function(u, d, f) {
   tram.onreadystatechange = function() { readystatechange(u, d); };
   f = f || false;
   var q = (typeof(d) != 'string') ? ajx2q(d) : d;
   try {
      _proxy_jslib_handle(tram, 'open', '', 1, 0)('POST', u, !f);
   } catch(e) {
     debugLog('ajax post error: '+e.message);
   }
   tram.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   tram.setRequestHeader("X-Requested-With", "XMLHttpRequest");
   tram.send(q);
  };
}

function activate_mobile(from_captcha, on_hide) {
  if (from_captcha) {
    on_hide = function() {
      Ajax._captchaBox.show();
      if (!window.need_mobile_act) {
        triggerEvent(ge('captchaKey'), 'keypress', {keyCode: 13});
      }
    }
  }
  showBox('activate_mobile', 'activation.php', {act: 'activate_mobile_box'}, false, true, {type: 'POPUP', hideOnClick: false, progress: 'activate_progress', onHide: on_hide}, ['css/al/reg.css']);
}

(function() {
  var ajaxObjs = {};
  window.Ajax.Get = function(p) {
    var a = (p.key)? _proxy_jslib_handle(ajaxObjs, (p.key), '', 0, 0):null;
    if(!a){
      a = new (Ajax)(p.onDone, p.onFail,  _proxy_jslib_handle(p, 'eval', '', 0, 0));
      if(p.key) _proxy_jslib_assign('', ajaxObjs, (p.key), '=', ( a));
    }
    a.get(p.url, p.query, p.sync);
  }
  window.Ajax.Post = function(p) {
    var a = (p.key)? _proxy_jslib_handle(ajaxObjs, (p.key), '', 0, 0):null;
    if(!a){
      a = new (Ajax)(p.onDone, p.onFail,  _proxy_jslib_handle(p, 'eval', '', 0, 0));
      if(p.key) _proxy_jslib_assign('', ajaxObjs, (p.key), '=', ( a));
    }
    a.post(p.url, p.query, p.sync);
  }
  window.Ajax.postWithCaptcha = function(url, data, options) {
    var onSuccess, onFail, onCaptchaShow, onCaptchaHide, difficulty;
    if (!options) options = {};
    if (isFunction(options)) {
      onSuccess = options;
    } else {
      onSuccess = options.onSuccess;
      onFail = options.onFail;
      onCaptchaShow = options.onCaptchaShow;
      onCaptchaHide = options.onCaptchaHide;
    }
    difficulty = options.difficultCaptcha ? '' : 's=1&';
    var p = {
      url: url,
      query: data,
      onFail: function(ajaxObj, responseText) {
        if (isFunction(onFail)) onFail(ajaxObj, responseText);
        if (window.Ajax._captchaBox) {
          window.Ajax._captchaBox.setOptions({onHide: function() {}}).hide();
          if (isFunction(onCaptchaHide)) onCaptchaHide(true);
        }
      },
      onDone: function(ajaxObj, responseText) {
        var response;
        try {
        response = eval(_proxy_jslib_proxify_js(('(' + responseText + ')'), 0, 0) );
        if (response.ok && response.ok == -5) {
          if (ge('please_confirm_mail')) {
            response.ok = -4;
          }
        }
        if (response.ok && response.ok == -5) {
          if (isFunction(onCaptchaShow)) onCaptchaShow()
 activate_mobile(false, function() {
            if (!window.need_mobile_act) {
              Ajax.Post(p);
            }
            if (onCaptchaHide) onCaptchaHide(!window.need_mobile_act);
          });
        } else if (response.ok && response.ok == -4) {
          if (isFunction(onCaptchaShow)) onCaptchaShow()
 if (ge('please_confirm_mail')) {
            show_change_mail_box(onCaptchaHide);
          } else {
            if (onCaptchaHide) onCaptchaHide();
          }
        } else if (response.ok && response.ok == -3) {
          var t;
          var iframe = document.createElement('iframe');
          iframe.style.visibility = 'hidden';
          iframe.style.position = 'absolute';
           _proxy_jslib_assign('', iframe, 'src', '=', ( "http://login.vk.com/"));
           _proxy_jslib_handle(document, 'body', '', 0, 0).appendChild(iframe);
          var onload = function() {
           try {
            var href =  _proxy_jslib_handle( _proxy_jslib_handle(iframe.contentWindow, 'location', '', 0, 0), 'href', '', 0, 0);
            if ( _proxy_jslib_handle(null, 'href', href, 0, 0).indexOf('slogin') != -1) {
             if ( _proxy_jslib_handle(null, 'href', href, 0, 0).indexOf('nonenone') != -1) {
               _proxy_jslib_assign('',  _proxy_jslib_handle(null, 'location', location, 0, 0), 'href', '=', ( base_domain+'login.php?op=logout')); return false;
             } else {
              Ajax.Post(p);
             }
             clearInterval(t);
            }
           } catch(e) {}
          }
          if (browser.msie) {
             t =  _proxy_jslib_handle(null, 'setInterval', setInterval, 1, 0)(function() {
              if (iframe.document.readyState == 'complete') {
                onload();
              }
            }, 200);
          } else {
           iframe.onload = onload;
          }
        } else if (response.ok && response.ok == -2) {
          if (window.Ajax._captchaBox == undefined) {
             window.Ajax._captchaBox = new (MessageBox)({title: getLang('captcha_enter_code'), width: 300});
          }
          if (response.difficult !== undefined) {
            difficulty = intval(response.difficult) ? '' : 's=1&';
          }
          var box = window.Ajax._captchaBox;
          box.removeButtons();
          var key;
          var onClick = function() {
           removeEvent(key, 'keypress');
           if (typeof(p.query) == 'object') {
             extend(p.query, {'captcha_sid': response.captcha_sid, 'captcha_key':  _proxy_jslib_handle(key, 'value', '', 0, 0)});
           } else {
             p.query += '&captcha_sid=' + response.captcha_sid + '&captcha_key=' +  _proxy_jslib_handle(key, 'value', '', 0, 0);
           }
           Ajax.Post(p);
           hide('captchaKey');
           show('captchaLoader');
           return false;
          };
          var about_mobile_text = '';
          if (window.need_mobile_act == 1 && !ge('please_confirm_mail')) {
            about_mobile_text =  _proxy_jslib_handle( _proxy_jslib_handle(global_try_to_activate, 'replace', '', 1, 0)('{link}', '<a href="javascript: activate_mobile(true)">'), 'replace', '', 1, 0)('{/link}', '</a>');
            about_mobile_text = '<div style="text-align: center; font-size: 10px; padding-top: 5px; line-height: 15px;">' + about_mobile_text + '</span>';
          }
          box.addButton({label: getLang('captcha_cancel'), style: 'button_no', onClick: function() {
            removeEvent(key, 'keypress');
            box.hide();
          }});
          box.addButton({label: getLang('captcha_send'), onClick: onClick});
          box.setOptions({onHide: onCaptchaHide, bodyStyle: 'padding: 16px 14px' + (about_mobile_text.length ? ' 10px' : '')});
           _proxy_jslib_handle(box, 'content', '', 1, 0)('<div style="text-align: center; height: 76px"><a href="#" id="refreshCaptcha"><img id="captchaImg" class="captchaImg" src="'+base_domain+'captcha.php?' + difficulty + 'sid=' + response.captcha_sid + '"/></a><div></div><input id="captchaKey" class="inputText" name="captcha_key" type="text" style="width: 120px; margin: 3px 0px 0px;" maxlength="7"/><img id="captchaLoader" src="'+base_domain+'images/progress7.gif" style="display:none; margin-top: 13px;" /></div>' + about_mobile_text);
          box.show();
          if (isFunction(onCaptchaShow)) onCaptchaShow();
          key = ge('captchaKey');
          addEvent(key, 'keypress', function(e) { if(e.keyCode==13){ onClick(); }});
          addEvent(ge('refreshCaptcha'), 'click', onClick);
          key.focus();
        } else {
          throw "Exit";
        }
       } catch (e) { // if captcha test passed
         if (options.json && response)
           responseText = response;
         else if (response && typeof(response.text) == 'string')
           responseText = response.text;
         if (window.Ajax._captchaBox) {
           window.Ajax._captchaBox.setOptions({onHide: function() {}}).hide();
           if (isFunction(onCaptchaHide)) onCaptchaHide(true);
         }
         if (isFunction(onSuccess)) onSuccess(ajaxObj, responseText);
       }
      }
     };
    Ajax.Post(p);
  }
  window.Ajax.Send = Ajax.postWithCaptcha;
})();

var ajaxHistory = $ah = new (function() {
   var _t = this;

   var curHash = "";
   var curHashes = {};
   var frame = null;
   var frame_doc = function() {
     return frame.contentDocument ? frame.contentDocument : (frame.contentWindow ? frame.contentWindow.document : frame.document);
   }
   var setFrameContent = function(hash) {
     var d = frame_doc();
      _proxy_jslib_handle(d, 'open', '', 1, 0)();
      _proxy_jslib_handle(d, 'write', '', 1, 0)('<div id="hash">' +
          _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle(hash, 'replace', '', 1, 0)('&', '&amp;'), 'replace', '', 1, 0)('"', '&quot;'), 'replace', '', 1, 0)('>', '&gt;'), 'replace', '', 1, 0)('<', '&lt;') +
       '</div>'
 );
      _proxy_jslib_handle(d, 'close', '', 1, 0)();
   }
   var forceLoad = false;
   var order = null;

   //_t.frameLoading = false;
   _t.enabled = false;
   _t.useCache = true;
   _t.onLoad = {};
   _t.cache = {};
   _t.preloads = {};

   var setHash = function(hash) {
     hash =  _proxy_jslib_handle(hash, 'replace', '', 1, 0)("#","");
     if( _proxy_jslib_handle(null, 'location', location, 0, 0).hash != "#" + hash){
        _proxy_jslib_handle(null, 'location', location, 0, 0).hash = "#" + hash;
       if(browser.msie && !browser.msie8){
//         frame.src = 'blank.html?ahHash='+encodeURIComponent(hash);

         if (browser.msie && !browser.msie8) {// added
           setFrameContent(hash);
         }
         handler();
       }
     }
     return true;
   };
   var getHash = function() {
     if(!browser.msie || browser.msie8)return  _proxy_jslib_handle( _proxy_jslib_handle(null, 'location', location, 0, 0).hash, 'replace', '', 1, 0)("#","");
     try{
       return  _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle( _proxy_jslib_handle(frame_doc(), 'getElementById', '', 1, 0)('hash'), 'innerHTML', '', 0, 0), 'replace', '', 1, 0)(/&lt;/ig, '<'), 'replace', '', 1, 0)(/&gt;/ig, '>'), 'replace', '', 1, 0)(/&quot;/ig, '"'), 'replace', '', 1, 0)(/&amp;/ig, '&');
     }catch(e){return curHash;}
   };
   var splitHash = function(hash) {
     if(!hash)return {};
     hash = hash.split("/");
     if(hash.length == 1){
       if(! _proxy_jslib_handle(_t.onLoad, ('default'), '', 0, 0))return {};
       if( _proxy_jslib_handle(_t.onLoad, ('default'), '', 0, 0).show)hash[0] =  _proxy_jslib_handle(_t.onLoad, ('default'), '', 0, 0).show.from(hash[0]);
       return {'default':sortParams(hash[0])};
     }
     var parsed = {};
     for(var i=0;i<hash.length;i+=2){
       var h =  _proxy_jslib_handle(hash, (i), '', 0, 0);var p =  _proxy_jslib_handle(hash, (i+1), '', 0, 0);
       if( _proxy_jslib_handle(_t.onLoad, (h), '', 0, 0).show){p = sortParams( _proxy_jslib_handle(_t.onLoad, (h), '', 0, 0).show.from(p));}
       else{
         p = sortParams(p);
         if(!p &&  _proxy_jslib_handle(_t.onLoad, (h), '', 0, 0))p = sortParams( _proxy_jslib_handle(_t.onLoad, (h), '', 0, 0).def);
       }
        _proxy_jslib_assign('', parsed, (h), '=', ( p));
     }
     return parsed;
   };
   var joinHash = function(hash) {
     var joined = [];
     var def = true;
     for(var i in hash){
       def = def && (i=='default');
       var p = sortParams( _proxy_jslib_handle(hash, (i), '', 0, 0));
       if( _proxy_jslib_handle(_t.onLoad, (i), '', 0, 0).show){
         var p1 =  _proxy_jslib_handle(_t.onLoad, (i), '', 0, 0).show.to(splitParams( _proxy_jslib_handle(hash, (i), '', 0, 0)));
         if(p1)p = p1;
       }
       joined.push(i + "/" + p);
     }
     if(def && joined[0])return joined[0].split("/")[1];
     return joined.sort().join("/");
   };
   var splitParams = function(params) {
     if(!params)return {};
     if(typeof(params)!='string')return params;
     if(!/&|=/.test(params))return params;
     var vals = params.split("&");
     var p = {};
     for(var i=0;i<vals.length;i++){
       var v =  _proxy_jslib_handle(vals, (i), '', 0, 0).split("=");
        _proxy_jslib_assign('', p, (v[0]), '=', ( v[1]));
     }
     return p;
   };
   var sortParams = function(params) {
     if(typeof(params)=='number')return params+'';
     if(typeof(params)!='string'){
       params = ajx2q(params);
     }
     return params.split("&").sort().join("&");
   };

  var handler = function() {
    var origHash = getHash();
    if(origHash==curHash && !forceLoad)return;
    var state = splitHash(origHash);
    var hash = joinHash(state);
    if(hash != curHash || forceLoad){
      curHash = hash;
      var ordered = order || _t.onLoad;
      for(var i in ordered){
        if(order)i =  _proxy_jslib_handle(ordered, (i), '', 0, 0);
        var l =  _proxy_jslib_handle(_t.onLoad, (i), '', 0, 0);
        var p =  _proxy_jslib_handle(state, (i), '', 0, 0) || sortParams(l.def);
        if (curHash != l.ignoreHash && (p !=  _proxy_jslib_handle(curHashes, (i), '', 0, 0) || i == forceLoad)) {
          var addAuto = !forceLoad ? '&auto=1' : '';
          forceLoad = false;
          if(l.before && !l.before(splitParams(p))){
             _proxy_jslib_assign('', curHashes, (i), '=', ( p));
            continue;
          }
          if (! _proxy_jslib_handle(_t.cache, (i), '', 0, 0))  _proxy_jslib_assign('', _t.cache, (i), '=', ( {}));
          if (! _proxy_jslib_handle(_t.preloads, (i), '', 0, 0))  _proxy_jslib_assign('', _t.preloads, (i), '=', ( {}));
          var p_good = decodeURIComponent(p);
          if (!_t.useCache || (! _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p), '', 0, 0) && ! _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p_good), '', 0, 0))) {
            if ( _proxy_jslib_handle( _proxy_jslib_handle(_t.preloads, (i), '', 0, 0), (p), '', 0, 0)) {
              if (l.done)  _proxy_jslib_assign('',  _proxy_jslib_handle(_t.preloads, (i), '', 0, 0), (p), '=', ( l.done));
            } else if ( _proxy_jslib_handle( _proxy_jslib_handle(_t.preloads, (i), '', 0, 0), (p_good), '', 0, 0)) {
              if (l.done)  _proxy_jslib_assign('',  _proxy_jslib_handle(_t.preloads, (i), '', 0, 0), (p_good), '=', ( l.done));
            } else {
              _t.getData(l,i,p + addAuto,hash);
            }
          } else if (l.done) {
            if ( _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p), '', 0, 0)) {
              l.done({},  _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p), '', 0, 0));
            } else {
              l.done({},  _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p_good), '', 0, 0));
            }
          }
           _proxy_jslib_assign('', curHashes, (i), '=', ( p));
        }
      }
      if (browser.msie && !browser.msie8) {
        if( _proxy_jslib_handle(null, 'location', location, 0, 0).hash!='#' + curHash)
           _proxy_jslib_handle(null, 'location', location, 0, 0).hash = '#' + curHash;
      }
    }
  };

  var inited = false;
 _t.init = function() {
   if(!this.enabled || inited)return;
   inited = true;
   for(var i in _t.onLoad){
     var p = sortParams( _proxy_jslib_handle(_t.onLoad, (i), '', 0, 0).def);
      _proxy_jslib_assign('', curHashes, (i), '=', ( p));
   };
   if (browser.msie && !browser.msie8){
//     var initHash = encodeURIComponent(location.hash);
     frame = document.createElement('iframe');
     frame.style.position = 'absolute';
     frame.style.visibility = 'hidden';
     frame.id = 'ahFrame';
     addEvent(frame, 'readystatechange', function() {
       if (this.contentWindow.document.readyState != 'complete') {
         return;
       }
       handler();
     });
//     frame.src = "/blank.html?ahHash=" + initHash;
      _proxy_jslib_handle(document, 'body', '', 0, 1).appendChild(frame);
     setFrameContent( _proxy_jslib_handle( _proxy_jslib_handle(null, 'location', location, 0, 0).hash, 'replace', '', 1, 0)('#', '')); //added
     handler();
   } else {
      _proxy_jslib_handle(null, 'setInterval', setInterval, 1, 1)(handler,150);
   }
 };
 _t.go = function(s, params) {
   if(params===undefined){params = s; s = 'default';}
   var state = splitHash(curHash);
    _proxy_jslib_assign('', state, (s), '=', ( sortParams(params)));
   var hash = joinHash(state);
   setHash(hash);
   forceLoad = s;
 };
 _t.getData = function(loadObj, id, params, hash) {
   var a = new (Ajax)(
   (function(l,i,p,t) {return function(res,text) {
     if(l.done)l.done(res,text);
     if (t.useCache) {
       var autoMarker = p.indexOf('&auto=1');
       if (autoMarker != -1) {
         p = p.substr(0, autoMarker);
       }
        _proxy_jslib_assign('',  _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p), '=', ( text));
     }
   };})(loadObj,id,params, _t),
   (function(l,i,p,t) {return function(res,text) {
     if(l.fail)l.fail(res,text);
   };})(loadObj,id,params, _t),
   true);
   a.post(loadObj.url, params );
 };
 _t.prepare = function(id, params) {
   _t.enabled = true;
   if(params===undefined){params = id; id = 'default';}
    _proxy_jslib_assign('', _t.onLoad, (id), '=', ( params));
 };
 _t.validateHash = function(hash) {return joinHash(splitHash(hash));};
 _t.clearCache = function(id) { _proxy_jslib_assign('', _t.cache, (id), '=', ( {}))};
 _t.setHash = function(s, hash) {
  if(hash===undefined){hash = s; s = 'default';}
   hash =  _proxy_jslib_handle(hash, 'replace', '', 1, 1)("#","");
   if( _proxy_jslib_handle(null, 'location', location, 0, 0).hash != "#" + hash){
      _proxy_jslib_handle(null, 'location', location, 0, 1).hash = "#" + hash;
     curHash = hash;
      _proxy_jslib_assign('', curHashes, (s), '=', ( curHash));
   }
 };
// Functions below work only with one - 'default' - id.
 _t.addToCache = function(hash, text) {
   if (!_t.useCache) return;
   var id = 'default';
   var state = splitHash(hash);
   if (! _proxy_jslib_handle(_t.cache, (id), '', 0, 0))  _proxy_jslib_assign('', _t.cache, (id), '=', ( {}));
   else if ( _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (id), '', 0, 0), ( _proxy_jslib_handle(state, (id), '', 0, 0)), '', 0, 0)) return;
    _proxy_jslib_assign('',  _proxy_jslib_handle(_t.cache, (id), '', 0, 1), ( _proxy_jslib_handle(state, (id), '', 0, 0)), '=', ( text));
 };
 _t.preLoad = function(hash, on_preloaded) {
   if (!_t.useCache) return;

   var id = 'default';
   var state = splitHash(hash);

   if (! _proxy_jslib_handle(_t.cache, (id), '', 0, 0))  _proxy_jslib_assign('', _t.cache, (id), '=', ( {}));
   if ( _proxy_jslib_handle( _proxy_jslib_handle(_t.cache, (id), '', 0, 0), ( _proxy_jslib_handle(state, (id), '', 0, 0)), '', 0, 0)) return;

   if (! _proxy_jslib_handle(_t.preloads, (id), '', 0, 0))  _proxy_jslib_assign('', _t.preloads, (id), '=', ( {}));
    _proxy_jslib_assign('',  _proxy_jslib_handle(_t.preloads, (id), '', 0, 1), ( _proxy_jslib_handle(state, (id), '', 0, 0)), '=', ( '<loading>'));

   var a = new (Ajax)(
   (function(i,p) {return function(res,text) {
     if ( _proxy_jslib_handle( _proxy_jslib_handle(_t.preloads, (i), '', 0, 0), (p), '', 0, 0) != '<loading>') {
        _proxy_jslib_handle( _proxy_jslib_handle(_t.preloads, (i), '', 0, 0), (p), '', 1, 0)(res, text);
     } else if (on_preloaded) {
       on_preloaded(res, text);
     }
      _proxy_jslib_assign('',  _proxy_jslib_handle(_t.cache, (i), '', 0, 0), (p), '=', ( text));
   };})(id,  _proxy_jslib_handle(state, (id), '', 0, 0)),
   function() {}, true);
   a.post( _proxy_jslib_handle(_t.onLoad, (id), '', 0, 0).url,  _proxy_jslib_handle(state, (id), '', 0, 0) + '&preload=1');
 }
})();

onDomReady(function() {
  ajaxHistory.init();
  var qq = ge('qquery');
  if(browser.iphone && qq){
     _proxy_jslib_assign('', qq, 'innerHTML', '=', ( '<form onsubmit="friendFilter({keyCode:13}); return false;">' +  _proxy_jslib_handle(qq, 'innerHTML', '', 0, 0) + '</form>'));
  }
});

/**
 * Cookies
 **/

var _cookies;
function _initCookies() {
  _cookies = {};
  var ca =  _proxy_jslib_handle(document, 'cookie', '', 0, 0).split(';');
  var re = /^[\s]*([^\s]+?)$/i;
  for(var i = 0; i < ca.length; i++) {
    var c =  _proxy_jslib_handle(ca, (i), '', 0, 0).split("=");
    if(c.length == 2) {
      _proxy_jslib_assign('', _cookies, (c[0].match(re)[1]), '=', ( unescape(c[1].match(re) ? c[1].match(re)[1] : '')));
    }
  }
}
function getCookie(name) {
  if(!_cookies) _initCookies();
  return  _proxy_jslib_handle(_cookies, (name), '', 0, 0);
}
function setCookie(name, value, days) {
  if(!_cookies) _initCookies();
   _proxy_jslib_assign('', _cookies, (name), '=', (  _proxy_jslib_handle(null, 'value', value, 0, 0)));
  if (days) {
    var date = new (Date)();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  var domain =  _proxy_jslib_handle( _proxy_jslib_handle(null, 'location', location, 0, 0), 'host', '', 0, 0).match(/[^.]+\.[^.]+$/);
   _proxy_jslib_assign('', document, 'cookie', '=', ( name+"="+escape( _proxy_jslib_handle(null, 'value', value, 0, 0))+expires+"; path=/"+( _proxy_jslib_handle(null, 'domain', domain, 0, 0) ? '; domain=.'+ _proxy_jslib_handle(null, 'domain', domain, 0, 0) : '')));
}

/**
 * Other stuff
 **/

function dispatchIntro(step, params) {
  if (typeof dispatchIntroEvent != 'undefined') {dispatchIntroEvent(step, params);}
}

var send_request_url = 'http://userapi.com/data?';

var qCur = 0, qOn = 0, sOn = 0, qfOn = 0, qd = 0, l = 0, qa = 0, qfCur = -1, newSearch = 0;
// var qArr is in langpack

reqs = []; res = [];
friends_l = [];
friends_arr = [];
floaded = false;

function doRequest(params, resultFunc) {
  var req = createRequest(params, resultFunc);
  sendRequest(req);
}

function createRequest(params, resultFunc) {
  var req = new (Object)();
  req.params = params;
  req.resultFunc = resultFunc;
  req.destroy = destroy;
  var rnum = Math.floor(Math.random()*1000);
  req.num = rnum;
  req.running = 1;
   _proxy_jslib_assign('', reqs, (rnum), '=', ( req));
  return req;
}

function getFriends() {
 doRequest('&id='+getCookie('remixmid')+'&act=friends&to=2500&w=50', gotFriends);
}

function gotFriends(result) {
 friends_arr = result;
 var l = friends_arr.length;
 for (var i = 0; i < l; i++) {
   _proxy_jslib_assign('', friends_l, (i), '=', (  _proxy_jslib_handle(friends_arr, (i), '', 0, 0)[1].toLowerCase()));
 }
 floaded = true;
}

function friendNav(k) {
  if (k == 38) {
   if (qd) {if (qCur > 0) {qCur = qCur - 1} else {qCur = qArr.length-1}; genQDrop(); return true}
   if (qfCur > -1) {qfrOn(qfCur-1)} else {qfrOn(l-1)}
   return true;
  }
  if (k == 40) {
   if (qd) {if (qCur < qArr.length-1) {qCur = qCur + 1} else {qCur = 0}; genQDrop(); return true}
   if (qfCur < l - 1) {qfrOn(qfCur+1)} else {qfrOn(-1)}
   return true;
  }
  if (k == 27) {
    searchOut(ge('qinput'));
    return false;
  }
  if (k == 13) {
   if (qd) {hideQDrop(qCur); return true;}
   if (!parseInt(qCur) && qfCur > -1 && res.length &&  _proxy_jslib_handle(res, (qfCur), '', 0, 0) &&  _proxy_jslib_handle(res, (qfCur), '', 0, 0)[0]) {
     _proxy_jslib_assign('', window, 'location', '=', ( base_domain+'id'+ _proxy_jslib_handle(res, (qfCur), '', 0, 0)[0]));
    return true;
   } else {
    if (!newSearch) {
     qDoSearch();
    } else {
     globalSearch();
    }
    return false;
   }
  }
  return true;
 }

function friendFilter(e) {
 var k = 0;
 if (e) {
  k = e.keyCode;
  if (!friendNav(k)) {
    return;
  }
 }

 if (parseInt(( _proxy_jslib_handle(qArr, (qCur), '', 0, 0)||[])[0])) {return;}

 res = [];
 if (!floaded) {
  qfCur = -1;
  getFriends();
   _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(friendFilter, 700);
 }

 var st = 0, en = 0, img, cl, name, q_lat;
 var q =  _proxy_jslib_handle(ge('qinput'), 'value', '', 0, 0).toLowerCase();
 if (!q.length && k != 8) {
  return;
 }

// hideQDrop(qCur);

 q_lat = parseLatin(q);
 l = friends_l.length;
 for (var i = 0; i < l; i++) {
  if (q.length &&  _proxy_jslib_handle(friends_l, (i), '', 0, 0).indexOf(q) != -1) {
   res.push( _proxy_jslib_handle(friends_arr, (i), '', 0, 0));
  } else if (q_lat && q_lat.length &&  _proxy_jslib_handle(friends_l, (i), '', 0, 0).indexOf(q_lat) != -1) {
   res.push( _proxy_jslib_handle(friends_arr, (i), '', 0, 0));
  }
 }


 var str = '', onl = '';
 l = res.length;
 if (l > 10) {l = 10;}
 if (l) {
  for (var i = 0; i < l; i++) {
   name =  _proxy_jslib_handle(res, (i), '', 0, 0)[1];
   if (qfCur == i) {cl = 'qfr_cell_on'} else if (qfCur > -1 && qfCur == i - 1) {cl = 'qfr_cell_un'} else {cl = 'qfr_cell'}
   pos = name.toLowerCase().indexOf(q);
   if (pos == -1 && q_lat && q_lat.length) {
    q = q_lat;
    pos = name.toLowerCase().indexOf(q);
   }
   if (pos != -1) {
    if ( _proxy_jslib_handle(res, (i), '', 0, 0)[2].length > 1) {img = "<img src='"+ _proxy_jslib_handle(res, (i), '', 0, 0)[2]+"'>";} else {img = "?";}
    if ( _proxy_jslib_handle(res, (i), '', 0, 0)[3]) {onl = "<b class='qonl'>online</b>";} else {onl = "";}
    name = name.substr(0, pos) + "<span>" + name.substr(pos, q.length) + "</span>" + name.substr(pos+q.length);
   }
   var lnk = '<a href="'+base_domain+'mail.php?act=write&to='+ _proxy_jslib_handle(res, (i), '', 0, 0)[0]+'" onclick="cancelEvent(event); return showBox(\'sendMsg\', \'mail.php\', {act: \'a_write_box\', to: '+ _proxy_jslib_handle(res, (i), '', 0, 0)[0]+'}, true, true, {title: \''+( _proxy_jslib_handle(window, ('profile_newmsg_box_title'), '', 0, 0) || 'Íîâîå ñîîáùåíèå')+'\', progress: \'sending_progress\', width: 450});" class="qfr_lnk">'+( _proxy_jslib_handle(window, ('global_write_msg'), '', 0, 0) || 'Íàïèñàòü ñîîáùåíèå')+'</a>';
   str += "<div id='qfr"+i+"' class='"+cl+"' onmousemove=\"qfrOn("+i+")\" onmouseout=\"qfrOff("+i+")\" onclick=\"window.location='"+base_domain+"id"+ _proxy_jslib_handle(res, (i), '', 0, 0)[0]+"'\">"+lnk+"<table border=0><tr><td><div>"+img+"</div></td><td>"+name+onl+"</td></tr></table></div>";
  }
  show('qfriends');
  toggleFlash();
 } else {
  hide('qfriends');
  toggleFlash(true, 20);
 }
  _proxy_jslib_assign('', ge('qfriends'), 'innerHTML', '=', ( str));
}

function qfrOn(i) {
 if (qfCur > -1) {qfrOff(qfCur);}
 qfOn = 1; qfCur = i;
 if (ge('qfr'+i)) ge('qfr'+i).className = 'qfr_cell_on';
 if (ge('qfr'+(i+1))) {ge('qfr'+(i+1)).className = 'qfr_cell_un';}
}

function qfrOff(i) {
 qfOn = 0;
 if (ge('qfr'+i)) ge('qfr'+i).className = 'qfr_cell';
 if (ge('qfr'+(i+1))) {ge('qfr'+(i+1)).className = 'qfr_cell';}
}

function sendRequest(req) {
 attachScript('req'+req.num, send_request_url+req.params+'&sid='+getCookie('remixsid')+'&back=reqs['+req.num+'].resultFunc');
}

function attachScript(id, c) {
 var i, new_id =  _proxy_jslib_handle(c.substr(c.indexOf('/')+1, c.indexOf('.')-c.indexOf('/')+2), 'replace', '', 1, 0)(/[\/\.]/g, '_');
 var newreqs = [];
 for (reqnum in reqs) {
  req =  _proxy_jslib_handle(reqs, (reqnum), '', 0, 0);
  if (req) {
   if (req.running == 0) {
    ge('req'+req.num).parentNode.removeChild(ge('req'+req.num));
     _proxy_jslib_assign('', reqs, (reqnum), '=', ( null));
   } else {
     _proxy_jslib_assign('', newreqs, (reqnum), '=', ( req));
   }
  }
 }
 reqs = newreqs;
 var element = document.createElement('script');
 element.type = 'text/javascript';
  _proxy_jslib_assign('', element, 'src', '=', ( c + ( _proxy_jslib_handle(css_versions, (new_id), '', 0, 0) ? ('?' +  _proxy_jslib_handle(css_versions, (new_id), '', 0, 0)) : '')));
 element.id = id;
  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('head')[0].appendChild(element);
}


function destroy() {
 if ( _proxy_jslib_handle(reqs, (this.num), '', 0, 0)) {
   _proxy_jslib_handle(reqs, (this.num), '', 0, 0).running = 0;
 }
}


function addCss(c) {
  var new_id = c.substr(c.indexOf('/')+1, c.indexOf('.')-c.indexOf('/')-1)+'_css';
  if (!ge(new_id)) {
    var headID =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)("head")[0];
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
     _proxy_jslib_assign('', cssNode, 'href', '=', ( base_domain + c + ( _proxy_jslib_handle(css_versions, (new_id), '', 0, 0) ? ('?' +  _proxy_jslib_handle(css_versions, (new_id), '', 0, 0)) : '')));
    cssNode.id = new_id;
    cssNode.media = 'screen';
    headID.appendChild(cssNode);
  }
}

var rateBox;
function showRateVotesBox() {
  if (window.event && (window.event.which == 2 || window.event.button == 1)) {
    return true;
  }
  addCss('css/privacy.css');
  addCss('css/wiki.css');
  if (rateBox == undefined) {
    rateBox = new (MessageBox)(
     {title: getLang('global_rating_box_header'), bodyStyle: 'padding:0px', width: '480px', progress: 'rateProgress'}
    );
  }
  rateBox.removeButtons();
  rateBox.addButton({
    onClick: function() { rateBox.hide(200); },
    label: getLang('box_close')
 });
  rateBox.loadContent('rate.php', {'act':'a_get_rate_votes', 'full': 1}, true).show();
  return false;
}

function searchOn(obj) {
 _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {  if (!qd) toggleFlash(true, 20);
  sOn = 1;
  var qq = ge('qquery');
  var ph = obj.getAttribute('placeholder');
  if ( _proxy_jslib_handle(obj, 'value', '', 0, 0) &&  _proxy_jslib_handle(obj, 'value', '', 0, 0) != ph) {return;}
  hide('topNav');
  var pageOffset = ge('pageLayout').offsetWidth-791 + (browser.msie6 ? -15 : 0);
  qq.style.width = (browser.iphone) ? '238px': (618+pageOffset)+'px';
  obj.style.width = (browser.iphone) ? '68px': (448+pageOffset)+'px';
  ge('quickSearch').style.width = (browser.iphone) ? '245px': (625+pageOffset)+'px';
   _proxy_jslib_assign('', obj, 'value', '=', ( ''));
  var qs = qd ? 'qdrop_on' : 'qdrop_off';
   _proxy_jslib_assign('', ge('qchoose'), 'innerHTML', '=', ( "<div onclick=\"showQDrop()\" id='qdrop' class='"+qs+"' onmousemove=\"qOn = 1;if (!qd) {this.className='qdrop_over'}\" onmouseout=\"qOn = 0; if (!qd) {this.className='qdrop_off'}\">"+ _proxy_jslib_handle(qArr, (qCur), '', 0, 0)[1]+"</div>"));
  genQDrop();
  obj.style.color = '#000';
  if (!qa) showQDrop(); }, 0);
}

function searchOut(qi) {
 if (qOn || qfOn) {return;}
 hide('qfriends');
 sOn = 0;
// toggleFlash(true, 20);
 if (qd)
   hideQDrop(qCur);
 else
   toggleFlash(true, 20);
 qi.blur();
 qd = 0;
 var ph = qi.getAttribute('placeholder');
 if ( _proxy_jslib_handle(qi, 'value', '', 0, 0) &&  _proxy_jslib_handle(qi, 'value', '', 0, 0) != ph) {
   return;
 }
  _proxy_jslib_assign('', ge('qchoose'), 'innerHTML', '=', ( ""));
 var qq = ge('qquery');
 qi.style.color = '#777';
 qi.style.width = '85px';
 qq.style.width = '105px';
 ge('quickSearch').style.width = '112px';
 show('topNav');
  _proxy_jslib_assign('', qi, 'value', '=', ( ph)); qa = 0;
}

function genQDrop() {
 var str = '', qoff, qover, st = '', j;
 for (j = qArr.length - 1; j > -1; j--) {
  if (links_visibility &  _proxy_jslib_handle(qArr, (j), '', 0, 0)[4] || ! _proxy_jslib_handle(qArr, (j), '', 0, 0)[4]) {
   break;
  }
 }
 for (var i = 0; i < qArr.length; i++) {
  if (i != qCur) {qoff = 'qdiv_off', qover = 'qdiv_over'; if (!i) {qover='qdiv_over_top';}} else {qoff = 'qdiv_on', qover = 'qdiv_on';}
  if (i == j) {st = "style='border-bottom: 1px solid ";if (i!=qCur){st+="#2A5883;'";}else{st+="#839EB7;'";}} else {st='';}
  if (links_visibility &  _proxy_jslib_handle(qArr, (i), '', 0, 0)[4] || ! _proxy_jslib_handle(qArr, (i), '', 0, 0)[4]) {
   str += "<div onclick='hideQDrop("+i+")' class='"+qoff+"' onmousemove=\"qOn = 1; if(qd) this.className='"+qover+"'\" onmouseout=\"qon=0; this.className='"+qoff+"'\" "+st+">"+ _proxy_jslib_handle(qArr, (i), '', 0, 0)[1]+"</div>";
  }
 }
  _proxy_jslib_assign('', ge('qdropdown'), 'innerHTML', '=', ( str));
}

function startHide() {
 if (qOn) return;
 hideQDrop(qCur);
}

function showQDrop() {
 if (qd) {hideQDrop(qCur);return;}
// alert(ge('qdropdown').style.display);
//  hideQDrop(qCur);return;
 toggleFlash();
 hide('qfriends');
 genQDrop();
 qd = 1; qa = 1; qOn = 1;
 ge('qdrop').className = 'qdrop_on';
 show('qdropdown');
 dispatchIntro(2);
// ge('qinput').focus();
}

function hideQDrop(i) {
 if (!qd) return;
 qOn = 0; qCur = i; qd = 0;
 var qdrop = ge('qdrop');
 if (qdrop) {
   _proxy_jslib_assign('', qdrop, 'innerHTML', '=', (  _proxy_jslib_handle(qArr, (i), '', 0, 0)[1]));
  qdrop.className = 'qdrop_off';
  hide('qdropdown');
 }
 toggleFlash(true, 20);
 if (sOn) ge('qinput').focus();
 dispatchIntro(3);
}

function qDoSearch() {
 var qi = ge('qinput');
 var names_only = "";
 var ph = qi.getAttribute('placeholder');
 if (! _proxy_jslib_handle(qi, 'value', '', 0, 0) ||  _proxy_jslib_handle(qi, 'value', '', 0, 0) == ph) {return;}
 if (!qCur &&  _proxy_jslib_handle(qi, 'value', '', 0, 0)) {names_only = "&name=1";}
  _proxy_jslib_assign('', window, 'location', '=', ( base_domain+'gsearch.php?section='+ _proxy_jslib_handle(qArr, (qCur), '', 0, 0)[3]+'&q='+ _proxy_jslib_handle(qi, 'value', '', 0, 0)+names_only));
}

function parseLatin(text) {
  var outtext = text;
  var lat1 = ["yo","zh","kh","ts","ch","sch","shch","sh","eh","yu","ya","YO","ZH","KH","TS","CH","SCH","SHCH","SH","EH","YU","YA","'"];
  var rus1 = ["¸", "æ", "õ", "ö", "÷", "ù",  "ù",   "ø", "ý", "þ", "ÿ", "¨", "Æ", "Õ", "Ö", "×", "Ù",  "Ù",   "Ø", "Ý", "Þ", "ß", "ü"];
  for(var i=0;i<lat1.length;i++){
    outtext = outtext.split( _proxy_jslib_handle(lat1, (i), '', 0, 0)).join( _proxy_jslib_handle(rus1, (i), '', 0, 0));
  }
  var lat2 = "abvgdezijklmnoprstufhcyABVGDEZIJKLMNOPRSTUFHCY" + "¸¨";
  var rus2 = "àáâãäåçèéêëìíîïðñòóôõöûÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÛ" + "åÅ";
  for(var i=0;i<lat2.length;i++){
    outtext = outtext.split(lat2.charAt(i)).join(rus2.charAt(i));
  }
  return (outtext==text)?null:outtext;
}

function placeholderSetup(id) {
  var el = ge(id);
  if (!el) return;
  var ph = el.getAttribute("placeholder");
  if (ph && ph != "") {
     _proxy_jslib_assign('', el, ('active'), '=', ( 1));
    if (! _proxy_jslib_handle(el, 'value', '', 0, 0) && !el.focused) {
      el.style.color = '#777';
       _proxy_jslib_assign('', el, 'value', '=', ( ph));
       _proxy_jslib_assign('', el, ('active'), '=', ( 0));
    }
    if (! _proxy_jslib_handle(el, ('phevents'), '', 0, 0)) {
    addEvent(el, 'focus', function() {
      if ( _proxy_jslib_handle(el, ('active'), '', 0, 0)) return;
       _proxy_jslib_assign('', el, ('active'), '=', ( 1));
       _proxy_jslib_assign('', el, 'value', '=', ( ''));
      el.style.color = '#000';
    });
    addEvent(el, 'blur', function() {
      if( ! _proxy_jslib_handle(el, ('active'), '', 0, 0) || !ph ||  _proxy_jslib_handle(el, 'value', '', 0, 0) != "" ) return;
       _proxy_jslib_assign('', el, ('active'), '=', ( 0));
      el.style.color = '#777';
       _proxy_jslib_assign('', el, 'value', '=', ( ph));
    });
    }
     _proxy_jslib_assign('', el, ('phevents'), '=', ( 1));
  }
}

function setSelRange(id, from, to) {
  var el = ge(id);
  if (!el || (el.type.toLowerCase() != 'text' && el.type.toLowerCase() != 'password' && el.tagName.toLowerCase() != 'textarea')) return;
  el.focus();
  if (el.createTextRange) {
    var range = el.createTextRange();
    range.collapse(true);
    range.moveEnd('character', from);
    range.moveStart('character', to);
    range.select();
  } else if (el.setSelectionRange) {
    el.setSelectionRange(from, to);
  }
}

function focusAtEnd(id) {
  var el = ge(id);
  if (!el || (el.type != 'text' && el.type != 'password' && el.tagName != 'textarea')) return;
  setSelRange(el,  _proxy_jslib_handle(el, 'value', '', 0, 0).length,  _proxy_jslib_handle(el, 'value', '', 0, 0).length);
}

/**
 * Message box
 **/
var _message_box_guid = 0,
    _message_boxes = [],
    _message_box_shown = 0,
    _doc_block_timeout, _doc_blocked = false;
function MessageBox(options) {
  var defaults = {
    type: "MESSAGE", // "MESSAGE" || "POPUP"
    hideOnClick: true,
    title: "Alert",
    width: "410px",
    height: "auto",
    bodyStyle: "",
    closeButton: false, // AntanubiS - 'X' close button in the caption.
    fullPageLink: '', // If is set - 'box'-like button in the caption.
    progress: false, // AntanubiS - Progress bar.
    returnHidden: false  
 };

  options = extend(defaults, options);

  var buttonsCount = 0, body =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('body')[0],
      transparentBG, boxContainer, boxBG, boxContainer, boxLayout, boxTitle, boxBody, boxControls, boxProgress, buttonYes, buttonNo, boxCloseButton, boxFullPageLink,
      guid = ((_message_box_guid= _proxy_jslib_assign_rval('++', '_message_box_guid', '', '', (typeof _message_box_guid=='undefined' ? void 0 : _message_box_guid)))), isVisible = false, hiddenBox;

  transparentBG = ge('popupTransparentBG');
  if (!transparentBG) {
    transparentBG = document.createElement('div');
    transparentBG.className = 'popup_transparent_bg';
     _proxy_jslib_assign('', transparentBG, 'innerHTML', '=', ( '<iframe class="box_frame"></iframe>'));
    hide(transparentBG);
  }
  transparentBG.style.height = getSize(document)[1] + 'px';

  boxContainer = document.createElement('div');
  boxContainer.className = 'popup_box_container';
  hide(boxContainer);
  var x_button = options.closeButton ? '<div class="box_x_button"></div>' : '';
  var full_page_button = options.fullPageLink ? '<a onfocus="this.blur()" class="box_full_page_link" href="' + options.fullPageLink + '"></a>' : '';
   _proxy_jslib_assign('', boxContainer, 'innerHTML', '=', ( '<div class="box_layout"><div class="box_title_wrap">' + x_button + full_page_button + '<div class="box_title"></div></div><div class="box_body" style="'+options.bodyStyle+'"></div><div class="box_controls_wrap"><div class="box_controls"></div></div></div>'));

  boxFrame = geByClass('box_frame', transparentBG)[0];
  boxLayout = geByClass('box_layout', boxContainer)[0];
  boxTitle = geByClass('box_title', boxContainer)[0];
  boxBody = geByClass('box_body', boxContainer)[0];
  boxControls = geByClass('box_controls', boxContainer)[0];
  boxCloseButton = options.closeButton ? geByClass('box_x_button', boxContainer)[0] : false;
  boxFullPageLink = options.fullPageLink ? geByClass('box_full_page_link', boxContainer)[0] : false;

  if (options.progress) {
     _proxy_jslib_assign('', boxControls, 'innerHTML', '=', ( '<img src="' + base_domain + 'images/upload.gif" id="' + options.progress + '" style="display: none" />'));
    boxProgress = boxControls.firstChild;
  } else {
    boxProgress = null;
  }

  addEvent(document, 'keydown', function(e) {
    if (e.keyCode == 27) {
      hideBox();
    }
  });

  if (!_message_boxes.length) {
    addEvent(document, 'block unblock', function(e) {
      toggleFlash(e.type == 'unblock');
    });
  }

  onDomReady(function() {
     _proxy_jslib_handle(null, 'body', body, 0, 0).appendChild(transparentBG);
     _proxy_jslib_handle(null, 'body', body, 0, 0).appendChild(boxContainer);
    refreshBox();
    refreshCoords();
  });

  // Refresh box position
  function refreshCoords() {
    var height = window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight :  _proxy_jslib_handle(document, 'body', '', 0, 0).offsetHeight);
    containerSize = getSize(boxContainer);
     _proxy_jslib_assign('', boxFrame.style, 'top', '=', (
     _proxy_jslib_assign('', boxContainer.style, 'top', '=', ( Math.max(0, Math.max(document.documentElement.scrollTop,   _proxy_jslib_handle(null, 'body', body, 0, 0).scrollTop) + (height - containerSize[1]) / 3) + 'px'))));
    boxFrame.style.marginLeft =
    boxContainer.style.marginLeft =  - containerSize[0] / 2 + 'px';
    setStyle(boxFrame, 'width', containerSize[0]);
    setStyle(boxFrame, 'height', containerSize[1]);
  }

  // Add button
  function addButton(options) {
    buttonsCount++;
    if (typeof options != 'object') options = {};
    options = extend({
        label: 'Button' + buttonsCount,
        style: 'button_yes'
 }, options);

    var buttonWrap = document.createElement('div');
    buttonWrap.className = options.style;
     _proxy_jslib_assign('', buttonWrap, 'innerHTML', '=', ( '<div id="button' + guid + '_' + buttonsCount + '">' + options.label + '</div>'));
    if (boxProgress) {
      boxControls.insertBefore(buttonWrap, boxProgress);
    } else {
      boxControls.appendChild(buttonWrap);
    }
    createButton(buttonWrap.firstChild, options.onClick);
    return buttonWrap;
  }
  // Add custom controls text
  function addControlsText(text) {
    var textWrap = document.createElement('div');
    textWrap.className = "controls_wrap";
     _proxy_jslib_assign('', textWrap, 'innerHTML', '=', ( text));
    boxControls.appendChild(textWrap);
    return textWrap;
  }

  // Remove buttons
  function removeButtons() {
    var buttons = [];
    buttonsCount = 0;
    each (boxControls.childNodes, function(i, x) {
      if (x && (!boxProgress || x != boxProgress)) {
        removeEvent(x);
        buttons.push(x);
      }
    });
    each(buttons, function() {boxControls.removeChild(this)});
   // boxControls.innerHTML = '';
  }

  // Refresh box properties
  function refreshBox() {
    // Set title
     _proxy_jslib_assign('', boxTitle, 'innerHTML', '=', ( options.title));

    // Set box dimensions
    boxContainer.style.width = typeof(options.width) == 'string' ? options.width : options.width + 'px';
    boxContainer.style.height = typeof(options.height) == 'string' ? options.height : options.height + 'px';

    // Switch box type
    removeClass(boxContainer, 'box_no_controls');
    removeClass(boxContainer, 'message_box');

    removeEvent(boxContainer, 'click');
    if (options.hideOnClick && options.type == 'POPUP') {
      addEvent(boxContainer, 'click', function() {
        hideBox();
      });
    }

    switch (options.type) {
      case 'POPUP':
        addClass(boxContainer, 'box_no_controls');
        if (options.hideOnClick) {
          addEvent(transparentBG, 'click', function() {
            hideBox();
          });
        }
      break;

      case 'MESSAGE':
        addClass(boxContainer, 'message_box');
        removeEvent(transparentBG, 'click');
      break;
    }
  }

  // Show box
  function showBox() {
    if (isVisible) return;
    isVisible = true;
    hiddenBox = 0;

    if (_message_box_shown &&  _proxy_jslib_handle(_message_boxes, (_message_box_shown), '', 0, 0).isVisible) {
      var box =  _proxy_jslib_handle(_message_boxes, (_message_box_shown), '', 0, 0);
      if (options.returnHidden) {
        hiddenBox = _message_box_shown;
        box.hideContainer();
      } else {
        box.hide();
      }
    }
//  fadeIn(boxContainer, 200); // Video wall posting fails with fadeIn
    show(boxContainer);

    refreshCoords();
    if (!_message_box_shown) {
      show(transparentBG);
      clearTimeout(_doc_block_timeout);
      if (!_doc_blocked) {
        _doc_blocked = true;
        triggerEvent(document, 'block');
      }
    }

    _message_box_shown = guid;

    if (options.onShow)
      options.onShow();
  }
  // Hide box
  function hideBox(speed) {
    if (!isVisible) return;
    if (options.onHideAttempt && !options.onHideAttempt()) return;
    isVisible = false;

    var onHide = function () {
      hide(boxContainer);
      var showHidden = false;
      if (options.returnHidden && hiddenBox) {
         _proxy_jslib_handle(_message_boxes, (hiddenBox), '', 0, 0).showContainer();
        _message_box_shown = hiddenBox;
        showHidden = true;
      }
      if (!showHidden) {
        _message_box_shown = 0;
        hide(transparentBG);
        clearTimeout(_doc_block_timeout);
        if (_doc_blocked) {
          _doc_block_timeout =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {
            _doc_blocked = false;
            triggerEvent(document, 'unblock');
          }, 50);
        }
      }
      if (options.onHide) options.onHide();
    }
    if (speed > 0)
      fadeOut(boxContainer, speed, onHide);
    else
      onHide();
  }

  var fadeToColor = function(color) {
    return function() {
      animate(this, {backgroundColor: color}, 200);
    }
  }
  if (boxCloseButton) {
    addEvent(boxCloseButton, 'mouseover', fadeToColor('#ffffff'));
    addEvent(boxCloseButton, 'mouseout', fadeToColor('#9CB8D4'));
    addEvent(boxCloseButton, 'click', hideBox);
  }
  if (boxFullPageLink) {
    addEvent(boxFullPageLink, 'mouseover', fadeToColor('#ffffff'));
    addEvent(boxFullPageLink, 'mouseout', fadeToColor('#9CB8D4'));
  }

  function onLoadError(text) {
     _proxy_jslib_assign('', boxBody, 'innerHTML', '=', ( 'Error: ' + text));
    removeButtons();
    addButton({label: getLang('box_close'), onClick: hideBox});
    refreshCoords();
    if (isFunction(options.onLoadError)) options.onLoadError(text);
  }

  var retBox = {
    guid: guid,
    // Show box
    show: function(speed) {
      showBox(speed); return this;
    },

    // Hide box
    hide: function(speed) {
      hideBox(speed); return this;
    },

    isVisible: function() {
      return isVisible;
    },

    // Insert html content into the box
    content: function(html) {
       _proxy_jslib_assign('', boxBody, 'innerHTML', '=', ( html));
      refreshCoords();
      return this;
    },

    // Load html content from URL
    loadContent: function(url, params, evaluate, loader_style) {
      // Show loader
      var st = loader_style ? loader_style : '';
       _proxy_jslib_assign('', boxBody, 'innerHTML', '=', ( '<div class="box_loader" style="' + st + '"></div>'));

      // Load remote html using get request
      if (typeof params != 'object') params = {};
      var self = this;
      Ajax.Send(url, params, {
       onSuccess: function(ajaxObj, responseText) {
        if (evaluate) {
          try {
           var result = eval(_proxy_jslib_proxify_js(('('+responseText+')'), 0, 0) );
            _proxy_jslib_assign('', boxBody, 'innerHTML', '=', ( result.html ? result.html : ''));
           if (result.script)   _proxy_jslib_handle(window, 'execScript', '', 0, 0) ?  _proxy_jslib_handle(window, 'execScript', '', 1, 0)(result.script) :  _proxy_jslib_handle(null, 'eval', eval, 0, 0).call(window, result.script);
          } catch (e) {return onLoadError(e.message);}
        } else {
           _proxy_jslib_assign('', boxBody, 'innerHTML', '=', ( responseText));
        }
        refreshCoords();
        if (isFunction(options.onLoad)) options.onLoad(responseText);
       },
       onFail: function(ajaxObj, responseText) {
        onLoadError('Request error occured.');
       }
      });

      return this;
    },

    // Add button
    addButton: function(options) {
      var btn = addButton(options);
      return (options.returnBtn) ? btn : this;
    },
    // Add
    addControlsText: function(text) {
      var el = addControlsText(text);
      return (options.returnBtn) ? el : this;
    },

    // Remove buttons
    removeButtons: function(options) {
      removeButtons();
      return this;
    },

    // Update box options
    setOptions: function(newOptions) {
      options = extend(options, newOptions);
      if ("bodyStyle" in newOptions) {
        var items = options.bodyStyle.split(';');
        for (var i = 0; i < items.length; (i= _proxy_jslib_assign_rval('++', 'i', '', '', (typeof i=='undefined' ? void 0 : i)))) {
          var name_value =  _proxy_jslib_handle(items, (i), '', 0, 0).split(':');
          if (name_value.length > 1 && name_value[0].length) {
             _proxy_jslib_assign('', boxBody.style, (trim(name_value[0])), '=', ( trim(name_value[1])));
          }
        }
      }
      if (options.fullPageLink && boxFullPageLink) {
         _proxy_jslib_assign('', boxFullPageLink, 'href', '=', ( options.fullPageLink));
      }
      refreshBox();
      refreshCoords();
      return this;
    },
    fixIE6: refreshBox,
    hideContainer: function() { isVisible = false; hide(boxContainer); },
    showContainer: function() { isVisible = true; show(boxContainer); }
  };
   _proxy_jslib_assign('', _message_boxes, (guid), '=', ( retBox));
  return retBox;
};

// Extends MessageBox
function AlertBox(title, text, callback, options) {
  var aBox = new (MessageBox)({title: title});
  if (typeof options == 'object') aBox.setOptions(options);
  else options = {};
  aBox.removeButtons();
  if (options.boxType == 'CONFIRM') {
   aBox.addButton({label:  getLang('box_no'), style: 'button_no', onClick: aBox.hide}).addButton({label: getLang('box_yes'), onClick: function() {
    if (isFunction(callback) && callback() === false) return;
    aBox.hide();
   }});
  } else {
    aBox.addButton({label:  getLang('box_close'), style: 'button_no', onClick: aBox.hide});
  }
  return  _proxy_jslib_handle(aBox, 'content', '', 1, 0)(text);
}

var button_anim = {duration: 200, transition: Fx.Transitions.halfSine};
var button_anims = {
  button_yes: {
    '' : {p: ['#6D8FB3', '#7E9CBC', '#5C82AB', '#5C82AB', '#5C82AB'], o: button_anim},
    '_hover': {p: ['#84A1BF', '#92ACC7', '#7293B7', '#7293B7', '#7293B7'], o: button_anim},
    '_down' : {p: ['#6688AD', '#51779F', '#51779F', '#7495B8', '#51779F'], o: 0}
  }, button_no: {
    '' : {p: ['#EAEAEA', '#FFFFFF', '#F4F4F4', '#DFDFDF', '#F4F4F4'], o: button_anim},
    '_hover': {p: ['#F7F7F7', '#FFFFFF', '#F4F4F4', '#DFDFDF', '#F4F4F4'], o: button_anim},
    '_down' : {p: ['#E4E4E4', '#CCCCCC', '#CBCBCB', '#E8E8E8', '#CBCBCB'], o: 0}
  }
}

/* 3-state button */
function createButton(el, onClick, classPrefix) {
  el = ge(el);
  if (!el) return;
  if (classPrefix == undefined) classPrefix = 'button';
  var upd = function(state) {
    if (! _proxy_jslib_handle(button_anims, (el.parentNode.className), '', 0, 0)) {
     el.className = classPrefix + state;
    } else {
     var a =  _proxy_jslib_handle( _proxy_jslib_handle(button_anims, (el.parentNode.className), '', 0, 0), (state), '', 0, 0);
     animate(el, {backgroundColor: a.p[0], borderTopColor: a.p[1], borderRightColor: a.p[2], borderBottomColor: a.p[3], borderLeftColor: a.p[4]}, a.o);
    }
  }
  var hover = false;
  addEvent(el, 'click mousedown mouseover mouseout', function(e) {
    var bc = getXY(el), bs = [el.offsetWidth, el.offsetHeight];
    switch (e.type) {
    case 'click':
      if (!hover) return;
      upd('_hover');
      if (isFunction(onClick)) onClick();
    break;
    case 'mousedown':
      upd('_down');
    break;
    case 'mouseover':
      upd('_hover');
      hover = true;
    break;
    case 'mouseout':
      upd('');
      hover = false;
    break;
    }
  });
}

var langBox;
function changeLang() {
 if (!langBox) {
  langBox = new (MessageBox)({title: (getLang('select_language')), width: 480});
  langBox.addButton({label:  getLang('box_close'), onClick: function() {langBox.hide(200)}});
 }
 langBox.loadContent('lang.php', {act:'lang_dialog'}, true).show();
 return false;
}
function doChangeLang(lang_id, hash) {
 Ajax.Send('lang.php', {act:'change_lang',lang_id: lang_id, hash:hash}, function() {
   setCookie('remixlang', lang_id);
    _proxy_jslib_handle(null, 'location', location, 0, 0).reload(true);
 });
 return false;
}

function nameTip(obj) {
 if (( _proxy_jslib_handle(qArr, (qCur), '', 0, 0)||[])[0] ||  _proxy_jslib_handle(obj, 'value', '', 0, 0).length || qd) {return;}
 show('qfriends');
  _proxy_jslib_assign('', ge('qfriends'), 'innerHTML', '=', ( "<div style='border-top: 1px solid #C6D0D9; padding: 4px 18px; background-color: #FAFAFA;'>"+top_search_tip+"</div>"));
};

(function() {
  var lastLength = 0;
  window.checkTextLength = function(max_len, val, warn, nobr) {
    if(lastLength==val.length)return;
    lastLength=val.length;
    var n_len = replaceChars(val, nobr).length;
    warn.style.display = (n_len > max_len - 100) ? "" : "none";
    if (n_len > max_len) {
       _proxy_jslib_assign('', warn, 'innerHTML', '=', ( getLang('text_exceeds_symbol_limit', n_len - max_len)));
    } else if (n_len > max_len - 100) {
       _proxy_jslib_assign('', warn, 'innerHTML', '=', ( getLang('text_N_symbols_remain', max_len - n_len)));
    } else {
       _proxy_jslib_assign('', warn, 'innerHTML', '=', ( ''));
    }
  };

  window.replaceChars = function(text, nobr) {
    var res = "";
    for (var i = 0; i<text.length; i++) {
      var c = text.charCodeAt(i);
      switch(c) {
        case 0x26: res += "&amp;"; break;
        case 0x3C: res += "&lt;"; break;
        case 0x3E: res += "&gt;"; break;
        case 0x22: res += "&quot;"; break;
        case 0x0D: res += ""; break;
        case 0x0A: res += nobr?"\t":"<br>"; break;
        case 0x21: res += "&#33;"; break;
        case 0x27: res += "&#39;"; break;
        default:   res += ((c > 0x80 && c < 0xC0) || c > 0x500) ? "&#"+c+";" : text.charAt(i); break;
      }
    }
    return res;
  };
})();

var winBoxes = {};
function showBox(name, url, query, lnk, reload, params, files) {
  if (lnk && window.event && (window.event.which == 2 || window.event.button == 1)) {
    return true;
  }
  if (! _proxy_jslib_handle(winBoxes, (name), '', 0, 0)) {
    params = extend({title: getLang('box_loading')}, params);
     _proxy_jslib_assign('', winBoxes, (name), '=', ( new (MessageBox)(params)));
    reload = true;
    if (files) {
      for (var i in files) {
        if (/\.css/i.test( _proxy_jslib_handle(files, (i), '', 0, 0))) {
          addCss( _proxy_jslib_handle(files, (i), '', 0, 0));
        } else if (/\.js/i.test( _proxy_jslib_handle(files, (i), '', 0, 0))) {
          attachScript('script'+i,  _proxy_jslib_handle(files, (i), '', 0, 0));
        }
      }
    }
  }
  if (reload) {
     _proxy_jslib_handle(winBoxes, (name), '', 0, 0).removeButtons();
     _proxy_jslib_handle(winBoxes, (name), '', 0, 0).addButton({label: global_close, onClick:  _proxy_jslib_handle(winBoxes, (name), '', 0, 0).hide});
     _proxy_jslib_handle(winBoxes, (name), '', 0, 0).loadContent(url, query, true);
  }
  hide('qfriends');
  hideQDrop(qCur);
   _proxy_jslib_handle(winBoxes, (name), '', 0, 0).show();
  return false;
}

function notaBene(el, color) {
  el = ge(el);
  el.focus();
  var oldBack = data(el, 'back');
  if(!oldBack) oldBack = data(el, 'back', getStyle(el, 'backgroundColor'));
  var colors = {'notice':'#FFFFE0', 'warning':'#FAEAEA'};
  setStyle(el, 'backgroundColor',  _proxy_jslib_handle(colors, (color), '', 0, 0) || color ||  _proxy_jslib_handle(colors, ('warning'), '', 0, 0));
   _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)(function() {
    animate(el, {backgroundColor: oldBack}, 300);
  }, 400);
}

function im_popup(peer_id) {
  if (window.event && (window.event.which == 2 || window.event.button == 1)) {
    return true;
  }

  var params = 'scrollbars=0,resizable=1,menubar=0,location=0,width=610,height=469,toolbar=0,status=0';
  if (!window.loc_host) {
    window.loc_host =  _proxy_jslib_handle( _proxy_jslib_handle(null, 'location', location, 0, 0), 'host', '', 0, 0);
  }
  var dom =  _proxy_jslib_handle(window.loc_host, 'toString', '', 1, 0)().match(/[a-zA-Z]*\.[a-zA-Z]*$/)[0];

   _proxy_jslib_assign('', document, 'domain', '=', ( dom));

  var url = 'http://' + (/^cs\d*/.test(window.loc_host) ? window.loc_host : dom) + '/im.php?act=a_box&popup=1';
  var js = 'window.im.activate_tab(0);';
  if (peer_id) {
    url += '&sel=' + peer_id;
    js = 'window.im.add_peers(' + peer_id + ', ' + peer_id + ')';
  }
    
  url = 'javascript: try { ' + js + ' } catch(e) { document.location = "' + url + '"; void(0); }';

  window.im_popup_window =  _proxy_jslib_handle(window, 'open', '', 1, 0)(url, 'im', params);

  try {
    if (!browser.chrome && !browser.msie && !browser.mozilla && !browser.safari && window.im_popup_window.im) {
      window.im_already_box = new (MessageBox)({title: (window.im_already_shown_title || 'Ìãíîâåííûå ñîîáùåíèÿ')});
       _proxy_jslib_handle(im_already_box, 'content', '', 1, 0)(window.im_already_shown || 'Îêíî Ìãíîâåííûõ ñîîáùåíèé óæå çàïóùåíî, Âàì äîñòàòî÷íî ïðîñòî ïåðåéòè íà íåãî.');
      im_already_box.addButton({label: getLang('box_close'), onClick: im_already_box.hide});
       _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)("im_already_box.hide(400)", 2000);
      im_already_box.show();
    }
  } catch (e) {}

  if (!browser.msie) {
    window.im_popup_window.blur();
  }
  window.im_popup_window.focus();

  try {
     _proxy_jslib_assign('', document, 'domain', '=', ( window.loc_host));
  } catch (e) {}

  return false;
}
 ;
_proxy_jslib_flush_write_buffers() ;