var while_images_total = 4;
var luminosity_images_total = 3;
var respirator_images_total = 5;
var yesterdays_images_total = 5;


function extract_zine_image_no(fullpath)
{
  var last_slash;
  var filename;

  last_slash = fullpath.lastIndexOf("/");
  filename   = fullpath.substring(last_slash + 3, fullpath.length - 4);
  return filename;
}


function change_zine_image(set)
{
  //Get current image number
  var current_image_no     = extract_zine_image_no(document.getElementById(set + '_image_holder').src);
  var current_image_total;
  var image_name;

  //Get the set's total image count
  if (set == "lu") {
    current_image_total = luminosity_images_total;
  }
  else if (set == "re") {
    current_image_total = respirator_images_total;
  }
  else if (set == "ye") {
    current_image_total = yesterdays_images_total;
  }
  else if (set == "wh") {
    current_image_total = while_images_total;
  }

  //Not yet on the last one?
  if ((parseInt(current_image_no) + 1) <= parseInt(current_image_total)) {
    image_name                                         = parseInt(current_image_no) + 1 + '.jpg';
    document.getElementById(set + '_image_holder').src = 'http://www.quietcorners.com/general/images/resize.jpg';   //Fix safari resize bug
    document.getElementById(set + '_image_holder').src = 'http://www.quietcorners.com/zines_imgs/' + set + image_name;
  }
  else {
    image_name                                         = '1.jpg';
    document.getElementById(set + '_image_holder').src = 'http://www.quietcorners.com/general/images/resize.jpg';   //Fix safari resize bug
    document.getElementById(set + '_image_holder').src = 'http://www.quietcorners.com/zines_imgs/' + set + image_name;
  }
}

