﻿var currentImage;


function ShowGalleryImage(galleryCaption, galleryImage){
    
    
    var oImage = document.getElementById("GalleryImage");
    var oCaption = document.getElementById("GalleryCaption");
    
    var oGallery = document.getElementById("GalleryPanelContainer");

    oImage.src = "image/loading.gif"
    
    //Set the caption
    oCaption.innerHTML = galleryCaption;
    
    currentImage = oImage;
    
    //Set the image and display when loaded
    currentImage.src = "image/full_size/" + galleryImage;    
    currentImage.onload = function() { displayImage(); }

}


function displayImage(){

  var oGallery = document.getElementById("GalleryPanelContainer");
  
  var usefulWidth = 0;
  var usefulHeight = 0;
  
  if(document.documentElement){
      usefulWidth = document.documentElement.offsetWidth;
      usefulHeight = document.documentElement.offsetHeight;
  }
  else{
      usefulWidth = document.body.offsetWidth;
      usefulHeight = document.body.offsetHeight;
  }
  
  if(usefulWidth > 0 && document.all){
      var leftPos = ((usefulWidth - oGallery.offsetWidth)/2);
      oGallery.style.left = leftPos + "px";
  }
  
  //Show the panel
  oGallery.style.display = "block";   
  

  if(usefulHeight > 0 && document.all){
      var topPos = ((usefulHeight - oGallery.offsetHeight)/2);
      oGallery.style.top = topPos + "px";        
  }
  
 
 

}


function HideGallery(){

    var oGallery = document.getElementById("GalleryPanelContainer");
    oGallery.style.display = "none";
    return false;

}
