function _InitManager()
{
  this.execute_events = function(name)
  {
    if (!this.events[name])
      return;
    for (var k in this.events[name])
    {
      if (k == "length")
        continue;
      if (typeof(this.events[name][k]) == "function")
        this.events[name][k]();
      else if (typeof(this.events[name][k]) == "string")
        eval(this.events[name][k]);
    }
  }
  this.register_event = function(name, callback)
  {
    if (!this.events[name])
    {
      this.events[name] = new Object();
      this.events[name]["length"] = 0;
    }
    this.events[name]["length"]++;
    this.events[name][this.events[name]["length"]]=callback;
  }
  this.unregister_event = function(name, callback)
  {
    if (!this.events[name])
      return;
    for (var k in this.events[name])
    {
      if (k == "length")
        continue;
      if (this.events[name][k]==callback)
      {
        delete this.events[name][k];
        this.events[name]["length"]--;
        return;
      }
    }
  }
  this.events = new Object();
  window.onload = function() {InitManager.execute_events("onload");};
  window.onresize = function() {InitManager.execute_events("onresize");};
  window.onscroll = function() {InitManager.execute_events("onscroll");};
}
var InitManager = new _InitManager();

function _ConnectionManager()
{
  this.pool;
  this.requests;
  this.req_next=1;
  this.createHttpRequest = function()
  {
    req = null;
    if (window.XMLHttpRequest)
    {
      try
      {
        req = new XMLHttpRequest();
      } catch (e){}
    }
    else if (window.ActiveXObject)
    {
      try
      {
        req = new ActiveXObject('Msxml2.XMLHTTP');
      } catch (e)
      {
        try
        {
          req = new ActiveXObject('Microsoft.XMLHTTP');
        } catch (e){}
      }
    }
    return req;
  }
  this.checkLoad = function()
  {
    for (var k=0;k<5;k++)
    {
      if (this.pool[k]["active"])
      {
        if (this.pool[k]["obj"].readyState == 4)
        {
          if (this.pool[k]["obj"].status == 200)
            this.pool[k]["callback"](this.pool[k]["obj"].responseXML);
          delete this.requests[this.pool[k]["req_id"]];
          this.pool[k]["active"]=false;
          this.pool[k]["time"]=0;
          this.pool[k]["req_id"]=0;
        }
        else
        {
          if (((new Date).getTime()-this.pool[k]["time"])>5000)
          {
            this.pool[k]["obj"].abort();
            this.requests[this.pool[k]["req_id"]]["active"]=false;
            this.pool[k]["active"]=false;
            this.pool[k]["time"]=0;
            this.pool[k]["req_id"]=0;
            this.send();
          }
        }
      }
    }
    this.send();
    setTimeout("ConnectionManager.checkLoad()",200);
  }
  this.init = function()
  {
    this.pool = new Object();
    for (var k=0;k<5;k++)
    {
      this.pool[k]=new Object();
      this.pool[k]["obj"]=this.createHttpRequest();
      this.pool[k]["active"]=false;
      this.pool[k]["req_id"]=0;
      this.pool[k]["time"]=0;
    }
    this.requests = new Object();
    setTimeout("ConnectionManager.checkLoad()",200);
  }
  this.send = function()
  {
    for (var k in this.requests)
    {
      if (!this.requests[k]["active"])
      {
        for (var m=0;m<5;m++)
        {
          if (!this.pool[m]["active"])
          {
            this.pool[m]["active"]=true;
            this.pool[m]["req_id"]=k;
            this.pool[m]["callback"]=this.requests[k]["callback"];
            this.pool[m]["time"]=(new Date()).getTime();
            this.requests[k]["active"]=true;
            this.pool[m]["obj"].open("POST", this.requests[k]["url"], true);
            this.pool[m]["obj"].setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
            this.pool[m]["obj"].setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            this.pool[m]["obj"].setRequestHeader("Content-length", this.requests[k]["params"].length);
            this.pool[m]["obj"].setRequestHeader("Connection", "close");
            this.pool[m]["obj"].send(this.requests[k]["params"]);
            break;
          }
        }
      }
    }
  }
  this.get = function(url,params,callback)
  {
    if (!this.pool)
      this.init();
    this.requests[this.req_next]=new Object();
    this.requests[this.req_next]["url"]=url;
    this.requests[this.req_next]["params"]=params;
    this.requests[this.req_next]["callback"]=callback;
    this.requests[this.req_next++]["active"]=false;
    this.send();
  }
}
var ConnectionManager = new _ConnectionManager();

function fix_png(el)
{
  if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent)) return;

  var src;
  if (el.tagName=='IMG')
  {
    if (/\.png$/.test(el.src))
    {
      src = el.src;
      el.src = "/img/high.gif";
      el.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
    }
  }
  else
  {
    src = el.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
    if (src)
    {
      src = src[1];
      el.runtimeStyle.backgroundImage="none";
      if (el.currentStyle.backgroundRepeat == "no-repeat")
        el.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
      else
        el.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
    }
  }
}

