﻿function swapImg(imageid, namesVec, root){
    ima = document.getElementById(imageid)
    // divides the path
    nr = ima.getAttribute('src').split('/');
    // gets the last part of path, ie name
    nr = nr[nr.length-1]
     
    for (i=0;i<namesVec.length;i++) {
        if(nr==namesVec[i]){
            if (i < namesVec.length-1) {
                ima.setAttribute('src',root+namesVec[i+1]);
            }
            else
            {
                ima.setAttribute('src',root+namesVec[0]);
            }
        }
    }
}