/*******************************************************************************
"rjxLib" Библиотека функций JavaScript
(c) Oleg Danilkin, 2007-2008
*******************************************************************************/

//Информация о версии библиотеки
rjxLib = {version:"1.0",date:"14.08.2007",copyright:"Oleg Danilkin"};


/*******************************************************************************
                     Вспомогательный функции rjxMain.jsm
*******************************************************************************/

//Определено ли свойства/переменные
function rjxDef() {
  for(var i = 0; i < arguments.length; i++)
    if (typeof(arguments[i]) == "undefined") return false;
  return true;
}

//Числовое значение
function rjxNum() {
  for(var i = 0; i < arguments.length; i++)
    if(isNaN(arguments[i]) || typeof(arguments[i]) != "number") return false;
  return true;
}

//Строковое значение
function rjxStr() {
  for(var i = 0; i < arguments.length; i++)
    if(typeof(arguments[i]) != "string") return false;
  return true;
}

//Предварительная загрузка изображений
function rjxImgPreload (p) {
  var ims = [], i;
  for (i = 1; i < arguments.length; i++) {
    ims[i-1] = new Image();
    ims[i-1].src = p + arguments[i];
  }
}

//Удаление дочерних элементов
function rjxClearChilds (e) {
  if (!(e = rjxE(e))) return;
  while (e.lastChild)
    e.removeChild(e.lastChild);
}

//Удаление дочерних элементов
function rjxRemoveChild (e) {
  e.parentNode.removeChild(e);
}


String.prototype.toHtmlEntities = function () {
  return this.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;").
         replace(/—/g,"&mdash;").replace(/–/g,"-").replace(/«/g,"&laquo;").replace(/»/g,"&raquo;").
         replace(/§/g,"&sect;").replace(/©|(\(c\))|(\(C\))|(\(с\))|(\(С\))/g,"&copy;").replace(/±/g,"&plusmn;").
         replace(/¤/g,"&curren;").replace(/®/g,"&reg;").replace(/¶/g,"&para;").replace(/·/g,"&middot;");
}

String.prototype.fromHtmlEntities = function () {
  return this.replace(/&amp;/g,"&").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quot;/g,"\"").
         replace(/&mdash;/g,"—").replace(/-/g,"–").replace(/&laquo;/g,"«").replace(/&raquo;/g,"»").
         replace(/&sect;/g,"§").replace(/&copy;/g,"©").replace(/&plusmn;/g,"±").
         replace(/&curren;/g,"¤").replace(/&reg;/g,"®").replace(/&para;/g,"¶").replace(/&middot;/g,"·");
}

/*******************************************************************************
              Функции работы с элементами страницы rjxDom.jsm
*******************************************************************************/

//getElementById
function rjxE (e) {
  if (typeof(e) == "string") e = document.getElementById(e);
  return e;
}

//getElementsByTagName tagname, parent
function rjxET (t,p) {
  var p = p ? rjxE(p) : document;
  if (p.getElementsByTagName) return p.getElementsByTagName(t);
  return null;
}

//createElement tagname, attributes, parent
function rjxCE (t,a,p) {
  var e = document.createElement(t);
  if (a)
    for (var i in a)
      e[i] = a[i];
  if (p) rjxE(p).appendChild(e);
  return e;
}

//createTextNode text, parent
function rjxCT (t,p) {
  var e = document.createTextNode(t);
  if (p) rjxE(p).appendChild(e);
  return e;
}

//Создание img
function rjxCIMG (s, a, t, w, h, p, at) {
  var im = rjxCE("img", {src: s, alt: a, title: t, width: w, height: h}, p);
  if (at)
    for (var i in at)
      im[i] = at[i];
  return im;
}


function rjxCI (s, w, h, a, t, p, at) {
  var im = rjxCE("img", {src: s, alt: a, title: t, width: w, height: h}, p);
  if (at)
    for (var i in at)
      im[i] = at[i];
  return im;
}
















/*******************************************************************************
             Функции определения/установки размеров и положения
                       элементов страницы rjxPosition.jsm
*******************************************************************************/

//getComputedStyle defaul view   element, property, inInteger
function rjxGetComputedStyle(e, pr, bInt) {
  var dv = document.defaultView || window, s, p;
  if(dv && dv.getComputedStyle) {
    s = dv.getComputedStyle(e, "");
    if (s) p = s.getPropertyValue(pr);
  }
  else
    if (e.currentStyle) {
      var i, a = pr.split("-");
      pr = a[0];
      for (i = 1; i < a.length; i++) 
        pr += a[i].charAt(0).toUpperCase() + a[i].substr(1);
      p = e.currentStyle[pr];
    }
    else return null;
  return bInt ? (parseInt(p) || 0) : p;
}

//Верхняя координата
function rjxTop(e, v) {
  if(!(e = rjxE(e))) return 0;
  var s = e.style;
  if(rjxDef(v)) {
    if (s) s.top = v + "px";
    else if (rjxDef(s.pixelTop)) s.pixelTop = v;
  }
  else {
    if (rjxDef(e.offsetTop)) v = e.offsetTop;
    else 
      if (s) {
        v = parseInt(s.top);
        if (isNaN(v)) v = rjxGetComputedStyle(e,"top",1);
      }
      else
        if (rjxDef(s.pixelTop)) v = s.pixelTop;
  }
  return v;
}

//Левая координата
function rjxLeft(e, v) {
  if(!(e = rjxE(e))) return 0;
  var s = e.style;
  if(rjxDef(v)) {
    if (s) s.left = v + "px";
    else if (rjxDef(s.pixelLeft)) s.pixelLeft = v;
  }
  else {
    if (rjxDef(e.offsetLeft)) v = e.offsetLeft;
    else 
      if (s) {
        v = parseInt(s.left);
        if (isNaN(v)) v = rjxGetComputedStyle(e,"left",1);
      }
      else
        if (rjxDef(s.pixelLeft)) v = s.pixelLeft;
  }
  return v;
}

//Ширина
function rjxWidth(e, v) {
  if(!(e = rjxE(e))) return 0;
  var s = e.style;
  if(rjxDef(v)) {
    if (s) s.width = v + "px";
    else if (rjxDef(s.pixelWidth)) s.pixelWidth = v;
  }
  else {
    if (rjxDef(e.offsetWidth)) v = e.offsetWidth;
    else 
      if (s) {
        v = parseInt(s.width);
        if (isNaN(v)) v = rjxGetComputedStyle(e,"width",1);
      }
      else
        if (rjxDef(s.pixelWidth)) v = s.pixelWidth;
  }
  return v;
}

//Высота
function rjxHeight(e, v) {
  if(!(e = rjxE(e))) return 0;
  var s = e.style;
  if(rjxDef(v)) {
    if (s) s.height = v + "px";
    else if (rjxDef(s.pixelHeight)) s.pixelHeight = v;
  }
  else {
    if (rjxDef(e.offsetHeight)) v = e.offsetHeight;
    else 
      if (s) {
        v = parseInt(s.height);
        if (isNaN(v)) v = rjxGetComputedStyle(e,"height",1);
      }
      else
        if (rjxDef(s.pixelHeight)) v = s.pixelHeight;
  }
  return v;
}

//Слой
function rjxZIndex(e, v) {
  if(!(e = rjxE(e))) return 0;
  var s = e.style;
  if(rjxDef(v)) {
    if (s) s.zIndex = v;
  }
  else {
    if (rjxDef(s.zIndex)) v = parseInt(s.zIndex);
    if (isNaN(v)) v = rjxGetComputedStyle(e,"z-index",1);
  }
  return v;
}

//Прокрутка горизонтальная
function rjxScrollLeft(e, v) {
  var w = e ? rjxE(e) : window;
  if (!rjxNum(w.scrollTop) && rjxDef(w.document)) e = rjxDef(w.document.documentElement) ? w.document.documentElement : w.document.body;
  else e = w;
  if (rjxDef(v)) {
    if (rjxNum(e.scrollLeft)) e.scrollLeft = v;
    else  if (rjxNum(w.pageXOffset)) w.pageXOffset = v;
  }
  else {
    if (rjxNum(e.scrollLeft)) v = e.scrollLeft;
    if (rjxNum(w.pageXOffset)) v = w.pageXOffset;
    if (!v) v = 0;
  }
  return v;
}

//Прокрутка вертикальная
function rjxScrollTop(e, v) {
  var w = e ? rjxE(e) : window;
  if (!rjxNum(w.scrollTop) && rjxDef(w.document)) e = rjxDef(w.document.documentElement) ? w.document.documentElement : w.document.body;
  else e = w;
  if (rjxDef(v)) {
    if (rjxNum(e.scrollTop)) e.scrollTop = v;
    else if (rjxNum(w.pageYOffset)) w.pageYOffset = v;
  }
  else {
    if (rjxNum(e.scrollTop)) v = e.scrollTop;
    if (rjxNum(w.pageYOffset)) v = w.pageYOffset;
    if (!v) v = 0;
  }
  return v;
}

//Ширина клиентской области
function rjxClientWidth(w) {
  var d = w ? w.document : document;
  if (d.documentElement && w && !w.opera) return d.documentElement.clientWidth;
  if (d.body && d.body.clientWidth) return d.body.clientWidth;
  return 0;
}

//Высота клиентской области
function rjxClientHeight(w) {
  var d = w ? w.document : document;
  if (d.documentElement && w && !w.opera) return d.documentElement.clientHeight;
  if (d.body && d.body.clientHeight) return d.body.clientHeight;
  return 0;
}

/*******************************************************************************
             Функции определения/установки стилей отображения
                       элементов страницы rjxStyle.jsm
*******************************************************************************/

