/* This script replaces images when a box is clicked. */

function imageChange(imageName, Image1, Image2, toggleContainer) {

  // Finds the image to be replaced within the document.
  var myImage = document.getElementById(imageName);
  
  // Gets the current height of the box (string with a 'px' in the end).
  var strCurrentBoxHeight = document.getElementById(toggleContainer).style.height;
  
  // Converts it to integer
  var intCurrentBoxHeight = parseInt(strCurrentBoxHeight.substring(0,strCurrentBoxHeight.length - 2));

  // If the box height is greater than zero, script will load back the first image. Else, it will load the new image
  if(intCurrentBoxHeight > 0) {
    myImage.src = Image1;
  }
  else {
    myImage.src = Image2;
  }
}