function _ImageViewer()
{
  this.handle;
  this.viewarea;
  this.thumbails;
  this.shadow;
  this.loading;
  this.close_button;
  this.prev_button;
  this.next_button;
  this.sce;
  this.images = new Object();
  this.mwidth = 352;
  this.mheight = 200;
  this.tcount;
  this.is_loading = false;
  this.is_slideshow = false;
  this.prev_image = function()
  {
    this.onclick_thumbail(this.images.curr-1);
  }
  this.next_image = function()
  {
    this.onclick_thumbail(this.images.curr+1);
  }
  this.set_nav = function ()
  {
    if (this.images.curr > 1)
      this.prev_button.style.visibility="visible";
    else
      this.prev_button.style.visibility="hidden";
    if (this.images.curr < this.images.length)
      this.next_button.style.visibility="visible";
    else
      this.next_button.style.visibility="hidden";
  }
  this.pos = function()
  {
    if (!this.handle)
      return;
    var atop = 0;
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      atop = document.documentElement.scrollTop;
    this.handle.style.top = ((document.documentElement.clientHeight - this.handle.offsetHeight) / 2) + atop + "px";
    this.handle.style.left = ((document.documentElement.clientWidth - this.handle.offsetWidth) / 2) + "px";
    this.close_button.style.left = this.handle.offsetLeft + this.handle.offsetWidth + "px";
    this.close_button.style.top = this.handle.offsetTop - this.close_button.offsetHeight + "px";
    this.expand_button.style.left = this.handle.offsetLeft - this.expand_button.offsetWidth - 5 + "px";
    this.expand_button.style.top = this.handle.offsetTop + 50 + "px";
    this.slide_button.style.left = this.handle.offsetLeft - this.slide_button.offsetWidth - 5 + "px";
    this.slide_button.style.top = this.handle.offsetTop + 75 + "px";
    this.prev_button.style.left = this.handle.offsetLeft - this.prev_button.offsetWidth - 5 + "px";
    this.prev_button.style.top = this.handle.offsetTop + this.handle.offsetHeight / 2  + "px";
    this.next_button.style.left = this.handle.offsetLeft + this.handle.offsetWidth + 5 + "px";
    this.next_button.style.top = this.handle.offsetTop + this.handle.offsetHeight / 2 + "px";
    this.thumb_prev_button.style.left = this.handle.offsetLeft - this.thumb_prev_button.offsetWidth - 5 + "px";
    this.thumb_prev_button.style.top = this.handle.offsetTop + this.handle.offsetHeight - this.thumbails.offsetHeight + 5  + "px";
    this.thumb_next_button.style.left = this.handle.offsetLeft + this.handle.offsetWidth + 5 + "px";
    this.thumb_next_button.style.top = this.handle.offsetTop + this.handle.offsetHeight - this.thumbails.offsetHeight + 5  + "px";
    this.loading.style.left = this.handle.offsetLeft + (this.viewarea.offsetWidth - this.loading.offsetWidth) / 2 + "px";
    this.loading.style.top = this.handle.offsetTop + (this.viewarea.offsetHeight - this.loading.offsetHeight) / 2 +  "px";
    this.set_nav();
  }
  this.dark_all = function()
  {
    this.shadow = document.createElement("DIV");
    this.shadow.style.cssText = "z-index:1000;background:#000000;left:0px;top:0px;width:100%;height:100%;position:fixed;opacity:0.5;filter:alpha(opacity=50);";
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
    {
      this.shadow.style.position = "absolute";
      this.shadow.style.width = document.documentElement.scrollWidth;
      this.shadow.style.height = document.documentElement.scrollHeight;
    }
    document.body.appendChild(this.shadow);
  }
  this.get_text = function(obj)
  {
    if (/MSIE/.test(navigator.userAgent))
      return obj.text;
    return obj.textContent;
  }
  this.set_thumbail = function(id)
  {
    this.images[id].thumbail.src = this.images[id].thumbail_t.src;
    this.images[id].thumbail.onmouseover = function(id) {return function() {ImageViewer.onmouseover_thumbail(id)}} (id);
    this.images[id].thumbail.onmouseout = function(id) {return function() {ImageViewer.onmouseout_thumbail(id)}} (id);
    if (id == this.images.curr)
    {
      this.images[this.images.curr].thumbail.style.cssText = "margin:0;width:48px;height:48px;border:1px solid #aa0000;filter:alpha(opacity=100);opacity:1;cursor:default;";
      this.images[this.images.curr].thumbail.onclick = function() {};
      return;
    }
    var a = "";
    if (this.images[id].thumbail.style.visibility == "hidden")
      a = "visibility:hidden;";
    this.images[id].thumbail.style.cssText = "margin:5px;width:40px;height:40px;border:0;opacity:0.5;filter:alpha(opacity=50);cursor:pointer;" + a;
    this.images[id].thumbail.onclick = function(id) {return function() {ImageViewer.onclick_thumbail(id)}} (id);
  }
  this.load = function()
  {
    this.is_loading = true;
    this.prev_button.style.visibility = "hidden";
    this.next_button.style.visibility = "hidden"
    this.images[this.images.curr].image = document.createElement("IMG");
    this.images[this.images.curr].image.src = this.images[this.images.curr].src;
    if (!this.images[this.images.curr].image.complete)
    {
      this.loading.style.visibility = "visible";
      this.images[this.images.curr].image.onload = function() {ImageViewer.set_image()};
    }
    else
      this.set_image();
  }
  this.light_image = function()
  {
    if (!this.handle)
      return;
    this.images[this.images.curr].alpha += 10;
    if (/MSIE/.test(navigator.userAgent))
    {
      this.images[this.images.curr].alpha += 10;
      this.images[this.images.curr].image.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.images[this.images.curr].alpha + ");";
    }
    else
      this.images[this.images.curr].image.style.opacity = this.images[this.images.curr].alpha / 100;
    if (this.images[this.images.curr].alpha < 100)
      setTimeout(function() {ImageViewer.light_image()}, 50);
    else
    {
      this.is_loading = false;
      this.images[this.images.curr].image.onclick = function() {ImageViewer.close();};
    }
  }
  this.get_dims = function()
  {
    var maxw = document.documentElement.clientWidth - this.prev_button.offsetWidth - this.next_button.offsetWidth - 50;
    var maxh = document.documentElement.clientHeight - this.close_button.offsetHeight - 40 - this.thumbails.offsetHeight;
    var w = this.images[this.images.curr].w;
    var h = this.images[this.images.curr].h;
    if (h > maxh)
    {
      var old_h = h;
      h = maxh;
      w = Math.round(h / old_h * w);
    }
    if (w > maxw)
    {
      var old_w = w;
      w = maxw;
      h = Math.round(w / old_w * h);
    }
    return [w,h];
  }
  this.set_image = function()
  {
    if (!this.handle)
      return;
    this.loading.style.visibility = "hidden";
    if (this.viewarea.childNodes.length == 1)
      this.viewarea.removeChild(this.viewarea.childNodes[0]);
    if (/MSIE/.test(navigator.userAgent))
      this.images[this.images.curr].image.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0);";
    else
      this.images[this.images.curr].image.style.opacity = 0;
    this.images[this.images.curr].alpha = 0;
    this.viewarea.appendChild(this.images[this.images.curr].image);
    this.images[this.images.curr].w = this.images[this.images.curr].image.offsetWidth;
    this.images[this.images.curr].h = this.images[this.images.curr].image.offsetHeight;
    this.resize();
    this.light_image();
  }
  this.load_thumbails = function()
  {
    this.thumbails.style.height = "52px";
    var dv=document.createElement("DIV");
    dv.style.cssText = "height:50px;margin-top:1px;white-space:nowrap;position:relative;left:0;top:0;";
    this.thumbails.appendChild(dv);
    this.mheight += 52;
    for (var k in this.images)
    {
      if (isNaN(k))
        continue;
      this.images[k].thumbail = document.createElement("IMG");
      this.images[k].thumbail.src = "/img/iviewer/iw_iloading.gif";
      this.images[k].thumbail.style.cssText = "width:40x;height:40px;margin:5px;";
      dv.appendChild(this.images[k].thumbail);
      this.images[k].thumbail_t = document.createElement("IMG");
      this.images[k].thumbail_t.onload = function(k) {return function() {ImageViewer.set_thumbail(k)}} (k);
      this.images[k].thumbail_t.src = this.images[k].thumb_src;
    }
    this.resize();
  }
  this.parse_data = function(obj)
  {
    if (!this.handle)
      return;
    for (var k in this.images)
      delete this.images[k];
    var els = obj.getElementsByTagName("result");
    this.images.length = els.length;
    for (var k = 0;k < els.length;k++)
    {
      this.images[k+1] = new Object();
      this.images[k+1].rpoint = 0;
      this.images[k+1].rdir = 1;
      for (var m = 0;m < els.item(k).childNodes.length;m++)
      {
        var el = els.item(k).childNodes[m];
        var val = this.get_text(el);
        if (el.tagName == "curr")
        {
          if  (val == "1")
            this.images.curr = k + 1;
          continue;
        }
        this.images[k+1][el.tagName] = val;
      }
    }
    if (this.images.length > 0)
    {
      if (this.images.length > 1)
      {
        this.load_thumbails();
        this.slide_button.style.visibility = "visible";
      }
      this.load();
    }
  }
  this.move_thumbail = function(id)
  {
    this.images[id].rtm = setTimeout(function(id) {return function() {ImageViewer.move_thumbail(id)}} (id), 20);
    if (this.images[id].rdir == 1)
      return;
    if ((this.images[id].rdir == 3) && (this.images[id].ron == 1))
      return;
    if (this.images[id].rdir == 2)
    {
      if (this.images[id].rpoint == 0)
      {
        if (/MSIE/.test(navigator.userAgent))
          this.images[id].thumbail.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100);";
        else
          this.images[id].thumbail.style.opacity = 1;
      }
      this.images[id].rpoint++;
      if (this.images[id].rpoint == 6)
      {
        this.images[id].rdir = 3;
        this.images[id].rpoint = 5;
        return;
      }
    }
    if (this.images[id].rdir == 3)
    {
      if (this.images[id].rpoint == 0)
      {
        if (/MSIE/.test(navigator.userAgent))
          this.images[id].thumbail.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50);";
        else
          this.images[id].thumbail.style.opacity = 0.5;
      }
      this.images[id].rpoint--;
      if (this.images[id].rpoint == -1)
      {
        this.images[id].rpoint = 0;
        if (this.images[id].rdir == 3)
          this.images[id].rdir = 1;
      }
    }
    this.images[id].thumbail.style.margin = 5 -this.images[id].rpoint + "px";
    this.images[id].thumbail.style.width = 40 + this.images[id].rpoint * 2 + "px";
    this.images[id].thumbail.style.height = 40 + this.images[id].rpoint * 2 + "px";
  }
  this.onmouseover_thumbail = function(id)
  {
    if (this.images.curr != id)
    {
      this.images[id].rdir = 2;
      this.images[id].ron = 1;
      if (!this.images[id].rtm)
        this.images[id].rtm = setTimeout(function(id) {return function() {ImageViewer.move_thumbail(id)}} (id), 20);
    }
    if ((this.images[id].name) && (!this.is_loading))
    {
      this.name.style.display = "block";
      this.name.innerHTML = this.images[id].name;
      this.name.style.width = this.viewarea.childNodes[0].offsetWidth -40 + "px";
      this.name.style.left = this.handle.offsetLeft + "px";
      this.name.style.top = this.handle.offsetTop + this.viewarea.childNodes[0].offsetHeight - this.name.offsetHeight + "px";
    }
  }
  this.onmouseout_thumbail = function(id)
  {
    if (this.images.curr != id)
      this.images[id].ron = 0;
    this.name.style.display = "none";
  }
  this.onclick_thumbail = function(id,slide)
  {
    if (this.is_loading)
      return;
    if ((this.is_slideshow) && (!slide))
      this.stop_slide_show();
    if (/MSIE/.test(navigator.userAgent))
      this.images[this.images.curr].image.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50);";
    else
      this.images[this.images.curr].image.style.opacity = 0.5;
    this.images.curr = id;
    for (var k = 1;k <= this.images.length;k++)
      this.set_thumbail(k);
    this.is_loading = true;
    this.name.style.display = "none";
    this.load();
  }
  this.thumb_move_right = function()
  {
    if ((this.fthumb + this.tcount - 1) < this.images.length)
    {
      this.fthumb++;
      this.set_thumb_nav();
    }
  }
  this.thumb_move_left = function()
  {
    if (this.fthumb > 1)
    {
      this.fthumb--;
      this.set_thumb_nav();
    }
  }
  this.slide_show = function()
  {
    if (!this.handle)
      return;
    if (!this.is_slideshow)
      return;
    setTimeout(function() {ImageViewer.slide_show();},3000);
    if (this.is_loading)
      return;
    var id = this.images.curr + 1;
    if (id > this.images.length)
      id = 1;
    this.onclick_thumbail(id,true);
  }
  this.stop_slide_show = function()
  {
    this.is_slideshow = false;
    this.slide_button.src = "/img/iviewer/iw_slideshow.png";
    fix_png(this.slide_button);
  }
  this.start_slide_show = function()
  {
    if (this.is_loading)
      return;
    if (this.is_slideshow)
    {
      this.stop_slide_show();
      return;
    }
    this.slide_button.src = "/img/iviewer/iw_slideshow_sel.png";
    fix_png(this.slide_button);
    this.is_slideshow = true;
    this.slide_show();
  }
  this.expand_image = function()
  {
    window.open(this.images[this.images.curr].src);
  }
  this.set_thumb_nav = function()
  {
    for (var k = 1;k <= this.images.length;k++)
      this.images[k].thumbail.style.visibility = "hidden";
    for (var k = this.fthumb;k < (this.tcount + this.fthumb);k++)
    {
      if (k > this.images.length)
        break;
      this.images[k].thumbail.style.visibility = "visible";
    }
    this.thumbails.childNodes[0].style.left = (this.viewarea.offsetWidth - this.tcount * 50) / 2 - (this.fthumb - 1) * 50 + "px";
    if (this.fthumb > 1)
      this.thumb_prev_button.style.visibility = "visible";
    else
      this.thumb_prev_button.style.visibility = "hidden";
    if ((this.fthumb + this.tcount - 1) < this.images.length)
      this.thumb_next_button.style.visibility = "visible";
    else
      this.thumb_next_button.style.visibility = "hidden";
  }
  this.resize = function()
  {
    if (this.viewarea.childNodes.length == 1)
    {
      var dims = this.get_dims();
      this.images[this.images.curr].image.style.width = dims[0] + "px";
      this.images[this.images.curr].image.style.height = dims[1] + "px";
      this.viewarea.style.width = this.viewarea.childNodes[0].offsetWidth + "px";
      this.viewarea.style.height = this.viewarea.childNodes[0].offsetHeight + "px";
    }
    this.thumbails.style.width = this.viewarea.offsetWidth + "px";
    this.handle.style.width = this.viewarea.offsetWidth + "px";
    this.handle.style.height = this.viewarea.offsetHeight + this.thumbails.offsetHeight + "px";
    if (this.images.length > 1)
    {
      var w = this.viewarea.offsetWidth - 2;
      this.tcount = Math.floor(w / 50);
      this.fthumb = 1;
      if (this.tcount < this.images.length)
      {
        this.fthumb = this.images.curr - Math.floor(this.tcount / 2);
        if (this.fthumb < 1)
          this.fthumb = 1;
        if ((this.fthumb + this.tcount - 1) > this.images.length)
          this.fthumb = this.images.length - this.tcount + 1;
      }
      else
        this.tcount = this.images.length;
      this.set_thumb_nav();
    }
    this.pos();
  }
  this.create_self = function()
  {
    this.dark_all();
    this.handle = document.createElement("DIV");
    this.handle.style.cssText = "position:fixed;z-index:1001;background:#ffffff;width:" + this.mwidth + "px;height:" + this.mheight + "px;-webkit-box-shadow:2px 2px 10px #000000;-moz-box-shadow:2px 2px 10px #000000;box-shadow:2px 2px 10px #000000;filter:progid:DXImageTransform.Microsoft.Shadow(color='#000000',Direction=135,Strength=6);";
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.handle.style.position = "absolute";
    document.body.appendChild(this.handle);
    this.viewarea = document.createElement("DIV");
    this.viewarea.style.cssText = "width:" + this.mwidth + "px;height:" + this.mheight + "px;";
    this.handle.appendChild(this.viewarea);
    this.thumbails = document.createElement("DIV");
    this.thumbails.style.cssText = "width:" + this.mwidth + "px;height:0px;overflow:hidden;";
    this.handle.appendChild(this.thumbails);
    this.close_button = document.createElement("IMG");
    this.close_button.src = "/img/iviewer/iw_close.png";
    this.close_button.style.cssText = "position:fixed;z-index:1002;cursor:pointer;width:15px;height:15px;";
    this.close_button.onclick = function() {ImageViewer.close();};
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.close_button.style.position = "absolute";
    document.body.appendChild(this.close_button);
    this.prev_button = document.createElement("IMG");
    this.prev_button.src = "/img/iviewer/iw_nav_prev.png";
    this.prev_button.style.cssText = "position:fixed;z-index:1002;width:20px;height:19px;cursor:pointer;visibility:hidden;";
    this.prev_button.onclick = function() {ImageViewer.prev_image();};
    this.prev_button.onmouseover = function() {this.src = "/img/iviewer/iw_nav_prev_sel.png";fix_png(this);};
    this.prev_button.onmouseout = function() {this.src = "/img/iviewer/iw_nav_prev.png";fix_png(this);};
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.prev_button.style.position = "absolute";
    document.body.appendChild(this.prev_button);
    this.next_button = document.createElement("IMG");
    this.next_button.src = "/img/iviewer/iw_nav_next.png";
    this.next_button.style.cssText = "position:fixed;z-index:1003;width:20px;height:19px;cursor:pointer;visibility:hidden;";
    this.next_button.onclick = function() {ImageViewer.next_image();};
    this.next_button.onmouseover = function() {this.src = "/img/iviewer/iw_nav_next_sel.png";fix_png(this);};
    this.next_button.onmouseout = function() {this.src = "/img/iviewer/iw_nav_next.png";fix_png(this);};
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.next_button.style.position = "absolute";
    document.body.appendChild(this.next_button);
    this.thumb_next_button = document.createElement("IMG");
    this.thumb_next_button.src = "/img/iviewer/iw_tnav_next.png";
    this.thumb_next_button.style.cssText = "position:fixed;z-index:1003;width:20px;height:40px;cursor:pointer;visibility:hidden;";
    this.thumb_next_button.onclick = function() {ImageViewer.thumb_move_right();};
    this.thumb_next_button.onmouseover = function() {this.src = "/img/iviewer/iw_tnav_next_sel.png";fix_png(this);};
    this.thumb_next_button.onmouseout = function() {this.src = "/img/iviewer/iw_tnav_next.png";fix_png(this);};
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.thumb_next_button.style.position = "absolute";
    document.body.appendChild(this.thumb_next_button);
    this.thumb_prev_button = document.createElement("IMG");
    this.thumb_prev_button.src = "/img/iviewer/iw_tnav_prev.png";
    this.thumb_prev_button.style.cssText = "position:fixed;z-index:1003;width:20px;height:40px;cursor:pointer;visibility:hidden;";
    this.thumb_prev_button.onclick = function() {ImageViewer.thumb_move_left();};
    this.thumb_prev_button.onmouseover = function() {this.src = "/img/iviewer/iw_tnav_prev_sel.png";fix_png(this);};
    this.thumb_prev_button.onmouseout = function() {this.src = "/img/iviewer/iw_tnav_prev.png";fix_png(this);};
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.thumb_prev_button.style.position = "absolute";
    document.body.appendChild(this.thumb_prev_button);
    this.expand_button = document.createElement("IMG");
    this.expand_button.src = "/img/iviewer/iw_expand.png";
    this.expand_button.style.cssText = "position:fixed;z-index:1003;width:16px;height:18px;cursor:pointer;v";
    this.expand_button.onclick = function() {ImageViewer.expand_image();};
    this.expand_button.setAttribute("title","Открыть в новом окне");
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.expand_button.style.position = "absolute";
    document.body.appendChild(this.expand_button);
    this.slide_button = document.createElement("IMG");
    this.slide_button.src = "/img/iviewer/iw_slideshow.png";
    this.slide_button.style.cssText = "position:fixed;z-index:1003;width:22px;height:21px;cursor:pointer;visibility:hidden;";
    this.slide_button.onclick = function() {ImageViewer.start_slide_show();};
    this.slide_button.setAttribute("title","Слайдшоу");
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.slide_button.style.position = "absolute";
    document.body.appendChild(this.slide_button);
    this.loading = document.createElement("IMG");
    this.loading.src = "/img/iviewer/iw_loading.gif";
    this.loading.style.cssText = "position:fixed;z-index:1020;width:208px;height:13px;";
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      this.loading.style.position = "absolute";
    document.body.appendChild(this.loading);
    this.name = document.createElement("DIV");
    this.name.style.cssText = "position:fixed;z-index:1030;display:none;background:url('/img/iviewer/iw_pix.png');color:#ffffff;font-weight:bold;font-size:14px;text-align:center;padding-bottom:5px;padding-top:5px;padding-left:20px;padding-right:20px;";
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
    {
      this.name.style.position = "absolute";
      this.name.className = "png";
    }
    document.body.appendChild(this.name);
    this.pos();
    InitManager.register_event("onresize", function() {ImageViewer.resize()});
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      InitManager.register_event("onscroll", function() {ImageViewer.pos()});
  }
  this.show = function(sce,id)
  {
    if (!this.handle)
      this.create_self();
    this.sce = sce;
    ConnectionManager.get(this.sce,"id="+id,function(txt) {ImageViewer.parse_data(txt)});
  }
  this.show_one = function(url)
  {
    if (!this.handle)
      this.create_self();
    this.expand_button.style.visibility = "hidden";
    for (var k in this.images)
      delete this.images[k];
    this.images.curr = 1;
    this.images[1] = new Object();
    this.images[1].src = url;
    this.load();
  }
  this.close = function()
  {
    InitManager.unregister_event("onresize", function() {ImageViewer.resize()});
    if (/MSIE (5\.5|6\.)/.test(navigator.userAgent))
      InitManager.unregister_event("onscroll", function() {ImageViewer.pos()});
    document.body.removeChild(this.handle);
    document.body.removeChild(this.prev_button);
    document.body.removeChild(this.next_button);
    document.body.removeChild(this.thumb_prev_button);
    document.body.removeChild(this.thumb_next_button);
    document.body.removeChild(this.expand_button);
    document.body.removeChild(this.slide_button);
    document.body.removeChild(this.close_button);
    document.body.removeChild(this.loading);
    delete this.handle;
    document.body.removeChild(this.shadow);
  }
}
var ImageViewer = new _ImageViewer();

