﻿var picturesArr = new Array();
var firstPictureIndex = 0;
var lastPictureIndex = 0;

if ( picturesArr != null && picturesArr.length > 2 ) {
    firstPictureIndex = 0;
    lastPictureIndex = 1;    
}

function movePictureUp() {
    if ( picturesArr != null && picturesArr.length > 2 ) {
        if ( lastPictureIndex + 2 < picturesArr.length ) {
             firstPictureIndex +=2;
             lastPictureIndex +=2;               
        } else {
            firstPictureIndex = 0;
            lastPictureIndex = 1;            
        }
        RenderPictures();
    }
}

function movePictureDown() {
    if ( picturesArr != null && picturesArr.length > 2 ) {
        if ( firstPictureIndex > 1 ) {
             firstPictureIndex -= 2;
             lastPictureIndex -=2;  
        } else {
            firstPictureIndex = picturesArr.length - 2;
            lastPictureIndex = picturesArr.length - 1;            
        }
        RenderPictures();
    }
}

function RenderPictures() {
    var pict1Obj = document.getElementById('pict1');
    var pict2Obj = document.getElementById('pict2');
    if ( pict1Obj != null ) {
        pict1Obj.src = picturesArr[firstPictureIndex];
    }
    if ( pict2Obj != null ) {
        pict2Obj.src = picturesArr[lastPictureIndex];
    }

}