//Прозрачность 0-1
function rjxOpacity(e, v) {
  if(!(e=rjxE(e)) || !e.style) return 1;
  var s = e.style, f = rjxDef(v);
  if (rjxStr(s.opacity)) {
    if (f) s.opacity = v + "";
    else v = parseFloat(s.opacity);
  }
  else
    if (rjxStr(s.filter)) {
      if (f) s.filter = "alpha(opacity=" + (100 * v) + ")";
      else
        if (e.filters && e.filters.alpha)
          v = e.filters.alpha.opacity / 100;
    }
    else
      if (rjxStr(s.MozOpacity)) {
        if (f) s.MozOpacity = v + "";
        else v = parseFloat(s.MozOpacity);
      }
  return isNaN(v) ? 1 : v;
}

//Display
function rjxDisplay(e, v) {
  if ((e=rjxE(e)) && (s = e.style)) {
    if (rjxStr(v)) {
      try {s.display = v;}
      catch (ex) {s.display = '';}
    }
    else {
      v = s.display;
      if (!v) v = rjxGetComputedStyle(e, "display");
    }
    return v;
  }
  return null;
}

//Visibility
function rjxVisibility(e, v) {
  if ((e=rjxE(e)) && (s = e.style)) {
    if (rjxStr(v)) {
      try {s.visibility = v;}
      catch (ex) {s.visibility = '';}
    }
    else {
      v = s.visibility;
      if (!v) v = rjxGetComputedStyle(e, "visibility");
    }
    return v;
  }
  return null;
}

//Display  !v - none, v = true - block, v = "true" - inline
function rjxShow (e, v) {
  if (rjxDef(v))
    if (v === "true") rjxDisplay(e, "inline");
    else  rjxDisplay(e, v ? "block" : "none");
  return (rjxDisplay(e) != "none");
}

//Visible|hidden
function rjxVisible (e, v) {
  if (rjxDef(v)) rjxVisibility(e, v ? "visible" : "hidden");
  return (rjxVisibility(e) == "visible");
}

//Высота ширина скрытого элемента (display = none)
function rjxDimensions(e) {
  var r = {width: 0, height: 0, left: 0, top: 0};
  if(!(e = rjxE(e))) return r;
  var ov = rjxVisibility(e),
      od = rjxDisplay(e);
  if (!rjxShow(e)) {
    rjxVisible(e,false);
    rjxDisplay(e, "");
  }
  r.width = rjxWidth(e);
  r.height = rjxHeight(e);
  r.left = rjxLeft(e);
  r.top = rjxTop(e);
  rjxDisplay(e, od);
  rjxVisibility(e, ov);
  return r;
}

//Ставим объект e как второй e1 по координатам
function rjxCopyPos (e, e1) {
  var dm = rjxDimensions(e1);
  rjxLeft(e, dm.left);
  rjxTop(e, dm.top);
  rjxWidth(e, dm.width);
  rjxHeight(e, dm.height);
}

/*******************************************************************************
               Объект асинхронной передачи данных rjxAResp.jsm
*******************************************************************************/

//Экранирование символов s - escape, r - for russian unicode 
function rjxEscape (t, s) {
  var r = String(escape(t));
  if (s == "s") return r;
  var uf = 0, sf = 0, rr = "", c1, c2, l = r.length - 1;
  for (var i = 0; i <= l; i++) {
    c1 = r.charAt(i);
    c2 = r.charAt(i + 1);
    if (c1 == "%") {
      if (c2 != "u") {
        if (uf) rr += "e";
        if (!uf && !sf) rr += "(";
      }
      else {
        if (sf) rr += "u";
        if (!sf && !uf) rr += "(u";
      }
      sf = (c2 != "u");
      uf = !sf;
    } else
    if (sf || uf) {
      rr += ")";
      sf = 0;
      uf = 0;
    }
    if (sf) {
      rr += r.substr(i + 1, 2);
      i += 2;
    } else
    if (uf) {
      c2 = r.substr(i + 2, 2);
      if (s == "r" && c2 == "04") rr += "r";
      else rr += c2;
      rr += r.substr(i + 4, 2);
      i += 5;
    } else rr += c1;
  }
  if (sf || uf) rr += ")";
  return rr;
}
  
//Обратное экранирование символов s - escape, r - for russian unicode 
function rjxUnescape (t, s) {
  var r = String(unescape(t));
  if (s == "s") return r;
  var uf = 0, sf = 0, rr = "", c1, l = r.length - 1;
  for (var i = 0; i <= l; i++) {
    c1 = r.charAt(i);
    c2 = r.charAt(i + 1);
    if (c1 == "(" && c2 != "u" || uf && c1 == "e") {
      sf = 1;
      uf = 0;
      continue;
    }
    if (c1 == "(" && c2 == "u" || sf && c1 == "u")  {
      if (c1 == "(") i++;
      sf = 0;
      uf = 1;
      continue;
    }
    if (c1 == ")") {
      sf = 0;
      uf = 0;
      continue;
    }
    if (sf) {
      rr += "%" + r.substr(i, 2);
      i++;
    } else
    if (uf) {
      if (s == "r" && c1 == "r") rr += "%u04" + r.substr(i + 1, 2);
      else {
        rr += "%u" + r.substr(i, 4);
        i++;
      }
      i += 2;
    } else rr += c1;
  }
  return unescape(rr);
}

//функция аналогичная ELEMNT.getElementsByTagName(TAGNAME)[0].firstChild.nodeValue, передается элемент и имя тага
function rjxNV (e, t) {
  var ee = e.getElementsByTagName(t);
  if (ee.length < 1) return "";
  if (ee[0] && ee[0].firstChild && ee[0].firstChild.nodeValue) return ee[0].firstChild.nodeValue;
  else return "";
}

/*******************************************************************************
           Функция построения дерева DOM из полученных в XML данных
  Первый параметр - XML документ, второй - блок, в который добавляем,
  третий - id tagа htmldom в XML, который добавляем, последний параметр -
  ассоциативный массив замены шаблонов %%TPL_NAME
*******************************************************************************/

function rjxCreateXML2DOM (xmlel, insel, xmlidstr, tplar) {
  var props = new Array();
  props["class"] = "className";
//Функция рекурсивного обхода
    function recurse_consolidate (frm, too, tplar) {
      var chld = frm.childNodes, i, k, wstr, nnm, nnode, l, ind;
      for (i = 0; i < chld.length; i++) {
        if (chld[i].nodeType == 1) {
          nnode = rjxCE(chld[i].nodeName);
          l = chld[i].attributes.length;
          for (k = 0; k < l; k++) {
            wstr = String(chld[i].attributes[k].nodeValue);
            nnm = String(chld[i].attributes[k].nodeName);
            if (wstr.substr(0,2) == "%%") {
              ind = wstr.substr(2);
              if (rjxDef(tplar[ind]))
                wstr = tplar[ind];
            }
            if (rjxDef(props[nnm.toLowerCase()]))
              nnode[props[nnm.toLowerCase()]] = wstr;
          	else
              nnode[nnm] = wstr;
          }
          recurse_consolidate (chld[i], nnode, tplar);
        }
        if (chld[i].nodeType == 3) {
          ind = chld[i].nodeValue.substr(2);
          if (!rjxDef(tplar[ind]))
            nnode = rjxCT(chld[i].nodeValue);
          else
            nnode = rjxCT(tplar[ind]);
        }
        too.appendChild(nnode);
      }
    }
//Выделяем объекты
  var elx = xmlel.getElementsByTagName("htmldom"), i, k, l, elnx = null;
  for (i = 0; i < elx.length; i++) {
    l = elx[i].attributes.length;
    for (k = 0; k < l; k++)
      if ((elx[i].attributes[k].nodeName == "id") &&
          (elx[i].attributes[k].nodeValue == xmlidstr)) {
        elnx = elx[i];
        break;
      }
  }
  recurse_consolidate (elnx, insel, tplar);
}


/*******************************************************************************
                                 Объект rjxAResp
                            Обертка для XMLHttpRequest
*******************************************************************************/

rjxAResp = function (url, onload, method, onerror) {
  this.url = url;
  this.onload = (onload) ? onload : this.defaultLoad;
  this.onerror = (onerror) ? onerror : this.defaultError;
  this.method = (method) ? method : "POST";
  this.prms = [];
  this.req = null;
  this.xmlDocEl = null;
  this.respText = null;
  this.createRequestObj();
}