function _LoadManager()
{
  this.images = new Object();
  this.images_len = 0;
  this.add = function(src)
  {
    this.images[this.images_len] = new Object();
    this.images[this.images_len++]["src"] = src;
  }
  this.start = function(callback)
  {
    this.callback = callback;
    this.int = setInterval(function() {LoadManager.check_complete()},20);
    for (var k in this.images)
    {
      this.images[k]["complete"] = false;
      this.images[k]["img"] = document.createElement("IMG");
      this.images[k]["img"].onload = function(k1) {return function() {LoadManager.set_loaded(k1)}} (k);
      this.images[k]["img"].src = this.images[k]["src"];
    }
  }
  this.set_loaded = function(id)
  {
    this.images[id]["complete"] = true;
    this.check_complete();
  }
  this.check_complete = function()
  {
    for (var k in this.images)
    {
      if (!this.images[k]["complete"])
      return;
    }
    clearInterval(this.int);
    for (var k in this.images)
    delete this.images[k];
    this.images_len = 0;
    this.callback();
  }
}
var LoadManager = new _LoadManager();

var on=new Object();
var maxw=new Object();
function set_widths(obj)
{
  var els=obj.getElementsByTagName("a");
  if (!maxw[obj])
    maxw[obj]=0;
  if (maxw[obj]==0)
  {
    for (var k=0;k<els.length;k++)
      if (els[k].offsetWidth>maxw[obj])
        maxw[obj]=els[k].offsetWidth;
  }
   for (var k=0;k<els.length;k++)
    els[k].style.width=maxw[obj]+"px";
}
function show_submenu(id)
{
  if (!document.getElementById("sub_"+id))
    return;
  on[id]=1;
  if (document.getElementById("sub_"+id).style.display!="block")
  {
    document.getElementById("sub_"+id).style.display="block";
    if (/MSIE (5\.5|6\.|7.)/.test(navigator.userAgent))
      set_widths(document.getElementById("sub_"+id));
    if (document.getElementById("menu_"+id).className=="sel")
      document.getElementById("menu_"+id).className="sel1";
    else
      document.getElementById("menu_"+id).className="sel";
  }
}
function hide_submenu(id)
{
  if (!document.getElementById("sub_"+id))
    return;
  on[id]=0;
  setTimeout(function(k) {return function() {try_to_hide_submenu(k)}} (id),40);
}
function try_to_hide_submenu(id)
{
  if (on[id]==0)
  {
    if (document.getElementById("sub_"+id).style.display=="block")
    {
      document.getElementById("sub_"+id).style.display="none";
      if (document.getElementById("menu_"+id).className=="sel1")
        document.getElementById("menu_"+id).className="sel";
      else
        document.getElementById("menu_"+id).className="";
    }
  }
}
function rotate_gchapters(obj)
{
  var dv=document.getElementById("rgchapters");
  if (dv.style.display=="none")
  {
    obj.className="sel";
    dv.style.display="block";
  }
  else
  {
    obj.className="";
    dv.style.display="none";
  }
}
var non=new Object();
function show_news_calendar(id)
{
  if (!document.getElementById("year_"+id))
    return;
  non[id]=1;
  if (document.getElementById("year_"+id).style.display!="block")
  {
    document.getElementById("year_"+id).style.display="block";
    if (document.getElementById("year_"+id).style.left=="")
    {
      document.getElementById("year_"+id).style.left=document.getElementById("year_"+id).offsetLeft+document.getElementById("yurl_"+id).offsetLeft+"px";
      document.getElementById("year_"+id).style.top=document.getElementById("year_"+id).offsetTop-document.getElementById("year_"+id).offsetHeight-10+"px";
    }
    document.getElementById("yurl_"+id).className="sel";
  }
}
function hide_news_calendar(id)
{
  if (!document.getElementById("year_"+id))
    return;
  non[id]=0;
  setTimeout(function(k) {return function() {try_to_hide_calendar(k)}} (id),40);
}
function try_to_hide_calendar(id)
{
  if (non[id]==0)
  {
    if (document.getElementById("year_"+id).style.display=="block")
    {
      document.getElementById("year_"+id).style.display="none";
      document.getElementById("yurl_"+id).className="";
    }
  }
}

