var fotocount = 0;
var name="gallery"
var num=0;  // line count
var h=100; // height BOX
var step=10; 

var n=0;
var y=0;
var d=0;


function Scroll(){
    document.getElementById(name).style.top = -(n*h+y)+"px";       
    if (d==1){
        //down
        if (y<h) {y=y+step;setTimeout("Scroll()",1);return 1}
        else {n=n+1;d=0;y=h-y;return 1;}
        }
    
    if (d==-1){
        //up
        if (y>-h) {y=y-step;setTimeout("Scroll()",1);return 1;}
        else {n=n-1;d=0;y=y+h;return 1;}
        }
    }
    
function ScrollUp(){
    if ((d==0)&(n>0)){d=-1; Scroll();}
    return 1;
}
    
function ScrollDown(){
    if ((d==0)&(n<num)){d=1; Scroll();}
    return 1;
}

function SetScroll(name_, fotocount_){
    fotocount = fotocount_;
    name = name_;
    if (fotocount <= 6) return 0;
    num= Math.floor(fotocount/2)-3;
    if ((fotocount % 2)>0) num+=1;
    if (num<0) num=0;
    document.write("<div id=\"gallerybtn\">");
    document.write("<input class=\"up\" type=\"button\" onclick=\"ScrollUp()\">");
    document.write("<input class=\"down\" type=\"button\" onclick=\"ScrollDown()\">");
    document.write("</div>");
}

