/*
function expandPhoto(photo, galleryId, width, height){
  var img = document.getElementById('bigPhoto' + galleryId);
  var container = img.parentNode;
  var ratio = width / height;

  var containerWidth = container.offsetWidth;
  var containerHeight = container.offsetHeight;

  var containerRatio = container.offsetWidth/ container.offsetHeight;

  img.src = '';
  
  if(containerRatio > ratio){
    img.style.width = containerWidth + 'px';
    img.style.height = containerWidth / ratio + 'px';
    img.style.marginTop = (container.offsetHeight - container.offsetWidth / ratio)/2 + 'px';
    img.style.marginLeft = ''; 
  } else {
    var newWidth = containerHeight*ratio;
    var newHeight = containerHeight;   
    img.style.height = newHeight + 'px';
    img.style.width = newWidth + 'px';
    img.style.marginLeft = (container.offsetWidth - container.offsetHeight*ratio)/2 + 'px';
    img.style.marginTop = ''; 
  }
  
  img.src=photo;
  return false;
}
*/

function expandPhoto(photoId, galleryId){
  var i = 0;
  var tmpContainer;
  while(tmpContainer = document.getElementById('bigPhoto' + galleryId + '-' + i)){
    tmpContainer.style.display = 'none';
    i++;    
  }

  var i = 0;
  var tmpPhoto;
  while(tmpPhoto = document.getElementById('smallPhoto' + galleryId + '-' + i)){
    tmpPhoto.className = '';
    i++;    
  }
  
  
  var smallPhoto = document.getElementById('smallPhoto' + galleryId + '-' + photoId);
  smallPhoto.className = 'current';
  

  var container = document.getElementById('bigPhoto' + galleryId + '-' + photoId);
  container.style.display = 'block';
  
  return false;
}
