function previous(countpics,picid){

  var imagesource = document.getElementById('pic'+picid).src;
  
  
  //Get length of image source. Remove 5 characters from end, since name of file is 5 characters from end (i.e. abc/X.png) 
  var imagesourcelength = imagesource.length - 5;
  
  //current image
  var currentpic = parseFloat(imagesource.charAt(imagesourcelength));

  if(currentpic == "1"){
      document.getElementById('pic'+picid).src = imagesource.replace("1.png", countpics + ".png");
    }else{
      document.getElementById('pic'+picid).src = imagesource.replace(currentpic + ".png", currentpic-1 + ".png");
    }


}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////



function next(countpics,picid){

  var imagesource = document.getElementById('pic'+picid).src;
  
  //Get length of image source. Remove 5 characters from end, since name of file is 5 characters from end (i.e. abc/X.png) 
  var imagesourcelength = imagesource.length - 5;
  
  //current image
  var currentpic = parseFloat(imagesource.charAt(imagesourcelength));

  if(currentpic == countpics){
      document.getElementById('pic'+picid).src = imagesource.replace(currentpic + ".png", "1.png");
    }else{
      document.getElementById('pic'+picid).src = imagesource.replace(currentpic + ".png", (currentpic+1) + ".png");
    }
    
}
