speed = 6;
initPos = 0;
bottomStop = 0;
topStop = -250;
rightStop = -5;
leftStop = -250;

function stop(){
	 clearInterval(SCROLL)
}

function startVertical(move, layer){
	 move2 = move*speed
	 layer2 = layer;
	 SCROLL = setInterval('scrollVertical(move2, layer2)',50)
}

function startHorizontal(move){
	 move2 = move*speed
	 SCROLL = setInterval('scrollHorizontal(move2)',50)
}

function scrollDifVertical(direction, diff, layer) {
   topStop = getHeight(layer);
   topStop = (topStop - diff) * -1;
   startVertical(direction, layer);
}

function scrollDifHorizontal(direction, diff) {
   leftStop = getWidth();
   leftStop = (leftStop - diff) * -1;
   startHorizontal(direction);
}

function scrollVertical(direction, layer){
         objekt = getElement(layer);
		 var layerTopPosition = initPos + direction;
		 
		 if(NN6) {
  			layerTopPosition += "px";
  		};
		 
         if ((initPos>topStop) && (initPos<bottomStop)) {
	      objekt.top = layerTopPosition;
	      initPos = initPos + direction;
	}
	if (initPos<=topStop) initPos = topStop+1;
	if (initPos>=bottomStop) initPos = bottomStop-1;
}

function scrollHorizontal(direction){
         objekt = getElement('scroller');
		 var layerLeftPosition = initPos + direction;
		 
		 if(NN6) {
  			layerLeftPosition += "px";
  		};
		 
         if ((initPos>leftStop) && (initPos<rightStop)) {
	      objekt.left = layerLeftPosition;
	      initPos = initPos + direction;
	}
	if (initPos<=leftStop) initPos = leftStop+1;
	if (initPos>=rightStop) initPos = rightStop-1;
}

function getHeight(layer) {
    myHeight = 0;
    if(NN6) {eval('myHeight = document.getElementById("'+layer+'").offsetHeight');} 
    if(NN4) {eval('myHeight = document.layers["scrollerDiv"].document.layers["'+layer+'"].document.height');} 
    if(IE)  {eval('myHeight = document.all["'+layer+'"].offsetHeight');} 
    return myHeight;
}

function getWidth() {
    myWidth = 0;
    if(NN6) {myWidth = document.getElementById("scroller").offsetWidth;} 
    if(NN4) {myWidth = document.layers["scrollerDiv"].document.layers["scroller"].document.width;} 
    if(IE)  {myWidth = document.all["scroller"].offsetWidth;} 
    return myWidth;
}

