Slideshow JavaScript: Control Bar

function gtJSUI_generateControlBar(parentObject, setID, slideTotal) {

  var controlBar;
  var controlObj;

  /* Create a Previous Slide Button */
  controlBar = document.createElement('DIV');
  controlBar.className = 'gtSlideshowControlBar';

  controlObj = document.createElement('BUTTON');
  controlObj.className = 'gtSlideshowControlButton';
  controlObj.setAttribute('data-direction', 'prev');
  controlObj.setAttribute('data-slideshow', setID);
  controlObj.addEventListener('click', function () { gtJSUI_changeSlide(this); }, false);

  textObj = document.createElement('I');
  textObj.className = 'svg-leftarrow';
  textObj.setAttribute('aria-hidden', 'true');
  controlObj.appendChild(textObj);

  textObj = document.createElement('SPAN');
  textObj.innerHTML = 'Previous Slide';
  controlObj.appendChild(textObj);

  controlBar.appendChild(controlObj);

  /* Create a Live Region for Displaying the Current Slide Status */
  controlObj = document.createElement('SPAN');
  controlObj.id = 'gtSlideshowStatus_' + setID;
  controlObj.innerHTML = 'Slide 1 of ' + slideTotal;
  controlObj.setAttribute('aria-live', 'polite');
  controlObj.setAttribute('aria-atomic', 'true');
  controlBar.appendChild(controlObj);

  /* Create a Next Slide Button */
  controlObj = document.createElement('BUTTON');
  controlObj.className = 'gtSlideshowControlButton';
  controlObj.setAttribute('data-mode', 'next');
  controlObj.setAttribute('data-slideshow', setID);
  controlObj.addEventListener('click', function () { gtJSUI_changeSlide(this); }, false);

  textObj = document.createElement('I');
  textObj.className = 'svg-rightarrow';
  textObj.setAttribute('aria-hidden', 'true');
  controlObj.appendChild(textObj);

  textObj = document.createElement('SPAN');
  textObj.innerHTML = 'Next Slide';
  controlObj.appendChild(textObj);

  controlBar.appendChild(controlObj);

  parentObject.appendChild(controlBar);

}