var ceh = ['cl_righthand','cl_cmdrate','r_fullbright','sv_cheats','gl_monolight','sv_chattime','mp_autokick','hud_centerid','thrideperson','restart','dem_forcehltv','sv_gravity','sv_stepsize','mp_freeztime','gl_texturemode','mp_timeleft','cheangelevel','voice_loopback','hud_saytext','+moveup','cam_command','chase_back','cl_bobup','cl_cmdrate','cl_dlmax','connect','direct','fakeloss','gl_zmax','hud_draw','net_log','s_reflect','spec_pip','wait'],winZIndex = winPosition = 0,stek = new Array(),error = {offline:'Отсутствует соединение с интернетом или сервер не отвечает',invalid:'Страница в разработке',getpage:'Выберите раздел'},callFnc = new Array(),baseTitle = 'CS~console :: коды для Counter-Strike 1.6, конфигурация контры, информация о модах, ботах, hltv, hlds.';
function updWinSize(){
  window.xCW = xClientWidth();
  window.xCH = xClientHeight();
}
function xClearSelect(){
  (document.selection && document.selection.empty) ? document.selection.empty() : window.getSelection().removeAllRanges();
}
function xClearEvt(evt){
  evt = evt || event;
  (evt.preventDefault) ? evt.preventDefault() : evt.returnValue = false;
}
function xGetEle(e){
  return(!typeof(e) == 'string') ? e : document.getElementById(e);
}
function getPath(s){
  return String(String(s).match(/(path=)\d+/g)).substring(5);
}
function xTop(e, y){
  if(typeof(y) == 'number')e.style.top = y + 'px';
  return e.offsetTop;
}
function xLeft(e, x){
  if(typeof(x) == 'number')e.style.left = x + 'px';
  return e.offsetLeft;
}
function xWidth(e, w){
  if(typeof(w) == 'number')e.style.width = (w > 0) ? w + 'px' : 0;
  return(typeof(e.style.width) == 'number') ? parseInt(e.style.width) : e.offsetWidth;
}
function xHeight(e, h){
  if(typeof(h) == 'number')e.style.height = (h > 0) ? h + 'px' : 0;
  return(typeof(e.style.height) == 'number') ? parseInt(e.style.height) : e.offsetHeight;
}
function onBlur(e){
  xClearEvt(e);
  xGetTarget(e).blur();
}
function createEle(ele, tag, className, body, fnc, useLink){
  if(tag == 'a' && navigator.userAgent.indexOf('MSIE 6') == -1)tag = (useLink) ? 'a' : 'div';
  var e = document.createElement(tag);
  if(typeof(className) == 'string')e.className = className;
  if(typeof(body) == 'string')e.innerHTML = body;
  if(tag == 'a'){
    e.href = (useLink) ? body : 'http://' + location.hostname + '/';
    xAddEvt(e, 'focus', onBlur);
    if(!useLink)xAddEvt(e, 'click', xClearEvt);
  }
  if(fnc)xAddEvt(e, 'click', fnc);
  ele.appendChild(e);
  return e;
}
function createRainbow(e, top){
  var r = createEle(e, 'div', (top) ? 'rtop' : 'rbottom');
  if(top)for(var i = 14; i >= 0; i--)createEle(r, 'div', 'r' + i);
  else for(var i = 0; i <= 14; i++)createEle(r, 'div', 'r' + i);
  return r;
}
function createArrow(e, type){
  var arr = createEle(e, 'div', (type == 'top' || type == 'bottom') ? 'arrow_vert' : 'arrow_hor')
  switch(type){
    case't':for(var i = 4; i >= 1; i--)createEle(arr, 'div', 'arr_v' + i);break;
    case'r':for(var i = 1; i <= 4; i++)createEle(arr, 'div', 'arr_h' + i);break;
    case'b':for(var i = 1; i <= 4; i++)createEle(arr, 'div', 'arr_v' + i);break;
    case'l':for(var i = 4; i >= 1; i--)createEle(arr, 'div', 'arr_h' + i);break;
  }
  return arr;
}
function xSendRequest(o, method, args, handler){
  o.request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
  var path = 'http://' + location.hostname;
  if(method == 'get' && args.length > 0)path += '?' + args;
  o.request.open(method, path, true);
  if(method == 'post')o.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  o.request.send((method == 'post') ? args : null);
  o.request.onreadystatechange = function(){
    if(o.request.readyState != 4)return;
    handler(o, o.request.status != 200);
  }
}
function xAlpha(){
  var num = arguments[arguments.length - 1];
  if(typeof(document.body.style.opacity) == 'string')for(var i = 0; i < arguments.length - 1; i++)arguments[i].style.opacity = num / 100;
  else for(var i = 0; i < arguments.length - 1; i++)arguments[i].style.filter = (num >= 100) ? null : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + num + ')';
}
function xClientWidth(){
  return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientWidth : document.body.clientWidth;
}
function xClientHeight(){
  return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientHeight : document.body.clientHeight;
}
function xAddEvt(e, eventType, eventListener){
  if(e.addEventListener)e.addEventListener(eventType, eventListener, false);
  else if(e.attachEvent)e.attachEvent('on' + eventType, eventListener);
}
function xDelEvt(e, eventType, eventListener){
  if(e.removeEventListener)e.removeEventListener(eventType, eventListener, false);
  else if(e.detachEvent)e.detachEvent('on' + eventType, eventListener);
}
function xGetTarget(evt){
  evt = evt || event;
  return evt.target || evt.srcElement;
}
function xEnableDrag(e, o, fncStart, fncDrag, fncEnd, fncX, fncY){
  e.fncStart = fncStart;
  e.fncDrag = fncDrag;
  e.fncEnd = fncEnd;
  e.fncX = fncX;
  e.fncY = fncY;
  e.o = o;
  xAddEvt(e, 'mousedown', onDragStart);
}
function onDragStart(evt){
  evt = evt || event;
  var e = xGetTarget(evt);
  if(e.fncX)e.deltaX = evt.clientX - e.fncX(e.o);
  if(e.fncY)e.deltaY = evt.clientY - e.fncY(e.o);
  xAddEvt(document, 'mousemove', onDragEvt);
  xAddEvt(document, 'mouseup', onDragEnd);
  window.eDrag = e;
  if(e.fncStart)e.fncStart(evt);
}
function onDragEvt(evt){
  evt = evt || event;
  if(eDrag.fncX)eDrag.fncX(eDrag.o, evt.clientX - eDrag.deltaX);
  if(eDrag.fncY)eDrag.fncY(eDrag.o, evt.clientY - eDrag.deltaY);
  if(eDrag.fncDrag)eDrag.fncDrag(evt);
}
function onDragEnd(evt){
  xDelEvt(document, 'mousemove', onDragEvt);
  xDelEvt(document, 'mouseup', onDragEnd);
  if(eDrag && eDrag.fncEnd)eDrag.fncEnd(evt);
  window.eDrag = null;
}
function createWin(id, path, e){
  var noscript = xGetEle('noscript');
  if(!xGetEle(id) || noscript){
    var o = createNewWin(id, path);
    if(noscript){
      o.oPath.innerHTML = '';
      for(var i = 0,n = '',chlds = xGetEle('wNavigation').childNodes; i < chlds.length; i++){
        if(!chlds[i].tagName)continue;
        var ele = createEle(o.oNavigation, 'a', chlds[i].className, chlds[i].innerHTML, goPage);
        if(chlds[i].className == 'button_active')o.intiBtn = ele;
        ele.path = n++;
      }
      if(o.intiBtn){
        o.type = 1;
        o.path = o.path.slice(0, -1) + o.intiBtn.path;
      } else o.type = 2;
      for(var i = 0,chlds = xGetEle('wPath').childNodes; i < chlds.length; i++){
        if(!chlds[i].tagName)continue;
        var tag = (chlds[i].className == 'path_active' || chlds[i].className == 'path_name_act') ? 'a' : chlds[i].tagName.toLowerCase(),ele = createEle(o.oPath, tag, chlds[i].className, chlds[i].innerHTML, goPath);
        if(chlds[i].tagName == 'A')ele.path = getPath(chlds[i].href);
        else ele.path = o.path;
      }
      o.oContent4.innerHTML = xGetEle('wText').innerHTML;
      updBtnUp(o);
      document.body.removeChild(xGetEle('noscript'));
    } else {
      o.oPath.innerHTML = '';
      var btn = createEle(o.oPath, 'div', 'path_download', 'Загрузка...');
      o.path = btn.path = getPath(e.href);
      o.intiBtn = btn;
      o.goPage = e.firstChild.nodeValue;
      xSendRequest(o, 'get', 'file=xml&path=' + o.path, getXML);
    }
  } else var o = xGetEle(id);
  if(winPosition + 100 + xHeight(o) >= xCH)winPosition = 0;
  changeWinType(o);
  onFocus(o);
  updScroller(o);
  getUserLink(o);
  var allScript = document.getElementsByTagName('SCRIPT');
  if(allScript.length > 1)callBack(null, getSRCName(allScript[allScript.length - 1].src));
}
function createNewWin(id, path){
  var o = createEle(document.body, 'div', 'window');
  o.window = true;
  o.id = id;
  o.type = 2;
  o.path = getPath(path || window.location);
  o.userPath = new Array(id.toLowerCase().split('/'));
  xAddEvt(o, 'mousedown', onFocus);
  o.bgTop = createRainbow(o, true);
  o.bgMiddle = createEle(o, 'div', 'win_bg');
  o.bgBottom = createRainbow(o);
  o.oHeader = createEle(o, 'div', 'header');
  o.oPath = createEle(o.oHeader, 'div', 'path');
  createEle(o.oPath, 'div', 'path_name');
  o.oClose = createEle(o.oHeader, 'a', 'button close', '&times;', onClose);
  var oContent1 = createEle(o, 'div', 'content1'),oContent2 = createEle(oContent1, 'div', 'content2');
  o.oContent3 = createEle(oContent2, 'div', 'content3_type2');
  o.topLine = createEle(o.oContent3, 'div', 'content3_top_type2');
  o.oContent4 = createEle(o.oContent3, 'div', 'content4_type2');
  xAddEvt(o.oContent4, 'mousewheel', onContentWheel);
  xAddEvt(o.oContent4, 'DOMMouseScroll', onContentWheel);
  o.oScrollbar = createEle(o.oContent3, 'div', 'scrollbar_type2');
  xAddEvt(o.oScrollbar, 'mousewheel', onContentWheel);
  xAddEvt(o.oScrollbar, 'DOMMouseScroll', onContentWheel);
  o.oScrollerTop = createEle(o.oScrollbar, 'a', 'scroller_top_type2');
  o.oScrollerTop.onmousedown = function(){
    onScrollTop(xGetWin(this).id, 500)
  }
  createArrow(o.oScrollerTop, 't');
  o.oScroller = createEle(o.oScrollbar, 'a', 'scroller');
  var oScrollSym = createEle(o.oScroller, 'div', 'scroll_sym');
  var oScrollSymTop = createArrow(oScrollSym, 't');
  createEle(oScrollSym, 'div', 'scroller_bg');
  var oScrollSymBotttom = createArrow(oScrollSym, 'b');
  o.oScrollerBottom = createEle(o.oScrollbar, 'a', 'scroller_bottom_type2');
  o.oScrollerBottom.onmousedown = function(){
    onScrollBottom(xGetWin(this).id, 500)
  }
  createArrow(o.oScrollerBottom, 'b');
  o.oLink = createEle(o, 'a', 'link', null, null, true);
  o.oResizeX = createEle(o, 'div', 'resize_x');
  o.oResizeY = createEle(o, 'div', 'resize_y');
  o.oResizeXY = createEle(o, 'div', 'resize_xy');
  xEnableDrag(o.oResizeXY, o, initDrag, onResizeXY, offDrag, xWidth, xHeight);
  xEnableDrag(o.oResizeY, o, initDrag, onResizeY, offDrag, null, xHeight);
  xEnableDrag(o.oResizeX, o, initDrag, onResizeX, offDrag, xWidth);
  xEnableDrag(o.oHeader, o, initDrag, onDrag, offDrag, xLeft, xTop);
  xEnableDrag(o.oScroller, o.oScroller, null, onScrollDrag, null, null, xTop);
  o.oNavigation = createEle(o, 'div', 'navigation');
  o.oExit = createEle(o, 'a', 'button button_back');
  o.style.left = (winPosition += 100) + 'px';
  o.style.top = winPosition + 'px';
  updBtnUp(o);
  o.style.display = 'block';
  offDrag(o);
  return o;
}
function getUserLink(o){
  var userLink = '';
  for(var i = 0; i < o.oPath.childNodes.length; i++){
    var nextPath = o.oPath.childNodes[i];
    if(nextPath.className == 'path_name_act' || nextPath.className == 'path_other')userLink += o.oPath.childNodes[i].firstChild.nodeValue.toLowerCase().replace(' ', '_') + '/';
  }
  if(o.intiBtn.className != 'button button_back')userLink += o.intiBtn.firstChild.nodeValue.toLowerCase().replace(' ', '_') + '/';
  return userLink;
}
function goPath(evt){
  var o = xGetWin(evt),e = xGetTarget(evt);
  if(e.className == 'path_active' || e.className == 'path_sym' || o.request)return;
  o.intiBtn = e;
  for(var chlds = o.oPath.childNodes,i = chlds.length - 1; i >= 0; i--){
    if(chlds[i].className == 'path_sym' || chlds[i].path != e.path)o.oPath.removeChild(chlds[i]);
    else {
      o.goPage = chlds[i].firstChild.nodeValue;
      o.path = chlds[i].path;
      o.oPath.removeChild(chlds[i]);
      createEle(o.oPath, 'a', 'path_download', 'Загрузка...');
      break;
    }
  }
  xSendRequest(o, 'get', 'file=xml&path=' + e.path, getXML);
}
function goPage(evt){
  var o = xGetWin(evt),e = xGetTarget(evt);
  if(e.className == 'button_active' || o.request)return;
  e.className += ' button_click';
  o.goPage = e.firstChild.nodeValue;
  o.intiBtn = e;
  o.path = (o.type == 1) ? o.path.slice(0, -1) + e.path : o.path + e.path;
  createEle(o.oPath, 'div', 'path_sym', '&nbsp;&gt;&nbsp;');
  createEle(o.oPath, 'a', 'path_download', 'Загрузка...');
  onResizeXY(o);
  xSendRequest(o, 'get', 'file=xml&path=' + o.path, getXML);
}
function updBtnUp(o){
  o.oExit.path = o.path.slice(0, -1);
  var type = o.oPath.firstChild.className == 'path_name_act';
  o.oExit.innerHTML = (type) ? 'вверх' : 'закрыть';
  xDelEvt(o.oExit, 'click', onClose);
  xDelEvt(o.oExit, 'click', goPath);
  xAddEvt(o.oExit, 'click', (type) ? goPath : onClose);
}
function createXML(o, data){
  o.xml = document.createDocumentFragment();
  var xmlWin = document.createElement('window');
  o.xml.appendChild(xmlWin);
  xmlWin.appendChild(document.createElement('navigation'));
  var xmlCont = document.createElement('content');
  xmlWin.appendChild(xmlCont);
  var xmlText = document.createTextNode(data);
  xmlCont.appendChild(xmlText);
  return o.xml.firstChild;
}
function getXML(o, err){
  o.xml = o.request.responseXML;
  if(err)var XMLWin = createXML(o, error.offline);
  else if(!o.xml)var XMLWin = createXML(o, error.invalid);
  else if(!o.xml.documentElement)var XMLWin = createXML(o, error.invalid);
  else if(o.xml.documentElement.tagName == 'parsererror')var XMLWin = createXML(o, error.invalid);
  else var XMLWin = o.xml.documentElement;
  document.title = o.tit = (XMLWin.getElementsByTagName('title')[0]) ? XMLWin.getElementsByTagName('title')[0].firstChild.nodeValue : baseTitle;
  o.oContent4.innerHTML = '';
  var e = XMLWin.childNodes;
  for(var i = 0; i < e.length; i++){
    if(!e[i].tagName)continue;
    var carentTagName = e[i].tagName.toLowerCase();
    if(carentTagName == 'navigation'){
      o.oNavigation.innerHTML = '';
      for(var n = 0,b = 0,navs = e[i].childNodes; n < navs.length; n++){
        if(navs[n].tagName != 'btn')continue;
        var ele = createEle(o.oNavigation, 'a', 'button', navs[n].firstChild.nodeValue, goPage);
        ele.path = b++;
      }
      o.type = 2;
      var nav = true;
    } else if(carentTagName == 'content' && e[i].firstChild)o.xsl = e[i].firstChild.nodeValue;
  }
  if(!nav){
    for(var i = 0,chlds = o.oNavigation.childNodes,l = chlds.length; i < l; i++){
      if(chlds[i].className != 'button_active')continue;
      chlds[i].className = 'button';
      break;
    }
    o.intiBtn.className = 'button_active';
    o.type = 1;
  }
  changeWinType(o);
  if(o.oPath.childNodes.length != 1){
    var prevPath = o.oPath.lastChild.previousSibling.previousSibling;
    prevPath.className = (prevPath.className == 'path_name_act' || prevPath.className == 'path_name') ? 'path_name_act' : 'path_other';
    xDelEvt(prevPath, 'click', goPath);
    xAddEvt(prevPath, 'click', goPath);
  }
  updBtnUp(o);
  onResizeXY(o);
  updScroller(o);
  if(err)return getXSL(o, err);
  for(var i = 0,jsLink = document.documentElement.getElementsByTagName('SCRIPT'); i < jsLink.length; i++)if(jsLink[i].tagName == 'SCRIPT' && getSRCName(jsLink[i].src) == XMLWin.getAttribute('js') + '.js')var useJS = true;
  for(var i = 0,cssLink = document.documentElement.getElementsByTagName('LINK'); i < cssLink.length; i++)if(cssLink[i].tagName == 'LINK' && getSRCName(cssLink[i].href) == XMLWin.getAttribute('css') + '.css')var useCSS = true;
  for(var i = 0,htmlChilds = document.documentElement.childNodes; i < htmlChilds.length; i++){
    if(htmlChilds[i].tagName != 'HEAD')continue;
    var head = htmlChilds[i];
    break;
  }
  if(XMLWin.getAttribute('css') && !useCSS){
    var css = document.createElement('link');
    css.href = 'http://css.cs-console.ru/' + XMLWin.getAttribute('css') + '.css';
    css.media = 'screen';
    css.rel = 'stylesheet';
    css.type = 'text/css';
    head.appendChild(css);
  }
  if(XMLWin.getAttribute('js') && !useJS){
    var js = document.createElement('script');
    js.type = 'text/javascript';
    js.src = 'http://js.cs-console.ru/' + XMLWin.getAttribute('js') + '.js';
    head.appendChild(js);
  }
  o.js = XMLWin.getAttribute('js');
  if(o.type == 1)xSendRequest(o, 'get', 'file=xsl&name=' + (XMLWin.getAttribute('xsl') || 'default'), getXSL);
  else {
    o.request = null;
    getXSL(o, false);
  }
}
function getXSL(o, err){
  if(err)var xhtml = error.offline;
  else if(!o.request)var xhtml = o.xsl;
  else {
    o.xsl = o.request.responseXML;
    if(window.ActiveXObject){
      try{
        var xhtml = o.xml.transformNode(o.xsl);
      }
      catch(e){
        var xhtml = error.invalid;
      }
    } else {
      var proc = new XSLTProcessor(),ser = new XMLSerializer();
      try{
        proc.importStylesheet(o.xsl);
        var xhtml = ser.serializeToString(proc.transformToFragment(o.xml, document));
      } catch(e){
        var xhtml = error.invalid;
      }
    }
  }
  if(o.type == 1){
    o.oPath.removeChild(o.oPath.lastChild);
    o.oPath.removeChild(o.oPath.lastChild);
  } else {
    o.oPath.lastChild.className = (o.oPath.childNodes.length != 1) ? 'path_active' : 'path_name';
    o.oPath.lastChild.innerHTML = o.goPage;
    o.oPath.lastChild.path = o.path;
  }
  o.oContent4.innerHTML = (!xhtml && o.type == 2) ? error.getpage : xhtml;
  updScroller(o);
  o.oLink.innerHTML = o.oLink.href = 'http://' + location.hostname + '/' + getUserLink(o);
  callBack(null, o.js);
  o.js = o.request = o.xml = o.xsl = null;
}
function callBack(fnc, js){
  if(fnc)window.fnc = fnc;
  if(js){
    if(window.callFnc[js])return window.callFnc[js]();
    window.js = js;
  }
  if(window.fnc && window.js){
    window.fnc();
    window.callFnc[window.js] = window.fnc;
    window.fnc = null;
    window.js = null;
  }
}
function getSRCName(src){
  return src.substring(src.lastIndexOf('/') + 1);
}
function changeWinType(o){
  o.topLine.className = 'content3_top_type' + o.type;
  o.oContent3.className = 'content3_type' + o.type;
  o.oContent4.className = 'content4_type' + o.type;
  o.oScrollbar.className = 'scrollbar_type' + o.type;
  o.oScrollerTop.className = 'scroller_top_type' + o.type;
  o.oScrollerBottom.className = 'scroller_bottom_type' + o.type;
}
function onClose(evt){
  var o = xGetWin(evt);
  for(var i = 0; i < stek.length; i++)if(stek[i] == o.id)stek.splice(i, 1);
  document.body.removeChild(o);
  o = xGetEle(stek[stek.length - 1]);
  if(stek.length)intWinAlpha(o, 40);
  document.title = (o && o.tit) ? o.tit : baseTitle;
}
function onResizeX(o){
  var o = (o.id) ? o : xGetWin(eDrag),minW = xWidth(o.oPath) + 100;
  minW = (minW > 500) ? minW : 500;
  if(xWidth(o) + xLeft(o) > xCW)o.style.width = xCW - xLeft(o) + 'px';
  if(xWidth(o) <= minW)o.style.width = minW + 'px';
  updScroller(o);
}
function onResizeY(o){
  var o = (o.id) ? o : xGetWin(eDrag),minH = xHeight(o.oNavigation) + 23;
  minH = (minH > 250) ? minH : 250;
  if(xHeight(o) + xTop(o) + xHeight(o.bgBottom) > xCH)o.style.height = xCH - xTop(o) - xHeight(o.bgBottom) + 'px';
  if(xHeight(o) <= minH)o.style.height = minH + 'px';
  updScroller(o);
}
function onResizeXY(o){
  onResizeX(o);
  onResizeY(o);
}
function onDrag(){
  var o = xGetWin(eDrag);
  if(xLeft(o) + xWidth(o) > xCW)o.style.left = xCW - xWidth(o) + 'px';
  if(xLeft(o) < 0)o.style.left = '0px';
  if(xTop(o) + xHeight(o) + xHeight(o.bgBottom) > xCH)o.style.top = xCH - xHeight(o) - xHeight(o.bgBottom) + 'px';
  if(xTop(o) - xHeight(o.bgTop) - 2 < 0)o.style.top = xHeight(o.bgTop) + 2 + 'px';
}
function initDrag(){
  //var o=xGetWin(eDrag);
  //o.oContent4.style.display=o.oScrollbar.style.display='none';
}
function offDrag(e){
  var o = xGetWin(window.eDrag || e);
  //o.oContent4.style.display=o.oScrollbar.style.display='block';
  o.style.top = xTop(o) * 100 / xCH + '%';
  o.style.left = xLeft(o) * 100 / xCW + '%';
  updScroller(o);
}
function onFocus(e){
  var o = xGetWin(e);
  o.style.zIndex = ++winZIndex;
  xGetEle('menu').style.zIndex = ++winZIndex;
  for(var i = 0; i < stek.length; i++)if(o.id == stek[i])stek.splice(i, 1);
  stek.push(o.id);
  if(stek.length - 2 >= 0)intWinAlpha(xGetEle(stek[stek.length - 2]), 20);
  intWinAlpha(o, 40);
  if(o.tit)document.title = o.tit;
}
function intWinAlpha(o, n){
  xAlpha(o.bgTop, o.bgMiddle, o.bgBottom, n);
  xAlpha(o.oPath, (n == 40) ? 100 : 50);
  xAlpha(o.oClose, (n == 40) ? 100 : 20);
  o.oContent3.style.visibility = o.oNavigation.style.visibility = o.oExit.style.visibility = (n == 40) ? 'visible' : 'hidden';
}
function onScrollBottom(id, time){
  var o = xGetEle(id);
  o.oContent4.style.top = xTop(o.oContent4) - 20 + 'px';
  o.onTimer = setTimeout(function(){
    onScrollBottom(id, 50)
  }, time);
  xAddEvt(document, 'mouseup', function(){
    stopScroll(o)
  });
  updScroller(o);
}
function onScrollTop(id, time){
  var o = xGetEle(id);
  o.oContent4.style.top = xTop(o.oContent4) + 20 + 'px';
  o.onTimer = setTimeout(function(){
    onScrollTop(id, 50)
  }, time);
  xAddEvt(document, 'mouseup', function(){
    stopScroll(o)
  });
  updScroller(o);
}
function updScroller(o){
  if(xHeight(o.oContent4) - xHeight(o.oContent3) > 0){
    o.oScrollbar.style.display = 'block';
    o.oScrollbar.style.height = xHeight(o.oContent3) - 24 + 'px';
    if(xTop(o.oContent4) + xHeight(o.oContent4) < xHeight(o.oContent3))o.oContent4.style.top = xHeight(o.oContent3) - xHeight(o.oContent4) + 'px';
    else if(xTop(o.oContent4) > 0)o.oContent4.style.top = '0px';
    o.oScroller.style.height = xHeight(o.oContent3) * xHeight(o.oScrollbar) / xHeight(o.oContent4) + 'px';
    o.oScroller.style.top = Math.ceil(-xTop(o.oContent4) * xHeight(o.oScrollbar) / xHeight(o.oContent4)) + 'px';
  } else {
    o.oScrollbar.style.display = 'none';
    if(xTop(o.oContent4) != 0)o.oContent4.style.top = '0px';
  }
}
function stopScroll(o){
  if(o.onTimer)clearTimeout(o.onTimer);
}
function xGetWin(e){
  e = (e.tagName) ? e : xGetTarget(e);
  while(!e.window){
    e = e.parentNode;
  }
  return e;
}
function onScrollDrag(){
  var o = xGetWin(eDrag);
  o.oContent4.style.top = -xTop(o.oScroller) * xHeight(o.oContent4) / xHeight(o.oScrollbar) + 'px';
  updScroller(o);
}
function onContentWheel(evt){
  evt = evt || event;
  var o = xGetWin(evt);
  o.oContent4.style.top = xTop(o.oContent4) + ((typeof(evt.wheelDelta) != 'undefined') ? evt.wheelDelta / 120 : -evt.detail / 3) * 20 + 'px';
  updScroller(o);
}
function createBG(className, cheatsNum){
  var e = xGetEle('cheats'),o = xGetEle(className);
  if(!o){
    o = createEle(e, 'div');
    o.id = className;
  }
  for(var i = 0; i < ceh.length * cheatsNum; i++){
    var cheat = createEle(o, 'div', null, ceh[parseInt(Math.random() * ceh.length)]);
    cheat.style.left = parseInt(Math.random() * 100) + '%';
    cheat.style.top = parseInt(Math.random() * 100) + '%';
  }
}
function initWin(evt){
  xClearEvt(evt);
  var e = xGetTarget(evt);
  createWin(e.firstChild.nodeValue, e.href, e);
}
function onLoad(){
  createBG('cheat_small', 3);
  createBG('cheats_norm', 2);
  createBG('cheats_big', 0.5);
  xGetEle('menu').style.zIndex = ++winZIndex;
  for(var i = 0,n = 0,chlds = xGetEle('menu_body').childNodes; i < chlds.length; i++){
    if(!chlds[i].tagName)continue;
    chlds[i].path = n;
    xAddEvt(chlds[i], 'click', initWin);
    xAddEvt(chlds[i], 'focus', onBlur);
    n++;
  }
  var noscript = xGetEle('noscript');
  if(!noscript)return;
  for(var i = 0; i < noscript.childNodes.length; i++){
    if(!noscript.childNodes[i].id)continue;
    createWin(noscript.childNodes[i].id);
    break;
  }
}
updWinSize();
xAddEvt(document, 'mousedown', xClearEvt);
xAddEvt(document, 'mousemove', xClearEvt);
xAddEvt(document, 'dblclick', xClearSelect);
xAddEvt(document, 'click', xClearSelect);
xAddEvt(document, 'keyup', xClearSelect);
xAddEvt(window, 'resize', updWinSize);
xAddEvt(window, 'load', onLoad);