var dx=0;
var nlenta_loading=false;
function get_left(el)
{
	var left=el.style.left.substr(0,el.style.left.length-2);
  left=left.replace(/,/,'.')*1;
	return left;
}
function nlenta_next()
{
	if (nlenta_loading)
		return;
	nlenta_loading=true;
	var wr=document.getElementById("nwrap");
	var pg=document.getElementById("npage");
	dx=get_left(pg)-wr.offsetWidth-12;
	if ((dx+pg.offsetWidth-12)<wr.offsetWidth)
		dx=get_left(pg)-(get_left(pg)+pg.offsetWidth-wr.offsetWidth-12);
	setTimeout("nlenta_move()",50);
}
function nlenta_prev()
{
	if (nlenta_loading)
		return;
	nlenta_loading=true;
	var wr=document.getElementById("nwrap");
	var pg=document.getElementById("npage");
	dx=get_left(pg)+wr.offsetWidth+12;
	if (dx>0)
		dx=0;
	setTimeout("nlenta_move()",50);
}
function nlenta_move()
{
	var pg=document.getElementById("npage");
	var step=(dx-get_left(pg))/5;
	if (Math.abs(step)<0.5)
	{
		pg.style.left=dx+"px";
		nlenta_loading=false;
		nlenta_set_nav();
		return;
	}
	pg.style.left=get_left(pg)+step+"px";
	setTimeout("nlenta_move()",50);
}
function nlenta_set_nav()
{
	var wr=document.getElementById("nwrap");
	var pg=document.getElementById("npage");
	if (get_left(pg)<0)
	{
		document.getElementById("nprev").className="nprevs";
		document.getElementById("nprev").onclick=nlenta_prev;
	}
	else
	{
		document.getElementById("nprev").className="nprev";
		document.getElementById("nprev").onclick=function() {};
	}
	if ((get_left(pg)+pg.offsetWidth-12)>wr.offsetWidth)
 {
		document.getElementById("nnext").className="nnexts";
		document.getElementById("nnext").onclick=nlenta_next;
	}
	else
	{
		document.getElementById("nnext").className="nnext";
		document.getElementById("nnext").onclick=function() {};
	}
}
var mpage_loading=false;
var mpage_text;
var mpage_loader;
function mpage_load(id)
{
  if (mpage_loading)
    return;
  mpage_loading=true;
  //mpage_loader=document.createElement("div");
  //mpage_loader.className="mploader";
  //document.body.appendChild(mpage_loader);
  ConnectionManager.get("/request.php","param=1&id="+id,mpage_set);
}
function mpage_set(txt)
{
  var els=txt.getElementsByTagName("block");
  mpage_text=ImageViewer.get_text(els[0]);
  var els=txt.getElementsByTagName("image");
  LoadManager.add(ImageViewer.get_text(els[0]));
  LoadManager.start(mpage_set_all);
}
function mpage_set_all()
{
  document.getElementById("mban_wrap").innerHTML=mpage_text;
  //document.body.removeChild(mpage_loader);
  setTimeout("move_news()",3000);
  mpage_loading=false;
}
var son=new Object();
function select_show(id)
{
  var dv=document.getElementById("drop"+id);
  dv.style.display="block";
	dv.style.top=dv.offsetTop-1+"px";
}
function select_hide(id)
{
  son[id]=0;
  setTimeout("select_try_to_hide("+id+")",30);
}
function select_try_to_hide(id)
{
  if (son[id]==1)
    return;
  var dv=document.getElementById("drop"+id);
  dv.style.display="none";
}
function select_set_val(id,obj,fid,id1)
{
  if (!id1)
    document.getElementById(fid).value=obj.innerHTML;
  else
    document.getElementById(fid).value=id1;
  document.getElementById("select"+id).innerHTML=obj.innerHTML;
  var dv=document.getElementById("drop"+id);
  dv.style.display="none";
}
function input_focus(obj)
{
  if (obj.value==obj.getAttribute("def"))
  {
    obj.value='';
    obj.className="focused";
  }
}
function input_blur(obj)
{
  var def=obj.getAttribute("def");
  if (obj.value=="")
  {
    obj.value=def;
    obj.className="";
  }
}
function select_set_val1(id,obj)
{
  if (id==4)
  {
    if (obj.value!=obj.getAttribute("def"))
      document.getElementById("select5").style.display="block";
    else
      document.getElementById("select5").style.display="none";
    return;
  }
  for (var k=(id+1);k<=5;k++)
    document.getElementById("select"+k).style.display="none";
  document.getElementById("sloading").style.display="block";
  var str='';
  for (var k=1;k<=4;k++)
  {
    if (document.getElementById("select"+k).value==document.getElementById("select"+k).getAttribute("def"))
      continue;
    str+="&val"+k+"="+escape(document.getElementById("select"+k).value);
  }
  ConnectionManager.get("/request.php","param=5&type="+(id+1)+str, set_select1);
}
function set_select1(txt)
{
  document.getElementById("sloading").style.display="none";
  var els=txt.getElementsByTagName("id");
  if (els.length == 0)
    return;
  var id=ImageViewer.get_text(els[0]);
  var els=txt.getElementsByTagName("option");
  if (els.length == 0)
    return;
  var sel=document.getElementById("select"+id);
  sel.options.length=0;
  sel.options[sel.options.length]=new Option(sel.getAttribute("def"),sel.getAttribute("def"));
  for (var k=0;k<els.length;k++)
  {
    sel.options[sel.options.length]=new Option(ImageViewer.get_text(els[k]),ImageViewer.get_text(els[k]));
  }
  document.getElementById("select"+id).style.display="block";
}
function sendform_send()
{
  var dv=document.getElementById("sendform");
  var els=dv.getElementsByTagName("input");
  var str='';
  for (var k=1;k<=4;k++)
    str+="&val"+k+"="+escape(document.getElementById("select"+k).value);
  document.getElementById("sformbutt").childNodes[0].style.visibility="hidden";
  document.getElementById("sformbutt").style.background="url('/img/loading.gif') no-repeat right center";
  ConnectionManager.get("/request.php","param=6&captcha_id="+escape(document.getElementById("captcha_id").value)+"&captcha_code="+escape(document.getElementById("captcha_code").value)+str,sendform_ok);
}
function sendform_send1(sessid)
{
  var email="";
  if (document.getElementById("email").value!=document.getElementById("email").getAttribute("def"))
    email=document.getElementById("email").value;
  var phone="";
  if (document.getElementById("phone").value!=document.getElementById("phone").getAttribute("def"))
    phone=document.getElementById("phone").value;
  if ((email!="") && (!email.match(/^[a-zA-Z0-9_\+-]+(\.[a-zA-Z0-9_\+-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.([a-zA-Z]{2,4})$/)))
  {
    alert("Неверный email!");
    return;
  }
  var str="&email="+escape(email)+"&phone="+escape(phone);
	var tbl=document.getElementById("stable");
	var els=tbl.getElementsByTagName("input");
  var ok=false;
	for (var k=0;k<els.length;k++)
	{
    if (els[k].value==els[k].getAttribute("def"))
      continue;
		var ind=parseInt(els[k].value,10);
		if ((isNaN(ind)) || (ind<=0))
		{
			alert("Неверные показания!");
			return;
		}
		str+="&"+els[k].name+"="+ind;
    ok=true;
	}
  if (!ok)
  {
    alert("Введите показания хотя бы одного счетчика!");
    return;
  }
  document.getElementById("sformbutt").childNodes[0].style.visibility="hidden";
  document.getElementById("sformbutt").style.background="url('/img/loading.gif') no-repeat right center";
  ConnectionManager.get("/request.php","param=2"+str+"&session="+sessid,sendform_ok1);
}
function sendform_ok1(txt)
{
  var els=txt.getElementsByTagName("status");
  if (ImageViewer.get_text(els[0])=="ERROR")
  {
    alert("Не удалось отправить показания. Попробуйте позже.");
    location.href="?a=1";
    return;
  }
  location.href="?do=s3";
}
function sendform_ok(txt)
{
  var els=txt.getElementsByTagName("status");
  if (ImageViewer.get_text(els[0])=="ERROR")
  {
    var els=txt.getElementsByTagName("link");
    document.getElementById("captcha_image").src=ImageViewer.get_text(els[0]);
    var els=txt.getElementsByTagName("id");
    document.getElementById("captcha_id").value=ImageViewer.get_text(els[0]);
    document.getElementById("captcha_code").value=document.getElementById("captcha_code").getAttribute("def");
    document.getElementById("sformbutt").childNodes[0].style.visibility="visible";
    document.getElementById("sformbutt").style.background="none";
    alert("Неверный код!");
    return;
  }
  location.href="?do=s2&session="+ImageViewer.get_text(els[0]);
}
function comm_send(otype)
{
  var dv=document.getElementById("cform");
  var els=dv.getElementsByTagName("input");
  var str="";
  for (var k=0;k<els.length;k++)
  {
    if ((els[k].value=="") || (els[k].value==els[k].getAttribute("def")))
    {
      alert("Все поля обязательны для заполнения!");
      return;
    }
    if (els[k].name=="email")
    {
      if (!els[k].value.match(/^[a-zA-Z0-9_\+-]+(\.[a-zA-Z0-9_\+-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.([a-zA-Z]{2,4})$/))
      {
        alert("Неверный email!");
        return;
      }
    }
    str+="&"+els[k].name+"="+escape(els[k].value);
  }
  var els=dv.getElementsByTagName("textarea");
  for (var k=0;k<els.length;k++)
  {
    if ((els[k].value=="") || (els[k].value==els[k].getAttribute("def")))
    {
      alert("Все поля обязательны для заполнения!");
      return;
    }
    str+="&"+els[k].name+"="+escape(els[k].value);
  }
  document.getElementById("cformbutt").childNodes[0].style.visibility="hidden";
  document.getElementById("cformbutt").style.background="url('/img/loading.gif') no-repeat right center";
  ConnectionManager.get("/request.php","param=4&otype="+otype+str,comm_send_ok);
}
function comm_send_ok(txt)
{
  var els=txt.getElementsByTagName("status");
  if (ImageViewer.get_text(els[0])=="ERROR")
  {
    var els=txt.getElementsByTagName("link");
    document.getElementById("captcha_image").src=ImageViewer.get_text(els[0]);
    var els=txt.getElementsByTagName("id");
    document.getElementById("captcha_id").value=ImageViewer.get_text(els[0]);
    document.getElementById("captcha_code").value=document.getElementById("captcha_code").getAttribute("def");
    document.getElementById("cformbutt").childNodes[0].style.visibility="visible";
    document.getElementById("cformbutt").style.background="none";
    alert("Неверный код!");
    return;
  }
  var els=txt.getElementsByTagName("text");
  alert(ImageViewer.get_text(els[0]));
  location.reload();
}
function load_main_image(obj,id)
{
  if (document.getElementById("nimages"))
    var els=document.getElementById("nimages").getElementsByTagName("img");
  else
    var els=document.getElementById("npage").getElementsByTagName("img");
  for (var k=0;k<els.length;k++)
     if (els[k].className=="curr")
      els[k].className="";
  obj.className="curr";
  document.getElementById("nmain_image").style.background="url('/img/iviewer/iw_loading.gif') no-repeat center center";
  var src=obj.getAttribute("msrc");
  LoadManager.add(src);
  LoadManager.start(function(src1,id1) {return function() {set_main_image(src1,id1)}} (src,id));
}
function set_main_image(src,id)
{
  document.getElementById("nmain_image").style.background="url('"+src+"') no-repeat center center";
  document.getElementById("nmain_image").onclick=function() {ImageViewer.show("/getimages.php?bid=3",id)};
  if (!document.getElementById("nimages"))
    set_pnav();
}
function set_pnav()
{
  var els=document.getElementById("npage").getElementsByTagName("tr");
  var row=els[0];
  var ct=row.cells.length;
  var curr=0;
  for (var k=0;k<ct;k++)
    if (row.cells[k].childNodes[0].className=="curr")
    {
      curr=k+1;
      break;
    }
  if (curr>1)
  {
    document.getElementById("pprev").className="pprevs";
    document.getElementById("pprev").onclick=main_image_prev;
  }
  else
  {
    document.getElementById("pprev").className="pprev";
    document.getElementById("pprev").onclick=function() {};
  }
  if (curr<ct)
  {
    document.getElementById("pnext").className="pnexts";
    document.getElementById("pnext").onclick=main_image_next;
  }
  else
  {
    document.getElementById("pnext").className="pnext";
    document.getElementById("pnext").onclick=function() {};
  }
}
function main_image_change(dx)
{
  var els=document.getElementById("npage").getElementsByTagName("tr");
  var row=els[0];
  var ct=row.cells.length;
  var curr=0;
  for (var k=0;k<ct;k++)
    if (row.cells[k].childNodes[0].className=="curr")
    {
      curr=k;
      break;
    }
  load_main_image(row.cells[curr+dx].childNodes[0],row.cells[curr+dx].childNodes[0].id.substr(3,500));
  var pg=document.getElementById("npage");
  var lct=Math.abs(Math.floor(get_left(pg)/94));
  curr++;
  if ((curr-lct)==5)
    nlenta_next();
  if ((curr-1)<=lct)
    nlenta_prev();
}
function main_image_next()
{
  main_image_change(1);
}
function main_image_prev()
{
  main_image_change(-1);
}
function hide_vacs()
{
  var els=document.getElementById("vacs").getElementsByTagName("div");
  for (var k=0;k<els.length;k++)
    if (els[k].className=="body")
    {
      els[k].style.display="none";
      els[k].parentNode.childNodes[0].childNodes[0].style.color="#999999";
      els[k].parentNode.childNodes[0].childNodes[0].style.fontWeight="normal";
    }
}
function rotate_vac(obj)
{
  var dv=obj.parentNode.parentNode.childNodes[1];
  if (dv.style.display=="none")
  {
    hide_vacs();
    dv.style.display="block";
    obj.style.color="#444444";
    obj.style.fontWeight="bold";
  }
  else
  {
    dv.style.display="none";
    obj.style.color="#999999";
    obj.style.fontWeight="normal";
  }
}
function check_vacform()
{
  var frm=document.forms["vacform"];
  if (frm.file.value!="")
  {
    if (frm.captcha_code.value=="")
    {
      alert("Неверный код!");
      return false;
    }
    return true;
  }
  var dv=document.getElementById("sendform");
  var els=dv.getElementsByTagName("input");
  for (var k=0;k<els.length;k++)
  {
    if ((els[k].value=="") || (els[k].value==els[k].getAttribute("def")))
    {
      if (els[k].hasAttribute("checkit"))
      {
        alert("Поля отмеченные *, обязательны для заполнения!");
        return false;
      }
    }
  }
  var els=dv.getElementsByTagName("textarea");
  for (var k=0;k<els.length;k++)
  {
    if ((els[k].value=="") || (els[k].value==els[k].getAttribute("def")))
    {
      if (els[k].hasAttribute("checkit"))
      {
        alert("Поля отмеченные *, обязательны для заполнения!");
        return false;
      }
      else
        els[k].value="";
    }
  }
  document.getElementById("sformbutt").childNodes[0].style.visibility="hidden";
  document.getElementById("sformbutt").style.background="url('/img/loading.gif') no-repeat right center";
  return true;
}
function send_vacform_fail(src,id)
{
  document.getElementById("captcha_image").src=src;
  document.getElementById("captcha_id").value=id;
  document.getElementById("captcha_code").value=document.getElementById("captcha_code").getAttribute("def");
  document.getElementById("sformbutt").childNodes[0].style.visibility="visible";
  document.getElementById("sformbutt").style.background="none";
  alert("Неверный код!");
}
function send_vacform_ok(txt)
{
  alert("Ваше резюме успешно отправлено!");
  document.getElementById("sformbutt").childNodes[0].style.visibility="visible";
  document.getElementById("sformbutt").style.background="none";
  var dv=document.getElementById("sendform");
  var els=dv.getElementsByTagName("input");
  for (var k=0;k<els.length;k++)
    els[k].value=els[k].getAttribute("def");
  var els=dv.getElementsByTagName("textarea");
  for (var k=0;k<els.length;k++)
    els[k].value=els[k].getAttribute("def");
}
function hide_contacts()
{
  var els=document.getElementById("contacts").getElementsByTagName("div");
  for (var k=0;k<els.length;k++)
  if (els[k].className=="body")
  {
    els[k].style.display="none";
    els[k].parentNode.childNodes[0].childNodes[0].style.color="#3471b2";
    els[k].parentNode.childNodes[0].className="name";
  }
}
function rotate_contact(obj)
{
  var dv=obj.parentNode.parentNode.childNodes[1];
  if (dv.style.display=="none")
  {
    hide_contacts();
    dv.style.display="block";
    obj.style.color="#e55413";
    obj.parentNode.className="name sel";
  }
  else
  {
    dv.style.display="none";
    obj.style.color="#999999";
    obj.parentNode.className="name";
  }
}
function hide_comms()
{
  var els=document.getElementById("comms").getElementsByTagName("div");
  for (var k=0;k<els.length;k++)
  if (els[k].className=="reply")
  {
    els[k].style.display="none";
    els[k].parentNode.childNodes[0].style.color="#444444";
  }
}
function rotate_comm(obj)
{
  var dv=obj.parentNode.childNodes[1];
  if (dv.style.display=="block")
  {
    dv.style.display="none";
    obj.style.color="#444444";
  }
  else
  {
    hide_comms();
    dv.style.display="block";
    obj.style.color="#3471b2";
  }
}
var can_move=true;
var move_dir=1;
function move_news()
{
  if (!can_move)
    return;
  if (move_dir==1)
    var el=document.getElementById("mpnext");
  else
    var el=document.getElementById("mpprev");
  if (el.style.visibility!="hidden")
  {
    el.onclick();
    can_move=true;
  }
  else
  {
    move_dir=(move_dir==1?2:1);
    move_news();
  }
}
function set_year(year,obj)
{
  var els=document.getElementById("efiles_years").getElementsByTagName("a");
  for (var k=0;k<els.length;k++)
    els.item(k).className="";
    obj.className="sel";
  var els=document.getElementById("efiles").getElementsByTagName("div");
  for (var k=0;k<els.length;k++)
  {
    if ((els.item(k).id) && (els.item(k).id.substr(0,5)=="year_"))
      els.item(k).style.display="none";
  }
  document.getElementById("year_"+year).style.display="block";
}
