/*
This file is part of Jar Of Green Photo Management Gallery
Copyright (C) 2005-2007 James Baster (james at jarofgreen dot co dot uk)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


var shown = '';
var picture = '';
var pictureOriginalHeight = 0;
var pictureOriginalWidth = 0;

function setupShowHide() {
  
  picture = document.getElementById('picture');
  if (picture) {
    pictureOriginalHeight = picture.height;
    pictureOriginalWidth = picture.width;
  }
}

function toggle(name) {
  if (shown == name) { 
    hide(name);
    growImage();
    shown = ''
  } else {
    if (shown == '') {
      shrinkImage();
    } else {
      hide(shown);
    }
    show(name);
    shown = name;
  }
}

function hide(name) {
  var ele = document.getElementById(name);
  ele.style.display = "none";
  var label = document.getElementById(name + '-label');
  label.innerHTML = "Show";
}

function show(name) {
  var ele = document.getElementById(name);
  ele.style.display = "block";
  var label = document.getElementById(name + '-label');
  label.innerHTML = "Hide";
}

function shrinkImage() {
  if (pictureOriginalHeight > 0) {
    picture.height = pictureOriginalHeight  / 2;
    picture.width = pictureOriginalWidth / 2;
  }
}

function growImage() {
  if (pictureOriginalHeight > 0) {
    picture.height = pictureOriginalHeight;
    picture.width = pictureOriginalWidth;
  }
}

