var mnyscrpause=0;
var mnyscrinterval;
var mnyscrheight;

if (document.getElementById('dir_1')) {
  if (window.addEventListener) {
    window.addEventListener('load',initmnyscr,false);
    window.addEventListener('unload',rm,false);
  } else if(window.attachEvent) {
    window.attachEvent('onload',initmnyscr);
    window.attachEvent('onunload',rm);
  }
}

function initmnyscr() {
  p = document.getElementById('path');
  if ((getWindowWidth()-(findPosX(p) + p.offsetWidth))>100) {
    l1 = document.getElementById('logos');
    l = document.createElement('div');
    p.appendChild(l);
    l.id='lscr';
    l.style.overflow='hidden';
    l.style.display="block";
    l.style.position="absolute";
    l.style.width="100px";
    l.style.top=findPosY(p) +'px';
    l.style.left=findPosX(p) + p.offsetWidth + 12 +'px';
    l.style.height = document.getElementById('dir_1').offsetHeight+'px';
    l.onmouseover=pause;
    l.onmouseout=pause;
    l1.style.display="block";
    l1.style.position="absolute";
    l2 = l1.cloneNode(true);
    l.appendChild(l1);
    l.appendChild(l2);
    l1.style.top=p.offsetTop + 'px';
    l2.style.top=l1.offsetTop+l1.offsetHeight + 'px';
    if (!(c=document.getElementById('scrc'))) {
      i = document.createElement('img');
      i.id="scrc";
      i.style.position="absolute";
      i.style.width="12px";
      i.style.height="12px";
      i.src="/d/direct/i/x.gif";
      i.onmousedown=rm;
      p.appendChild(i);
    }
    i.style.top=findPosY(p) + (p.offsetHeight-i.offsetHeight)/2 + 'px';
    i.style.left=findPosX(p) + p.offsetWidth + 'px';
    if (window.addEventListener) {
      window.addEventListener('resize',fixscr,false);
    } else if(window.attachEvent) {
      window.attachEvent('onresize',fixscr);
    }
    setTimeout("start()",3000);
  }
}
function start() {
  mnyscrinterval = setInterval("scroll()",20);
}
function pause() {
  mnyscrpause = 1 - mnyscrpause;
}

function fixscr() {
  p = document.getElementById('path');
  if ((getWindowWidth()-(findPosX(p) + p.offsetWidth))>112) {
    l = document.getElementById('lscr');
    i = document.getElementById('scrc');
    i.style.top=findPosY(p) +'px';
    i.style.left=findPosX(p) + p.offsetWidth + 'px';
    l.style.top=findPosY(p) +'px';
    l.style.left=findPosX(p) + p.offsetWidth + 12 +'px';
  } else {
    rm();
  }
}

function rm() {
  clearInterval(mnyscrinterval);
  if (e=document.getElementById('scrc')) document.getElementById('path').removeChild(e);
  if (e=document.getElementById('lscr')) document.getElementById('path').removeChild(e);
  if (window.removeEventListener) {
    window.removeEventListener('load',initmnyscr,false);
    window.removeEventListener('resize',fixscr,false);
  } else if(window.detachEvent) {
    window.detachEvent('onload',initmnyscr);
    window.detachEvent('onresize',fixscr);
  }
}

function scroll() {
  if (mnyscrpause==0) {
    if (c = document.getElementById('lscr')) {
      for (i=0;i<c.childNodes.length;i++) {
        node = c.childNodes[i];
        node.style.top = node.offsetTop-1 + 'px';
        c.style.height = document.getElementById('dir_1').offsetHeight+'px';
        if ((findPosY(node)+node.offsetHeight)<findPosY(c)) {
          if (i==0) {
            node.style.top = (c.lastChild.offsetTop+c.lastChild.offsetHeight) + 'px';
          } else {
           node.style.top = (c.childNodes[i-1].offsetTop+c.childNodes[i-1].offsetHeight) + 'px';
          }
        }
      }
    }
  }
}

function getWindowHeight (){
  if (window.innerHeight) return window.innerHeight;
  else if (document.documentElement) {
    return document.documentElement.clientHeight;
  }
  else return document.body.clientHeight;
}

function getDocumentHeight() {
  if (document.body.scrollHeight) return document.body.scrollHeight;
  if (document.height) return document.height;
  if (document.body.style.pixelHeight) return document.body.style.pixelHeight;
}

function getWindowWidth() {
  if (window.innerWidth) return window.innerWidth;
  else if (document.documentElement) return document.documentElement.clientWidth;
  else return document.body.clientWidth;
}

function findPosY(obj) {
  var curtop = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curtop += obj.offsetTop
          obj = obj.offsetParent;
    }
  } else if (obj.y) curtop += obj.y;
  return curtop;
}

function findPosX(obj) {
  var curleft = 0;
  if (obj.offsetParent)   {
    while (obj.offsetParent)     {
      curleft += obj.offsetLeft
          obj = obj.offsetParent;
    }
  } else if (obj.x) curleft += obj.x;
  return curleft;
}
