var gcurrent_photo = 0;
var gtotal_photo = 0;

function init_globals(total) {

  gcurrent_photo = 0;
  gtotal_photo = total;
}

function turn_on_div(pid, total) {

  var pon = "photo_" + pid;
  var poff;

  for (i = 0; i < total; i++) {

    poff = "photo_" + i;
    document.getElementById(poff).style.display='none';
  }

  if (pid == "") {

    document.getElementById('photo_0').style.display='block';
    gcurrent_photo = 0;

  } else {

    document.getElementById(pon).style.display='block';
    gcurrent_photo = pid;
  }
}

function next_photo() {

  var pid = gcurrent_photo + 1;

  if (pid >= gtotal_photo) { pid = 0; }

  turn_on_div(pid, gtotal_photo);
}

function previous_photo() {

  var pid = gcurrent_photo - 1;

  if (pid < 0) { pid = gtotal_photo - 1; }

  turn_on_div(pid, gtotal_photo);
}
