function loadImage( $key ) {
  if ( $key < 0 ) {
    $key = $picturesList[ 0 ].length - 1;
  }
  if ( $key === $picturesList[ 0 ].length ) {
    $key = 0;
  }
  $actualKey                                                     = $key;
  window.document.getElementById( 'previewImage' ).src           = $picturesList[ 0 ][ $actualKey ];
  window.document.getElementById( 'ctIMGDescription' ).innerHTML = $picturesList[ 1 ][ $actualKey ];
}

function slideshow(  ) {
  if ( $slideshowInterval ) {
    window.clearInterval( $slideshowInterval );
    $slideshowInterval                                  = null;
    window.document.getElementById( 'buttonPlay0' ).src = $templateImagePath + 'bttPlay.gif';
    window.document.getElementById( 'buttonPlay1' ).src = $templateImagePath + 'bttPlay.gif';
  }
  else {
    $slideshowInterval = window.setInterval( 'loadImage( $actualKey + 1 )', 3000 );
    window.document.getElementById( 'buttonPlay0' ).src = $templateImagePath + 'bttPause.gif';
    window.document.getElementById( 'buttonPlay1' ).src = $templateImagePath + 'bttPause.gif';
  }
}

$slideshowInterval = null;
$actualKey         = 0;