rjxAResp.prototype.createRequestObj = function () {
  try { this.req = new XMLHttpRequest(); }
  catch (tmt) {
    try { this.req = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (om) {
      try { this.req = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (fld) {
        return null;
      };
    }
  }
}

rjxAResp.prototype.defaultError = function () {
  alert("rjsAsyncResponse error (Ошибка обращения к серверу)");
  return;
}

rjxAResp.prototype.defaultLoad = function () {
  alert("Result response: "+this.respText);
}

rjxAResp.prototype.addParams = function (prms) {
  for (var i in prms) {
    if ((parseFloat(prms[i]) != prms[i]) && (parseInt(prms[i]) != prms[i]))
      this.prms[i] = String(prms[i]).toHtmlEntities();
    else this.prms[i] = prms[i];
  }
}

rjxAResp.prototype.overrideMimeType = function (mt) {
  this.req.overrideMimeType(mt);
}

rjxAResp.prototype.setHeader = function (hn, hd) {
  this.req.setRequestHeader(hn, hd);
}

rjxAResp.prototype.onReadyState = function () {
  var rq = this.req;
  if (rq.readyState == 4)   {
    if (rq.status == 200 || rq.status == 0) {
      if (this.req.responseXML)
        this.xmlDocEl = rq.responseXML.documentElement;
      if (rq.responseText);
        this.respText = rq.responseText;  
      this.onload.call(this);
    }  
    else
      this.onerror.call(this);
  }
}

rjxAResp.prototype.sendRequest = function () {
  if (this.req)
    try {
      var rq = this.req;
      var loader = this;
      rq.onreadystatechange = function () {
        loader.onReadyState.call(loader);
      }
      rq.open(this.method, this.url, true);
      rq.setRequestHeader ("Content-Type","application/x-www-form-urlencoded");
      rq.setRequestHeader ("X-Requested-With","rjxLib"+rjxLib.version);
      rq.setRequestHeader ("Accept","text/javascript, text/html, application/xml, text/xml, */*");
      var p = "";
      for (var i in this.prms)
        p += "&"+i+"="+String(this.prms[i]).replace(/&/g,"%26");
      p = p.substr(1);
      rq.send(p);
    }
    catch (err) {
      this.onerror.call(this);
    }
}

/*******************************************************************************
               Функции расширения объекта Date rjxDateExt.jsm
*******************************************************************************/

//Массивы
rjx_csWSDays = ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"];
rjx_csWDays = ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"];
rjx_csSMonths = ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"];
rjx_csMonths = ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"];
rjx_csMonthsy = ["Января", "Февраля", "Марта", "Апреля", "Мая", "Июня", "Июля", "Августа", "Сентября", "Октября", "Ноября", "Декабря"];
rjx_csAmPm = ["рп", "пп"];
rjx_csMDays = [31,28,31,30,31,30,31,31,30,31,30,31];

//Дней в месяце
Date.prototype.monthDays = function (y, m) {
  var d = this;
  if (!y) y = d.getFullYear();
  if (!m && (m !== 0)) m = d.getMonth();
  var r = rjx_csMDays[m];
  if ((m == 1) && ((y % 4) == 0)) r++;
  return r;
}

//Дату в строку по шаблону
Date.prototype.fstr = function (f) {
  function _z(v) {
    return v > 9 ? v : "0" + v;
  }
  var r = f ? f : "%d.%A.%Y %h:%M:%S",
      t = this,
      d = [t.getFullYear(), t.getMonth(), t.getDate(), t.getDay(), t.getHours(), t.getMinutes(), t.getSeconds(), t.getTimezoneOffset()];
  r = r.replace("%Y", d[0]).replace("%y", _z(d[0] % 100)).replace("%A", _z(d[1] + 1)).replace("%a", d[1] + 1);
  r = r.replace("%B", rjx_csMonths[d[1]]).replace("%b", rjx_csSMonths[d[1]]).replace("%C", rjx_csMonthsy[d[1]]);
  r = r.replace("%D", _z(d[2])).replace("%d", d[2]).replace("%W", rjx_csWDays[d[3]]).replace("%w", rjx_csWSDays[d[3]]);
  r = r.replace("%c", d[3]).replace("%H", _z(d[4])).replace("%h", d[4]).replace("%K", _z(d[4] < 13 ? d[4] : d[4] % 12));
  r = r.replace("%k", d[4] < 13 ? d[4] : d[4] % 12).replace("%p", rjx_csAmPm[d[4] < 12 ? 0 : 1]).replace("%M", _z(d[5]));
  r = r.replace("%m", d[5]).replace("%S", _z(d[6])).replace("%s", d[6]).replace("%T", (d[7] < 0 ? "+" : "-") + _z(Math.abs(Math.round(d[7] / 60))) + ":" + _z(Math.abs(d[7] % 60)));
  return r;
}

/*******************************************************************************
               Функции обработки событий rjxEventExt.jsm
*******************************************************************************/

function rjxAddListener (e, t, f) {
  if (!(e = rjxE(e))) return;
  if (!e.lsns) e.lsns = [];
  if (!e.lsns[t]) e.lsns[t] = [];
  var lsn = e.lsns[t], m = "on" + t;
  if (rjxDef(e[m]) && lsn.length < 1) lsn.push(e[m]);
  lsn.push(f);
  e[m] = function (ev) {
    var e = ev || window.event,
        l = this.lsns[e.type],
        r = 0;
    for (var i = l.length - 1; i >= 0; i--) {
      if (l[i]) r = l[i].call(this,e);
    }
    return r;
  }
}

/*******************************************************************************
                   Функции работы с cookie rjxCookie.jsm
*******************************************************************************/

function rjxCookie(n, v) {
  var c = document.cookie.split("; "),
      i, p, d = new Date();
  if (rjxDef(v)) {
    d.setYear(d.getFullYear() + 1);
    document.cookie = n + "=" + escape(v) + "; path=/; expires="+d.toString();
  }
  else {
    for (i = 0; i < c.length; i++) {
      p = c[i].split("=");
      if (p[0] == n) {
        v = unescape(p[1]);
        break;
      }
    }
  }
  return v;
}

/*******************************************************************************
                  Объект - всплывающая подсказка rjxShowHint.jsm

Используемые стили:
  #rjxHintMC - основной контейнер
  #rjxHintFC - фрэйм-подложка
  #rjxHintDT - контейнер для текста

#rjxHintMC {
  background-color: transparent;
  width: 0;
  height: 0;
}

#rjxHintFC {
  position: absolute;
  z-index: 4000;
}

#rjxHintDT {
  position: absolute;
  overflow: hidden;
  z-index: 4001;
  background-color: #F3F3CC;
  padding: 0 2px;
  border: 1px #CCCC00 solid;
  font-size: 8pt;
}

*******************************************************************************/

//Конструктор
/*
sh - задержка перед выпадением
tm - время задержки перед выпадением и скрытием
w - ширина фиксированная, иначе автоматически
*/
function rjxHint (sh, tm, w) {
  if (!window.rjxHintObj) window.rjxHintObj = this;
  else return window.rjxHintObj;
  this.sh = sh ? true : false;
  this.tm = tm ? tm : 600;
  this.w = w ? w : false;
  this.init();
}

//Создаем элементы страницы
rjxHint.prototype.init = function () {
  var th = this, mc = rjxCE("div", {id: "rjxHintMC"}, rjxET("body")[0]),
      fc = rjxCE("div", {}, mc);
  fc.innerHTML = "<iframe id=\"rjxHintFC\" scrolling=\"no\" frameborder=\"0\"></iframe>";
  th.tc = rjxCE("div", {id: "rjxHintDT"}, mc); //Контейнер для текста
  rjxShow(mc, false);
  th.mc = mc; //Основной контейнер
  th.fc = rjxET("iframe", mc)[0]; //фрэйм-подложка
}

//Присваиваем элементу hint, при отсутствии используем title (для img)
rjxHint.prototype.set = function (e, ht) {
  var e = rjxE(e);
  if (ht) e.hint = ht;
  else if (e.title) {
    e.hint = e.title;
    e.title = "";
  }
  rjxAddListener (e, "mouseover", this.onover);
  rjxAddListener (e, "mouseout", this.onout);
}

//Наведение мыши
rjxHint.prototype.onover = function (ev) {
  var th = window.rjxHintObj, e = ev || window.event, l,
      w = th.w ? th.w : rjxClientWidth() / 3;
  if (!this.hint) return false;
  clearTimeout(th.to);
  th.tc.innerHTML = this.hint;
  rjxShow(th.fc, false);
  rjxShow(th.mc, true);
  rjxVisible(th.tc, false);
  rjxTop(th.tc, e.clientY + rjxScrollTop() + 3);
  rjxWidth(th.tc, w);
//left
  l = rjxClientWidth() - e.clientX;
  if (l + 5 < w) l = rjxClientWidth() - w - 10;
  else l = e.clientX + 3;
  rjxLeft(th.tc, l);
  if (th.sh) th.to = setTimeout("window.rjxHintObj.show()", th.tm);
  else th.show();
}

rjxHint.prototype.onout = function () {
  var th = window.rjxHintObj;
  clearTimeout(th.to);
  th.to = setTimeout("window.rjxHintObj.hide()", th.tm);
}

rjxHint.prototype.show = function () {
  var th = window.rjxHintObj;
  rjxShow(th.fc, true);
  rjxCopyPos (th.fc, th.tc);
  rjxVisible(th.tc, true);
  rjxShow(th.mc, true);
}

rjxHint.prototype.hide = function () {
  rjxShow(window.rjxHintObj.mc, false);
}

/*******************************************************************************
                           Объект - окно rjxWindow.jsm

z-index 1000 etd

Используемые стили:
  #rjxHintMC - основной контейнер

*******************************************************************************/

//Конструктор
/*
e - путь к странице или объект DIV, который будет в окне
ct - текст заголовка
mv - возможность перетаскивания за заголовок и изменения размеров
l, t, w, h - левая граница, верхняя, высота и ширина окна
p - .p -путь src, .w,.h - ширина высота
im - имя файла иконки
cb - кнопка закрытия окна
mb - кнопка минимизации
fb - максимизация
*/
function rjxWindow (e, ct, mv, p, l, t, w, h, im, cb, mb, fb) {
  var th = this;
  if (!window.rjxWnds) window.rjxWnds = [];
  window.rjxWnds.push(th);
  th.n = window.rjxWnds.length - 1;
  if (typeof(e) == "string") 
    th.ce = rjxCE("iframe", {id: "rjxWndFrm"+th.n, scrolling: "yes", frameborder: "0", src: e});
  else
    th.ce = e;
  th.ct = ct;
  th.mv = rjxDef(mv) && mv;
  th.l = l ? l : 10 + th.n * 5;
  th.t = t ? t : 10 + th.n * 5;
  th.w = w ? w : 350;
  th.h = h ? h : 250;
  th.im = im ? im : false;
  th.imp = p ? p : {p: "", w: 0, h: 0};
  th.cb = rjxDef(cb) && cb;
  th.mb = rjxDef(mb) && mb;
  th.fb = rjxDef(fb) && fb;
  th.init();
}

rjxWindow.prototype.init = function () {
//Create DOM model
  var th = this, mc = rjxCE("div", {id: "rjxWnd"+th.n, className: "rjxwndmain"}, rjxET("body")[0]),
      fc = rjxCE("div", {}, rjxET("body")[0]),
      cd = rjxCE("div", {className: "rjxwndcontent"}),
      cc = rjxCE("div", {className: "rjxwndcaption" + (th.mv ? " move" : "")}, mc), im;
  th.cc = cc;    
  fc.innerHTML = "<iframe class=\"rjxhideframe\" scrolling=\"no\" frameborder=\"0\"></iframe>";
  th.fc = rjxET("iframe", fc)[0]; //фрэйм-подложка
  rjxZIndex(mc, 1000+th.n*3);
  rjxZIndex(fc, 999+th.n*3);
  th.mc = mc;//Основной контейнер
  if (th.im) rjxCIMG (th.imp.p+th.im, "ico", "", th.imp.w, th.imp.h, cc, {className: "left"});
  if (th.cb) {
    im = rjxCIMG (th.imp.p+"cls.gif", "Закрыть", "Закрыть", th.imp.w, th.imp.h, cc, {className: "right"});
  }
  if (th.fb) {
    im = rjxCIMG (th.imp.p+"max.gif", "Во весь экран", "Во весь экран", th.imp.w, th.imp.h, cc, {className: "right"});
  }
  if (th.mb) {
    im = rjxCIMG (th.imp.p+"min.gif", "Свернуть", "Свернуть", th.imp.w, th.imp.h, cc, {className: "right"});
  }
  rjxCT(th.ct, cc);



  rjxTop(mc, th.t);
  rjxLeft(mc, th.l);
  rjxWidth(mc, th.w);
  rjxHeight(mc, th.h);
  rjxCopyPos(th.fc, mc);
  
/*  
  cd.appendChild(th.ce);
  mc.appendChild(cd);
  if (th.mv) {
    im = rjxCIMG (th.imp.p+"sz.gif", "Изменить размер", "Изменить размер", th.imp.w, th.imp.h, mc, {className: "sz"});
    th.sz = im;
  }
  
 
  rjxShow(fc, false);
  rjxLeft(mc, th.l);
  rjxTop(mc, th.t);
  rjxWidth(mc, th.w + 40);
  rjxWidth(th.ce, th.w);
  rjxHeight(th.ce, th.h);

this.setpos();
*/
//  mc.appendChild(th.ce);
//  th.cc = //Заголовок
  
//Create DOM
}

rjxWindow.prototype.setpos = function () {
  var th = this;
  rjxWidth(th.ce, rjxWidth(th.cc));
  rjxHeight(th.ce, th.h - rjxHeight(th.cc));
  if (th.sz) {
    rjxLeft(th.sz, th.w - th.imp.w - 4);
    rjxTop(th.sz, th.h - th.imp.h);
  }
  
}


/*
//Создаем элементы страницы
rjxHint.prototype.init = function () {
  var th = this, mc = rjxCE("div", {id: "rjxHintMC"}, rjxET("body")[0]),
      fc = rjxCE("div", {}, mc);
  fc.innerHTML = "<iframe id=\"rjxHintFC\" scrolling=\"no\" frameborder=\"0\"></iframe>";
  th.tc = rjxCE("div", {id: "rjxHintDT"}, mc); //Контейнер для текста
  rjxShow(mc, false);
  th.mc = mc; //Основной контейнер
  th.fc = rjxET("iframe")[0]; //фрэйм-подложка
}

//Присваиваем элементу hint, при отсутствии используем title (для img)
rjxHint.prototype.set = function (e, ht) {
  var e = rjxE(e);
  if (ht) e.hint = ht;
  else if (e.title) e.hint = e.title;
  rjxAddListener (e, "mouseover", this.onover);
  rjxAddListener (e, "mouseout", this.onout);
}

//Наведение мыши
rjxHint.prototype.onover = function (ev) {
  var th = window.rjxHintObj, e = ev || window.event, l,
      w = th.w ? th.w : rjxClientWidth() / 3;
  if (!this.hint) return false;
  clearTimeout(th.to);
  th.tc.innerHTML = this.hint;
  rjxShow(th.fc, false);
  rjxShow(th.mc, true);
  rjxVisible(th.tc, false);
  rjxTop(th.tc, e.clientY + rjxScrollTop() + 3);
  rjxWidth(th.tc, w);
//left
  l = rjxClientWidth() - e.clientX;
  if (l + 5 < w) l = rjxClientWidth() - w - 10;
  else l = e.clientX + 3;
  rjxLeft(th.tc, l);
  if (th.sh) th.to = setTimeout("window.rjxHintObj.show()", th.tm);
  else th.show();
}

rjxHint.prototype.onout = function () {
  var th = window.rjxHintObj;
  clearTimeout(th.to);
  th.to = setTimeout("window.rjxHintObj.hide()", th.tm);
}

rjxHint.prototype.show = function () {
  var th = window.rjxHintObj;
  rjxShow(th.fc, true);
  rjxCopyPos (th.fc, th.tc);
  rjxVisible(th.tc, true);
  rjxShow(th.mc, true);
}

rjxHint.prototype.hide = function () {
  rjxShow(window.rjxHintObj.mc, false);
}
*/




















/*******************************************************************************
                   Объект - календарь rjxCalendar.jsm
*******************************************************************************/

var rjx_csToday = "Сегодня",
    rjx_csPrevYear = "Предыдущий год",
    rjx_csNextYear = "Следующий год",
    rjx_csPrevMonth = "Предыдущий месяц",
    rjx_csNextMonth = "Следующий месяц",
    rjx_csMHolidays = ["1,2,3,4,5", "23", "8", "", "1,9", "12", "", "", "", "", "4", ""];

function rjxCalendar(p,pth,fd,cd,ct,st,at,fok,fch) {
//Неделя начинается с...
  this.glsFirstWDay = fd;
//Префикс
  this.p = p;
//Проверка на неповторение префикса  
  if (rjxE(p+"RClndr")) return false;
//Путь к файлам
  this.pth = pth ? pth : "";
//Элементы управления
  this.gsCD = cd ? cd : true;
  this.gsCT = ct ? ct : false;
  this.gsST = st ? st : false;
  this.gsAT = at ? at : false;
//Текущая дата/время
  this.curDate = new Date();
//Функции обратного вызова
  this.onOK = fok;
  this.onCH = fch;
//Главный контейнер календаря
  this.mainDiv = this.createDom();
}

//Создаем контейнер календаря
rjxCalendar.prototype.createDom = function () {
  var th = this, p = th.p, s, i, k;
  //Создание img
  function CI (s,t,p) {
    return rjxCE("img", {"src" : th.pth + s, "width" : "16", "height" : "16", "alt" : "", "title" : t}, p);
  }
  //Основной контейнер
  var m_c = rjxCE("div", {"id" : p + "RClndr","className" : p + "mcont"});
  //Контейнер управления
  var tr = rjxCE("tr", null,
             rjxCE("tbody", null,
               rjxCE("table", null,
                 rjxCE("div", {"className" : p + "ccont"},
                   m_c))));
  CI("ar_py.gif", rjx_csPrevYear, rjxCE("td", {"className" : p + "tdbut", "p" : th, "onmouseover" : th.onTdBtnActive, "onmouseout" : th.onTdBtnDActive, "onclick" : th.onClickPrevYear}, tr));
  CI("ar_pm.gif", rjx_csPrevMonth, rjxCE("td", {"className" : p + "tdbut", "p" : th, "onmouseover" : th.onTdBtnActive, "onmouseout" : th.onTdBtnDActive, "onclick" : th.onClickPrevMonth}, tr));
  var td = rjxCE("td", null, tr);
  rjxCE("span", null, td);
  rjxCT(" ",td);
  rjxCE("span", null, td);
  CI("ar_nm.gif", rjx_csNextMonth, rjxCE("td", {"className" : p + "tdbut", "p" : th, "onmouseover" : th.onTdBtnActive, "onmouseout" : th.onTdBtnDActive, "onclick" : th.onClickNextMonth}, tr));
  CI("ar_ny.gif", rjx_csNextYear, rjxCE("td", {"className" : p + "tdbut", "p" : th, "onmouseover" : th.onTdBtnActive, "onmouseout" : th.onTdBtnDActive, "onclick" : th.onClickNextYear}, tr));
  //Контейнер сетки календаря
  var tb = rjxCE("tbody", null,
             rjxCE("table", null,
               rjxCE("div", {"className" : p + "bcont"},
                 m_c)));
  tr = rjxCE("tr", null, tb);
  s = th.glsFirstWDay;
  for (i = 0; i < 7; i++) {
    rjxCT(rjx_csWSDays[s].toUpperCase(), td = rjxCE("td", {"className" : p + "wday"}, tr));
    if (s == 0 || s == 6) td.className += " " + p + "hday";
    s = ++s % 7;
  }
  tb.appendChild(tr);
  for (i = 0; i < 6; i++) {
    tr = rjxCE("tr",null, tb);
    for (k = 0; k < 7; k++)
      rjxCE("td", {"p" : th, "onclick" : th.onClickDay},tr);
  }
  //Контейнер время/сегодня/ОК
  tr = rjxCE("tr", null,
         rjxCE("tbody", null,
           rjxCE("table", null,
             rjxCE("div", {"className" : p + "tcont"},
               m_c))));
  var sp = [];
  sp[0] = rjxCE("span", {"className" : p + "spbut", "p" : th, "onclick" : th.onClickHours}, td = rjxCE("td", null, tr));
  rjxCT(":", td);
  sp[1] = rjxCE("span", {"className" : p + "spbut", "p" : th, "onclick" : th.onClickMinutes}, td);
  rjxCT(":", td);
  sp[2] = rjxCE("span", {"className" : p + "spbut", "p" : th, "onclick" : th.onClickSeconds}, td);
  CI("today.gif", rjx_csToday, rjxCE("td", {"className" : p + "tdbut", "p" : th, "onmouseover" : th.onTdBtnActive, "onmouseout" : th.onTdBtnDActive, "onclick" : th.onClickToday}, tr));
  CI("applay.gif", "OK", rjxCE("td", {"className" : p + "tdbut", "p" : th, "onmouseover" : th.onTdBtnActive, "onmouseout" : th.onTdBtnDActive, "onclick" : th.onClickOK}, tr));
  //Устанавливаем видимость
  var ts = rjxET("table",m_c);
  td = rjxET("td",ts[0]);
  if (!th.gsCD) {
    rjxDisplay(td[0],"none");
    rjxDisplay(td[1],"none");
    rjxDisplay(td[3],"none");
    rjxDisplay(td[4],"none");
  }
  td = rjxET("td",ts[2]);
  if (!th.gsST) rjxDisplay(td[0],"none");
  if (!th.gsCD) rjxDisplay(td[1],"none");
  if (!th.onOK) rjxDisplay(td[2],"none");
  if (th.gsCT)
    for (i = 0; i < 3; i++) {
      sp[i].onmouseover = th.onSpBtnActive;
      sp[i].onmouseout = th.onSpBtnDActive;
    }
  return m_c;
}

//Выводим календарь на месяц
rjxCalendar.prototype.fillMonth = function () {
  var th = this, p = th.p, d = th.curDate, tbs = rjxET("table", th.mainDiv);
  var sp = rjxET("span", tbs[0]);
  sp[0].innerHTML = d.fstr("%B");
  sp[1].innerHTML = d.fstr("%Y");
  var td = rjxET("td", tbs[1]), 
      cd = d.getDate(),
      fd = (d.getDay() - cd + 36 - th.glsFirstWDay) % 7,
      md = d.monthDays(),
      hd = ","+rjx_csMHolidays[d.getMonth()]+",",
      cc = 1,
      i;
  for (i = 7; i < 49; i++) {
  //Очищаем ячейку
    td[i].className = p + "eday";
    td[i].innerHTML = "";
  //Если ячейка заполненная
    if ((i - fd > 6) && (cc <= md)) {
      td[i].className = p + "day";
      if (((i + th.glsFirstWDay - 1) % 7 > 4) || (hd.indexOf(","+cc+",") > -1))
        td[i].className += " " + p + "hday";
    //Today
      if (cc == cd) td[i].className += " " + p + "cday";
      td[i].innerHTML = cc;
      cc++;
    }
  }
  var sp = rjxET("span", tbs[2]);
  sp[0].innerHTML = d.fstr("%h");
  sp[1].innerHTML = d.fstr("%M");
  sp[2].innerHTML = d.fstr("%S");
  if (th.onCH) th.onCH.call(th);
}

//Обновление времени
rjxCalendar.prototype.updateTime = function (o,ot) {
  var d = new Date();
  o.curDate = d;
  var tbs = rjxET("table", o.mainDiv),
      sp = rjxET("span", tbs[2]);
  sp[0].innerHTML = d.fstr("%h");
  sp[1].innerHTML = d.fstr("%M");
  sp[2].innerHTML = d.fstr("%S");
  if (o.gsAT && !o.gsCT && !o.gsCD) 
    setTimeout(ot+".updateTime("+ot+",'"+ot+"')",1000);
}

//Изменение дня/месяца/года
rjxCalendar.prototype.incDate = function (n,m,y,h,i,s)
{
  var th = this, d = th.curDate, t = d.getDate(), ny = d.getFullYear() + y;
  d.setDate(1);
  if (ny < 1901) ny = 2100;
  if (ny > 2100) ny = 1901;
  d.setYear(ny);
  d.setMonth(d.getMonth() + m);
  d.setHours(d.getHours() + h);
  d.setMinutes(d.getMinutes() + i);
  d.setSeconds(d.getSeconds() + s);
  d.setDate(t+n);
  th.fillMonth();
}

rjxCalendar.prototype.show = function (l,t,w,h,s) {
//Фоновый iframe
  var th = this, pr = th.mainDiv.parentNode, fc,
      c = rjxCE("div", {"className" : th.p + "pcont"}, rjxET("body")[0]), f;
      l = l ? l : 0;
      t = t ? t : 0;
      w = w ? w : 250;
      h = h ? h : 200;
  if (!(f = rjxE(th.p + "backf"))) {
    fc = rjxCE("div", null, rjxET("body")[0]),
    fc.innerHTML = "<iframe id=\"" + this.p + "backf\" scrolling=\"no\" frameborder=\"0\"></iframe>";
    f = rjxE(th.p + "backf");
  }
  rjxLeft(c,l); rjxLeft(f,l);
  rjxTop(c,t); rjxTop(f,t);
  rjxWidth(c,w);
  rjxHeight(c,h);
  th.fillMonth();
  c.appendChild(th.mainDiv);
  rjxWidth(f,rjxWidth(th.mainDiv));
  rjxHeight(f,rjxHeight(th.mainDiv));
  rjxVisible(c, true);
  rjxVisible(fc.lastChild, true);
  if (pr && !s)
    pr.parentNode.removeChild(pr);
}

rjxCalendar.prototype.insert = function (p,s) {
  if (!(p = rjxE(p))) return;
  var th = this, pr = th.mainDiv.parentNode; 
  p.appendChild(th.mainDiv);
  if (pr && !s)
    pr.parentNode.removeChild(pr);
}

rjxCalendar.prototype.hide = function () {
  var p = this.p, c = this.mainDiv, pr = c.parentNode, f = rjxE(p + "backf");
  if (pr.className == p + "pcont") c = pr;
  rjxShow(c, false);
  if (f) f.parentNode.parentNode.removeChild(f.parentNode);
}

//События
rjxCalendar.prototype.onTdBtnActive = function () {this.className = this.p.p + "tdabut";}
rjxCalendar.prototype.onTdBtnDActive = function () {this.className = this.p.p + "tdbut";}
rjxCalendar.prototype.onSpBtnActive = function () {this.className = this.p.p + "spabut";}
rjxCalendar.prototype.onSpBtnDActive = function () {this.className = this.p.p + "spbut";}
rjxCalendar.prototype.onClickPrevYear = function () {this.p.incDate(0,0,-1,0,0,0);}
rjxCalendar.prototype.onClickPrevMonth = function () {this.p.incDate(0,-1,0,0,0,0);}
rjxCalendar.prototype.onClickNextMonth = function () {this.p.incDate(0,1,0,0,0,0);}
rjxCalendar.prototype.onClickNextYear = function () {this.p.incDate(0,0,1,0,0,0);}
rjxCalendar.prototype.onClickHours = function (ev) {
  var th = this, e = ev || window.event, i = 1;
  if (e.ctrlKey) i = -1;
  th.p.incDate(0,0,0,i,0,0);
}
rjxCalendar.prototype.onClickMinutes = function (ev) {
  var th = this, e = ev || window.event, i = 1;
  if (e.ctrlKey) i = -1;
  th.p.incDate(0,0,0,0,i,0);
}
rjxCalendar.prototype.onClickSeconds = function (ev) {
  var th = this, e = ev || window.event, i = 1;
  if (e.ctrlKey) i = -1;
  th.p.incDate(0,0,0,0,0,i);
}
rjxCalendar.prototype.onClickToday = function () {this.p.curDate = new Date(); this.p.fillMonth();}
rjxCalendar.prototype.onClickOK = function () {if (this.p.onOK) this.p.onOK.call(this.p);}
rjxCalendar.prototype.onClickDay = function () {
  var th = this, o = th.p, d = th.innerHTML;
  if (d > 0) {
    o.curDate.setDate(d);
    o.fillMonth();
  }
}

/*******************************************************************************
                  Объект - выбор даты / времени rjxDateSel.jsm
*******************************************************************************/

function rjxDTControl (p, c, pth, fd, d, t) {
  this.p = p;
  if (rjxDef(pth)) this.cln = new rjxCalendar(c, pth, fd, d, t, t, false, this.onCloseCalendar);
  else this.cln = c;
  this.cln.cdt = this;
  this.els = [rjxE(p + "Img"), rjxE(p + "Day"), rjxE(p + "Month"), rjxE(p + "Year"),
              rjxE(p + "Hours"), rjxE(p + "Minutes"), rjxE(p + "Seconds")];
  this.elc = t ? 7 : 4;
  this.create();
}

rjxDTControl.prototype.create = function () {
  var th = this, el = th.els, cn = th.elc, nd = new Date(), j,
      nw = [nd.getDate(), nd.getMonth() + 1, nd.getFullYear(), nd.getHours(), nd.getMinutes(),nd.getSeconds()];
//Clear
  for (j = 1; j < cn; j++) el[j].innerHTML = "";
//Fill
  for (j = 1; j < 32; j++) rjxCT(j, rjxCE("option", {value: j}, el[1]));
  for (j = 0; j < 12; j++) rjxCT(rjx_csMonthsy[j].toLowerCase(), rjxCE("option", {value: j+1}, el[2]));
  for (j = 2005; j < 2021; j++) rjxCT(j, rjxCE("option", {value: j}, el[3]));
  if (cn > 4) {
    for (j = 1; j < 24; j++) rjxCT(j, rjxCE("option", {value: j}, el[4]));
    for (j = 1; j < 60; j++) {
      rjxCT(j, rjxCE("option", {value: j}, el[5]));
      rjxCT(j, rjxCE("option", {value: j}, el[6]));
    }
  }
//Set
  for (j = 1; j < cn; j++) {
    el[j].value = nw[j-1];
    el[j].cdt = th;
  }
  el[0].cdt = th;
//Count days    
  this.onMonthDays();
//Events  
  rjxAddListener (el[0], "click", this.onClickCalendar);
  rjxAddListener (el[2], "change", this.onMonthDays);
  rjxAddListener (el[3], "change", this.onMonthDays);
}

rjxDTControl.prototype.onMonthDays = function () {
  var th = this, el = th.els ? th.els : th.cdt.els, nd = new Date(), i,
      ds = nd.monthDays(el[3].value, el[2].value - 1) + 1, cd = el[1].value;
  el[1].innerHTML = "";
  for (i = 1; i < ds; i++) rjxCT(i, rjxCE("option", {value: i}, el[1]));
  if (cd >= ds) cd = ds - 1;
  el[1].value = cd;
}

rjxDTControl.prototype.onClickCalendar = function (ev) {
  var th = this.cdt, el = th.els, cn = th.elc, cl = th.cln, cd = cl.curDate,
      e = ev || window.event;
  cd.setDate(el[1].value); cd.setMonth(el[2].value - 1); cd.setFullYear(el[3].value);
  if (cn > 4) {
    cd.setHours(el[4].value); cd.setMinutes(el[5].value); cd.setSeconds(el[6].value);
  }
  cl.fillMonth();
  cl.show(e.clientX,e.clientY, 200, 250);
}

rjxDTControl.prototype.onCloseCalendar = function () {
  var th = this.cdt, el = th.els, cn = th.elc, nd = this.curDate, i,
      nw = [nd.getDate(), nd.getMonth() + 1, nd.getFullYear(), nd.getHours(), nd.getMinutes(),nd.getSeconds()];
  for (i = 1; i < cn; i++)
    el[i].value = nw[i - 1];
  th.onMonthDays();
  this.hide();
}
























/*******************************************************************************
            Объект проверки введенных данных в форму rjxFormChecker.jsm

e - form
cc - изменение цвета фона класс .rjxfrmchk0 ...  .rjxfrmchk5
sh - всплывающая подсказка
p - путь к изображениям frmChk0.gif ... frmChk5.gif, если нет, изображения
    не используются
*******************************************************************************/

function rjxFormChecker (e, p) {
  this.fe = rjxE(e);
  this.pth = p;
}

rjxFormChecker.prototype.reset = function () {
  var inp = rjxET("input", this.fe), i,
      sel = rjxET("select", this.fe);
  for (i = 0; i < inp.length; i++)
    if (rjxDef(inp[i].rjxFC)) this.onEvent.call(inp[i]);
  for (i = 0; i < sel.length; i++)
    if (rjxDef(sel[i].rjxFC)) this.onEvent.call(sel[i]);
}

rjxFormChecker.prototype.check = function () {
  var inp = rjxET("input", this.fe), i,
      sel = rjxET("select", this.fe);
  for (i = 0; i < inp.length; i++)
    if (inp[i].rjxFCI && inp[i].rjxFCI.src.indexOf("frmChk0.gif") > -1) return false;
  for (i = 0; i < sel.length; i++)
    if (sel[i].rjxFCI && sel[i].rjxFCI.src.indexOf("frmChk0.gif") > -1) return false;
  return true;
}

rjxFormChecker.prototype.set = function (e, r, ev) {
  if (!(e = rjxE(e))) return;
  if (!ev)
    switch (e.tagName.toLowerCase()) {
      case "textarea" : ;
      case "input" : {ev = ["keyup", "blur", "mouseup"]; break;}
      default : ev = "change";
    }
  if (rjxStr(ev)) ev = [ev];
  e.rjxFCI = rjxET("img", e.parentNode)[0];
  if (e.rjxFCI && (e.rjxFCI.src.indexOf("frmChk0.gif") < 0)) return;
  e.rjxFC = this;
  e.rjxFCR = r;
  if (ev.length == 1) e["on" + ev] = this.onEvent;
  else
    for (var i = 0; i < ev.length; i++)
      e["on" + ev[i]] = this.onEvent;
}

rjxFormChecker.prototype.autoSet = function () {
  var inp = rjxET("input", this.fe), i, n,
      sel = rjxET("select", this.fe);
  for (i = 0; i < inp.length; i++) {
    n = inp[i].name.toLowerCase();
    if (n.indexOf("login") > -1)
      this.set(inp[i], "login");
    if (n.indexOf("password") > -1)
      this.set(inp[i], "pass");
    if (n.indexOf("mail") > -1)
      this.set(inp[i], "mail");
    if (n.indexOf("phone") > -1)
      this.set(inp[i], "phone");
  }
  for (i = 0; i < sel.length; i++) {
    if (sel[i].value == "")
      this.set(sel[i], "select_int");
  }
}

rjxFormChecker.prototype.setOK = function (e) {
  var i = e.rjxFCI;
  if (!i) return;
  i.src = this.pth + "frmChk5.gif";
  i.alt = "OK";
  i.title = "OK";
}

rjxFormChecker.prototype.setER = function (e) {
  var i = e.rjxFCI;
  if (!i) return;
  i.src = this.pth + "frmChk0.gif";
  i.alt = "Несоответствие";
  i.title = "Введенные данные не соответствуют установленному формату";
}

rjxFormChecker.prototype.setCM = function (e, p, t) {
  var i = e.rjxFCI;
  if (!i) return;
  i.src = this.pth + "frmChk" + p + ".gif";
  i.alt = t;
  i.title = t;
}

rjxFormChecker.prototype.onEvent = function () {
  var p, c, r = this.rjxFCR,
      th = this.rjxFC,
      v = this.value,
      ind = this.rjxFCI;
  if (typeof(r) != "string") {
    if (r.test(v)) th.setOK(this);
    else th.setER(this);
    return;
  }
  if (r.charAt(0) == "_") {
    if (v == "") th.setOK(this);
    else r = r.substr(1);
  }
  switch (r) {
    case "login" : {
      p = /^\w{4,}$/;
      if (p.test(v)) th.setOK(this);
      else th.setER(this);
      break;
    }
    case "pass" : {
      c = 0;
      p = /[a-z]/;
      if (p.test(v)) c++;
      p = /[A-Z]/;
      if (p.test(v)) c++;
      p = /\d/;
      if (p.test(v)) c++;
      p = /[-*+=,\.]/;
      if (p.test(this.value)) c++;
      if (v.length > 5) c++;
      p = /[^\w-*+=,\.]/;
      if (v.length < 4 || p.test(v)) c = 0;
      switch (c) {
        case 0: {th.setER(this); break;}
        case 1: {th.setCM(this, 1, "Безопасность пароля 20%"); break;}
        case 2: {th.setCM(this, 2, "Безопасность пароля 40%"); break;}
        case 3: {th.setCM(this, 3, "Безопасность пароля 60%"); break;}
        case 4: {th.setCM(this, 4, "Безопасность пароля 80%"); break;}
        case 5: th.setCM(this, 5, "Безопасный пароль");
      }
      break;
    }
    case "mail" : {
      p = /^[\w\._-]+@[\w\._-]+\.\w+$/;
      if (p.test(v)) th.setOK(this);
      else th.setCM(this, 0, "Неверный формат адреса электронной почты");
      break;
    }
    case "phone" : {
      p = /^\+\d \(\d{2,}\) [\d-]{6,}$/;
      if (p.test(v)) th.setOK(this);
      else th.setCM(this, 0, "Неверный формат телефонного номера");
      break;
    }
    case "text" : {
      if (v.length > 0) th.setOK(this);
      else th.setCM(this, 0, "Необходимо заполнить поле");
      break;
    }
    case "int" : {
      p = /^-?\d+$/;
      if (p.test(v)) th.setOK(this);
      else th.setCM(this, 0, "Неверный числовой формат");
      break;
    }
    case "real" : {
      p = /^-?\d+(\.\d+)?$/;
      if (p.test(v)) th.setOK(this);
      else th.setCM(this, 0, "Неверный числовой формат");
      break;
    }
    case "select_int" : {
      p = /^-?\d+$/;
      if (p.test(v)) th.setOK(this);
      else th.setCM(this, 0, "Необходимо выбрать одно из значений");
      break;
    }
    case "select_text" : {
      if (v.length > 0) th.setOK(this);
      else th.setCM(this, 0, "Необходимо выбрать одно из значений");
      break;
    }
  }
}
















/*
  Анимациия
*/

function rjxAnim (e, tt, cf, t, r, oe, ap, to) {
  var a = rjxAnim.inst, i, th = this;
  th.init(e, tt, cf, t, r, oe, to);
  for (i = 0; i < a.length; i++)
    if (!a[i]) break;
  a[i] = th;
  th.n = i;
  if (ap) th.start();
}

rjxAnim.inst = []; //Instances objects

rjxAnim.run = function (n) {
  var th = rjxAnim.inst[n], d = new Date(), p;
  th.t1 = d.getTime() - th.t0;
  p = th.t1 / th.tt;
  if (p > 1) p =1;
  if (th.t == 2) p = Math.sin(p*1.570796);
  else
    if (th.t == 3) p = p*p;
  th.cf.call(th, th.e, p < 1 ? p : 1);
  if (th.t1 < th.tt)
    th.tm = setTimeout("rjxAnim.run(" + th.n + ")", th.to);
  else {
    th.r--;
    if (th.r != 0) th.start(true);
    else th.stop();
  }
}

rjxAnim.prototype.init = function (e, tt, cf, t, r, oe, to) {
  var th = this;
  th.e = rjxE(e);
  th.t = t || 1;
  th.r = r || 1;
  th.tt = tt ? tt * 1000 : 1000;
  th.to = to || 30;
  th.cf = cf;
  th.oe = oe;
}

rjxAnim.prototype.start = function (p) {
  var th = this, d = new Date();
  if (!p && th.e.anim) return;
  th.e.anim = true;
  th.t0 = d.getTime();
  th.t1 = th.t0;
  th.tm = setTimeout("rjxAnim.run(" + th.n + ")", 1);
}

rjxAnim.prototype.pause = function () {
  var th = this;
  if (th.tm) {
    clearTimeout(th.tm);
    th.tm = null;
  }
}

rjxAnim.prototype.resume = function () {
  var th = this, d = new Date();
  th.t0 = d.getTime() - th.t1;
  th.tm = setTimeout("rjxAnim.run(" + th.n + ")", th.to);
}

rjxAnim.prototype.stop = function () {
  var th = this, a = rjxAnim.inst;
  th.e.anim = null;
  th.pause();
  a[th.n] = null;
  if (th.oe) th.oe.call(th);
}


/*
  Эффекты
*/

function rjxEffects (e) {
  this.e = rjxE(e);
}

rjxEffects.prototype.start = function (a) {
  var e = this.e, st = e.style;
  st._overflow = st.overflow;
  st.overflow = "hidden";
  a.start();
}

rjxEffects.prototype.end = function () {
  var e = this.e, st = e.style;
  st.overflow = st._overflow;
}

rjxEffects.prototype.slideUp = function (cf) {
  var th = this,
      an = new rjxAnim (th.e, 0.6, cbf, 3, 1, oef),
      st = th.e.style,
      h = rjxDimensions(th.e).height;
  th.start(an);
  function cbf (e, p) {
    rjxHeight(th.e, h * (1 - p));
  }
  function oef () {
    rjxShow(this.e, false);
    st.height = "";
    th.end();
    if (cf) cf.call(this);
  }
}

rjxEffects.prototype.slideDown = function (cf) {
  var th = this,
      an = new rjxAnim (th.e, 0.6, cbf, 3, 1, oef),
      st = th.e.style,
      h = rjxDimensions(th.e).height;
  rjxHeight(th.e, 0);  
  rjxShow(this.e, true);
  th.start(an);
  function cbf (e, p) {
    rjxHeight(th.e, h * p);
  }
  function oef () {
    st.height = "";
    th.end();
    if (cf) cf.call(this);
  }
}

rjxEffects.prototype.twiLight = function (cf) {
  var th = this,
      an = new rjxAnim (th.e, 1, cbf, 1, 1, oef);
  rjxShow(th.e, true);
  rjxOpacity(th.e,0);
  an.start();
  function cbf (e, p) {
    rjxOpacity(e,p);
  }
  function oef (e, p) {
    if (cf) cf.call(this);
  }
}

rjxEffects.prototype.twiDark = function (cf) {
  var th = this,
      an = new rjxAnim (th.e, 1, cbf, 1, 1, oef);
  rjxOpacity(th.e,1);
  an.start();
  function cbf (e, p) {
    rjxOpacity(e,1-p);
  }
  function oef () {
    rjxShow(th.e, false);
    if (cf) cf.call(this);
  }
}




function rjxBBCode (ta, ex) {
  this.ta = rjxE(ta);
  this.ta.bbc = this;
  this.ex = rjxE(ex);
  if (this.ex)
    rjxAddListener (this.ta, "keyup", this.mkExample);
}

rjxBBCode.prototype.mkExample = function () {
  var th = this.bbc ? this.bbc : this, v = th.ta.value, p = th.ex,
      ap = /<a href="([^"]*?)(\[.*?\])([^"]*?)">/g;
  v = v.replace(/"/g,"&quot;");
  v = v.replace(/<\w[^>]*?>/g,"");
  v = v.replace(/\[link=(.+?)\]/g,"<a href=\"$1\">"); //link=
  v = v.replace(/\[link\](.+?)\[\/link\]/g,"<a href=\"$1\">$1</a>"); //link
  while (ap.test(v)) v = v.replace(ap,"<a href=\"$1$3\">"); //delete tags from href
  v = v.replace(/\[\/link\]/g,"</a>"); // /link
  v = v.replace(/\[(\/?[bip])\]/g,"<$1>"); //b i p
  v = v.replace(/\[u\](.+?)\[\/u\]/g,"<span class=\"uline\">$1</span>"); //u
  v = v.replace(/\[(\/?)list\]/g,"<$1ul>"); //list
  v = v.replace(/\[(\/?)\*\]/g,"<$1li>"); //*
  v = v.replace(/\[size=([\d]+?)%\](.+?)\[\/size\]/g,"<span class=\"fs_$1\">$2</span>"); //size
  v = v.replace(/\[color=([\w]+?)\](.+?)\[\/color\]/g,"<span class=\"color_$1\">$2</span>"); //color
  p.innerHTML = v;
}

rjxBBCode.prototype.insBB = function (sc, ec) {
  var th = this, e = th.ta, d = document, cr, rg, v = e.value;
  e.focus();
//ie & opera
  if (d.selection) {
    rg = d.selection.createRange();
    if (rg.text) d.selection.createRange().text = sc + rg.text + ec;
    else e.value += sc + ec;
    e.focus();
  }
  else if (rjxDef(e.selectionStart)) {
    cr = e.selectionStart;
    rg = e.selectionEnd;
    v = v.substr(0, cr) + sc + v.substr(cr, rg - cr) + ec + v.substr(rg);
    e.value = v;
    if (cr != rg) e.selectionEnd = rg + sc.length + ec.length;
    else {
      e.selectionStart = cr + sc.length;
      e.selectionEnd = e.selectionStart;
    }
  }
  else e.value += sc + ec;
  if (th.ex) th.mkExample.call(th.ta);
}









//Параметры класс, прозрачность, (0 - клиентская область, 1 - окно = прокрутка)
function rjxBGFrame (c, o, t) {
  if (!t) t = 0;
  if (!o) o = .5;
  if (!c) c = "";
  var dv = rjxCE("div", {}, rjxET("body")[0]);
  rjxOpacity(dv, o);
  rjxWidth(dv, rjxClientWidth());
  rjxHeight(dv, rjxClientHeight());
  dv.className = c;
  dv.style.position = "absolute";
  dv.style.left = 0;
  dv.style.top = 0;
  dv.style.zIndex = "100";
  return dv;
}










rjxZoomer = {
  inst : [],  // e - small element, b - big img, t - text, f - effect, p - src for big img, imw - wait div, bgf - bgDiv, a - animation params
  steps : 10, //steps in animation
  
//e, fullimage, effect (1 бит - по вреху/на месте, 2 - увеличение, 3 - проявление), text
  set : function (e, f, ef, t) {
    e = rjxE(e); if (!t) t = ""; if (!rjxDef(ef)) ef = 3;
    rjxAddListener(e, "click", this.onClick);
    e.rjxZm = this.inst.length;
    this.inst[e.rjxZm] = {e: e, p: f, t: t, f: ef};
  },
  
  onClick : function (evt) {
    var ins = rjxZoomer.inst[this.rjxZm], bd = rjxET("body")[0],
        dv = rjxCE("div", {className: "rjxZmVD"}, bd),
        iex = 0, iey = evt.clientY - evt.offsetY;
    iex = (rjxDef(evt.offsetX) && !window.opera) ? evt.clientX + rjxScrollLeft() - evt.offsetX : rjxLeft(ins.e);
    iey = (rjxDef(evt.offsetY) && !window.opera) ? evt.clientY + rjxScrollTop() - evt.offsetY : rjxTop(ins.e);
    ins.imw = rjxCE("div", {className: "rjxZmrPD"}, bd);
    rjxCopyPos (ins.imw, ins.e);
    rjxLeft(ins.imw, iex);
    rjxTop(ins.imw, iey);
    rjxVisible(dv, false);
    ins.b = rjxCE ("img", {src: ins.p, alt: ins.t, className: "rjxZmVI", onclick: rjxZoomer.onClose}, dv);
    rjxCT(ins.t, rjxCE("div", {}, dv));
    rjxZoomer.listenerLoad(this.rjxZm);
  },

  listenerLoad : function (n) {
    if (rjxZoomer.inst[n].b.width < 50) setTimeout("rjxZoomer.listenerLoad("+n+")", 100);
    else rjxZoomer.onLoad(n);
  },

  onLoad : function (n) {
    var ins = rjxZoomer.inst[n], dv = ins.b.parentNode;
    ins.b.wt = ins.b.width;
    ins.b.ht = ins.b.height;
    rjxCopyPos (dv, ins.imw);
    rjxCopyPos (ins.b, ins.imw);
    ins.bgf = rjxBGFrame("bgDv", 0.9);
    this.startAnimation(n);
  },
  
  startAnimation : function (n) {
    var ins = rjxZoomer.inst[n], dv = ins.b.parentNode,
              bw = rjxGetComputedStyle(ins.b, "border-left-width", true) + rjxGetComputedStyle(ins.b, "border-right-width", true),
              bh = rjxGetComputedStyle(ins.b, "border-top-width", true) + rjxGetComputedStyle(ins.b, "border-bottom-width", true),
              cp = rjxDimensions(ins.imw),
              fp = {width_: ins.b.wt, height_: ins.b.ht, width: ins.b.wt + bw, height: ins.b.ht + bh},
              ls, le, ts, te, ws, hs, o, s = rjxZoomer.steps,
              th = (Math.round(ins.t.length / 100) + 1) * 30;
    rjxRemoveChild (ins.imw);
    //Current / Top page
    if ((ins.f & 0x01) > 0) {
      le = cp.left + (cp.width - fp.width) / 2;
      te = cp.top + (cp.height - fp.height) / 2;
    }
    else {
      le = (rjxClientWidth() - fp.width) / 2;
      te = rjxScrollTop();
    }
    //Opacity
    if ((ins.f & 0x04) > 0) o = 0;
    else o = 1;
    //Out of page
    if (le + fp.width > rjxClientWidth())
      le = rjxClientWidth() - fp.width;
    if (te + fp.height > rjxClientHeight())
      te = rjxClientHeight() - fp.height;
    if (le < 0) le = 0;
    if (te < 0) te = 0;
    //Move
    if ((ins.f & 0x02) > 0) {
      ls = cp.left; ts = cp.top;
      ws = cp.width; hs = cp.height;
    }
    else {
      ls = le; ts = te;
      ws = fp.width_; hs = fp.height_;
    }
    //Save animation params
    ins.a = [s + 1, ls, ts, ws, hs, o, (le - ls) / s, (te - ts) / s, (fp.width_ - ws) / s,
             (fp.height_ - hs) / s, (1 - o) / s, fp.width - fp.width_, fp.height - fp.height_ + th];
    this.stepAnimation (n);
  },
  
  stepAnimation : function (n) {
    var ins = rjxZoomer.inst[n], a = ins.a, i;
    rjxVisible(ins.b.parentNode, true);
    rjxLeft(ins.b.parentNode, Math.round(a[1]));
    rjxTop(ins.b.parentNode, Math.round(a[2]));
    rjxWidth(ins.b.parentNode, Math.round(a[3] + a[11]));
    rjxHeight(ins.b.parentNode, Math.round(a[4] + a[12]));
    rjxWidth(ins.b, Math.round(a[3]));
    rjxHeight(ins.b, Math.round(a[4]));
    rjxOpacity(ins.b.parentNode, a[5]);
    for (i = 1; i < 6; i++) {
      a[i] += a[i+5];
    }
    a[0]--;
    if (a[0] > 0) setTimeout("rjxZoomer.stepAnimation("+n+")", 10);
  },
  
  onClose : function (n) {
    var i, ins;
    for (i = 0; i < rjxZoomer.inst.length; i++)
      if (this == rjxZoomer.inst[i].b) break;
    ins = rjxZoomer.inst[i];
    rjxRemoveChild(ins.bgf);
    rjxRemoveChild(ins.b.parentNode);
  }
}



rjxLineSlider = {
  inst : [],  // be - bigimg, bx - box, imp - prefix, imc - count imgs, h0, h1 - высота пассив/актив, s - steps, cs current step, 
              // w0,w1 - ширина, wp - w+wp*imp = ширина полосы, bw - область прокрутки, to - timeout, comms - comments, cb
  steps : 5, //steps in animation
  
  
  init : function (p, px) {
    this.pth = p;
    this.px = px ? px : "1px.gif";
  },
  
  set : function (be, bx, cb, imc, imp, h0, h1, w1, s, comms) {
  //init
    var n = this.inst.length, bx = rjxE(bx), i, w0, w1, box = rjxET("div", bx)[0];
    bx.rjxLS = n;
    this.inst[n] = {be: rjxE(be), bx: bx, imp: imp ? imp : "", imc: imc, h0: h0, h1: h1, s: s, comms: comms, cb: rjxE(cb)};
  //createimgs
    i = rjxCE("img", {src: this.pth+imp+"0.th.jpg", alt: "", className: "rjxLS",
                      onclick: this.onClick, onmouseover: this.onMOver}, box);
    this.inst[n].wp = rjxGetComputedStyle(i, "border-left-width", true) +
                      rjxGetComputedStyle(i, "border-right-width", true);
    w0 = w1 * h0 / h1;
    i.width = w0;
    i.height = h0;
    this.inst[n].w0 = w0;
    this.inst[n].w1 = w1;
    for (i = 1; i < imc; i++)
      rjxCE("img", {src: this.pth+imp+i+".th.jpg", height: h0, width: w0, alt: "", className: "rjxLS",
                    onclick: this.onClick, onmouseover: this.onMOver}, box);
    rjxVisible(rjxCI(this.pth+this.px, 1, h1, "", "", box, {className: "rjxLS"}), false);
    this.inst[n].bw = (w0 + this.inst[n].wp) * imc - rjxWidth(bx);
  //Listener
    rjxAddListener(bx, "mousemove", this.onMouseMov);
  },
  
  
  onMouseMov : function (e) {
    var th = this, ins = rjxLineSlider.inst[th.rjxLS],
        box = rjxET("div", ins.bx)[0],
        xx = rjxDef(e.offsetX) ? e.offsetX : e.layerX, i,
        targ = rjxDef(e.target) ? e.target : (rjxDef(e.currentTarget) ? e.currentTarget : e.srcElement),
        ims = rjxET("img", ins.bx);
    if (!rjxDef(e.layerX))
      xx += rjxGetComputedStyle(box, "margin-left", true);
    if ((targ != th) && (targ != box) && (!rjxDef(e.layerX))) {
      for (i = 0; i < ims.length; i++)
        if (ims[i] == targ) break;
        else xx += rjxWidth(ims[i]);
    }
    box.style.marginLeft = -Math.round(ins.bw * xx / rjxWidth(ins.bx)) + "px";
  },
  
  onClick : function () {
    var p = this.parentNode.parentNode, ins = rjxLineSlider.inst[p.rjxLS],
        i, ims = rjxET("img", ins.bx);
    ins.be.src = this.src.replace(".th.jpg", ".jpg");
    if (ins.comms) {
      for (i = 0; i < ims.length; i++)
        if (ims[i] == this) break;
      ins.be.alt = ins.comms[i];
      ins.cb.innerHTML = ins.comms[i];
    }
    
    
    
  },
  
  onMOver : function () {
    var p = this.parentNode.parentNode, ins = rjxLineSlider.inst[p.rjxLS],
            i, ims = rjxET("img", ins.bx);
    for (i = 0; i < ims.length; i++)
      if (ims[i] == this) break;
    rjxLineSlider.startAnimation(p.rjxLS, i);
  },
  
  startAnimation : function (nn, n) {
    var ins = this.inst[nn], ims = rjxET("img", ins.bx), i, m;
    clearTimeout(ins.to);
    for (i = 0; i < ims.length - 1; i++) {
      m = Math.abs(i - n);
      if (m < ins.s) {
        ims[i].w0 = Math.round(ins.w1 - (ins.w1 - ins.w0) / ins.s * m);
        ims[i].h0 = Math.round(ins.h1 - (ins.h1 - ins.h0) / ins.s * m);
      }
      else {
        ims[i].w0 = ins.w0;
        ims[i].h0 = ins.h0;
      }
    }
    ins.cs = this.steps;
    this.stepAnimation(nn);
  },
  
  stepAnimation : function (n) {
    var ins = this.inst[n], i, ims = rjxET("img", ins.bx), w, h, s = 0;
    if (ins.cs == 1) {
      for (i = 0; i < ims.length - 1; i++) {
        ims[i].width = ims[i].w0;
        ims[i].height = ims[i].h0;
        ims[i].style.borderColor = (ims[i].width == ins.w1) ? "#FFB6C1" : "";
        s += ims[i].w0;
      }
      ins.bw = s + ins.wp * (ims.length - 1) - rjxWidth(ins.bx);
      return;
    }
    for (i = 0; i < ims.length - 1; i++) {
      w = ims[i].width;
      if (w != ims[i].w0) {
        h = ims[i].height;
        ims[i].width = Math.round((ims[i].w0 - w) / ins.cs + w);
        ims[i].height = Math.round((ims[i].h0 - h) / ins.cs + h);
      }
    }
    ins.cs--;
    ins.to = setTimeout("rjxLineSlider.stepAnimation("+n+")" ,100);
  }
}



rjxSnow = {
  fonts : ["Courier New", "Courier", "MS Serif", "New York", "Times New Roman", "Times", "MS Sans Serif",
           "Geneva", "Verdana", "Arial", "Helvetica", "Calibri", "Constantia", "Comic Sans MS", "Latha"],
  inst : [],

  start : function (cnt, h) {
    this.cnt = cnt;
    this.h = h;
    this.w = rjxClientWidth();
    this.startAnimation ();
  },
  
  random : function (n) {
    return Math.round(Math.random() * n);
  },
  
  createElement : function () {
    var el = rjxCE("div", {}, rjxET("body")[0]), st = el.style, th = rjxSnow;
    st.position = "absolute";
    st.zIndex = 150;
    st.fontFamily = th.fonts[th.random(th.fonts.length - 1)];
    st.fontSize = 8 + this.random(15) + "pt";
    st.color = "#FFFFFF";
    st.top = - this.random(this.h) + "px";
    st.width = "30px";
    rjxCT("*", el);
    el.snow = {a: this.random(40), b: 0.01 + (this.random(25) / 1000),
               c: 1 - this.random(200) / 100, d: this.random(4) + 1, x: 50 + this.random(this.w - 100)};
    return el;
  },
  
  startAnimation : function () {
    for (var i = 0; i < this.cnt; i++) {
      this.inst[i] = this.createElement ();
    }
    this.stepAnimation();
  },
  
  
  stepAnimation : function () {
    var th = rjxSnow, ins = th.inst, i, y, x;
    for (i = 0; i < ins.length; i++) {
      y = rjxTop(ins[i]);
      x = ins[i].snow.x + ins[i].snow.a * Math.sin(ins[i].snow.b * y + ins[i].snow.c);
      rjxTop(ins[i], y + ins[i].snow.d);
      rjxLeft(ins[i], x);
      if (y > th.h) {
        rjxRemoveChild(ins[i]);
        ins[i] = th.createElement();
      }
    }
    setTimeout("rjxSnow.stepAnimation()", 1);
  }
}
