p = document.getElementById('page');
c = document.getElementById('content');
t = document.getElementById('text');
g = document.getElementById('galery');
background1 = 'white url(style1/tapeta.jpg) -761px -118px no-repeat'; // left top
background2 = 'white url(style1/tapeta.jpg) -252px -466px no-repeat';
m = null;
var iurl;

function newwin(a) {
  if(a) {
    iurl = a.href;
    w = window.open('img.html', 'medianaimage', 'width=610,height=630');
  }
  return false;
}

function scroll( bName, v, s) {
  o = document.getElementById(bName);
  if(v) {o.scrollTop = o.scrollTop + s}
  else {o.scrollLeft = o.scrollLeft + s}
  m = window.setTimeout('scroll("'+bName+'", '+v+', '+s+')', 20);
}

function setScroll( o, bName, v, s) {
  o.style.cursor = 'pointer';
  o.onmousedown = function(){m = window.setTimeout('scroll("'+bName+'", '+v+', '+s+')', 1)}
  o.onmouseup = function(){window.clearTimeout(m)}
}

dtb = document.createElement('div');
dtb.style.position = 'absolute';
dtb.style.top = '0';
dtb.style.right = '-3px';
dtb.style.height = '100%';
dtb.style.background = background1;
//dtb.style.border = '1px solid red';
t.appendChild(dtb);

ist = document.createElement('img');
ist.setAttribute('src', 'img/strzalka4.gif');
ist.width = ist.width * 0.7;
ist.height = ist.height * 0.7;
ist.style.position = 'relative';
ist.style.top = '-7px';
setScroll( ist, 'text', true, -3);
dtb.appendChild(ist);

isb = document.createElement('img');
isb.setAttribute('src', 'img/strzalka2.gif');
isb.width = isb.width * 0.7;
isb.height = isb.height * 0.7;
isb.style.position = 'absolute';
isb.style.bottom = '-3px';
isb.style.left = '0';
setScroll( isb, 'text', true, 3);
dtb.appendChild(isb);

if(g) {
  dlr = document.createElement('div');
  dlr.style.position = 'absolute';
  dlr.style.bottom = '-133px';
  dlr.style.left = '0';
  dlr.style.width = '475px';
  dlr.style.background = background2;
  t.appendChild(dlr);
  
  isl = document.createElement('img');
  isl.setAttribute('src', 'img/strzalka3.gif');
  isl.width = ist.width * 1;
  isl.height = ist.height * 1;
  isl.style.position = 'relative';
  isl.style.left = '-7px';
  setScroll( isl, 'galery', false, -3);
  dlr.appendChild(isl);
  
  isr = document.createElement('img');
  isr.setAttribute('src', 'img/strzalka1.gif');
  isr.width = ist.width * 1;
  isr.height = ist.height * 1;
  isr.style.position = 'absolute';
  isr.style.top = '0';
  isr.style.right = '-7px';
  setScroll( isr, 'galery', false, 3);
  dlr.appendChild(isr);
}

function showArrows() {
  a = t.scrollTop;
  t.scrollTop = t.scrollTop + 1;
  dtb.style.visibility = (t.scrollTop>0)?'visible':'hidden';
  t.scrollTop = a;
  
  a = g.scrollLeft;
  g.scrollLeft = g.scrollLeft + 1;
  dlr.style.visibility = (g.scrollLeft>0)?'visible':'hidden';
  g.scrollLeft = a;
}

showArrows();

