window.setInterval( rotateHeaders, 4000 );

function rotateHeaders() {
  var h1 = document.getElementById( 'head_img_1' );
  var h2 = document.getElementById( 'head_img_2' );
  
  var h1src = h1.getAttribute( 'src' );
  var num = h1src.substr( h1src.lastIndexOf( '-' ) + 1, 1 );
  
  // Generate the number
  num = parseInt( num );
  if ( !isNaN( num ) ) {
    ++num;
    
    if ( num > 7 )
      num = 1;
    if ( num < 1 )
      num = 1;
  }
  
  // Create the images
  var tmp1 = new Image();
  var tmp2 = new Image();
  
  tmp1.src = h1src.substring( 0, h1src.lastIndexOf( '-' ) + 1 ) + num + 'A.jpg';
  tmp2.src = h1src.substring( 0, h1src.lastIndexOf( '-' ) + 1 ) + num + 'B.jpg';
  
  // Assign
  h1.src = tmp1.src;
  h2.src = tmp2.src;
}