var index = 1;
var countDivs = 0;

function setCount(co) {
    countDivs = co;
    updateLinks();
}

function showImage(id) {
    hideAll();
    var idtemp = "foto_" + id; 
    document.getElementById(idtemp).style.display = '';
    index = id;
    updateLinks();
}

function showNext() {
    hideAll();    
    idNext = index + 1;
    var idtemp = "foto_" + idNext;
    document.getElementById(idtemp).style.display = '';
    index = idNext;
    updateLinks();
    
}

function showPrevious() {
    hideAll();
    idPrevious= index - 1;
    var idtemp = "foto_" + idPrevious;
    document.getElementById(idtemp).style.display = '';
    index = idPrevious;
    updateLinks();
}

function hideAll() {
    for (i=1;i<countDivs+1;i++){
        document.getElementById("foto_" + i).style.display = 'none';
    }   
    
}

function updateLinks() {
    if (index == countDivs) {
        document.getElementById('next').style.display = 'none';
        document.getElementById('previous').style.display = '';
    } else {
        if (index == 1 && countDivs > 0) {
            document.getElementById('next').style.display = '';
            document.getElementById('previous').style.display = 'none';
        }
        else {
            if (countDivs == 0) {
                document.getElementById('next').style.display = 'none';
                document.getElementById('previous').style.display = 'none'; 
            } 
            else {
                document.getElementById('next').style.display = '';
                document.getElementById('previous').style.display = ''; 
            }
        }
    }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
        