﻿var currentImage;


function ShowGalleryImage(galleryCaption, galleryDescription, galleryImagePath, isRight){
    
    var oImage = document.getElementById("GalleryImage");
    
    var oCaption = document.getElementById("GalleryCaption");
    
    var oDescription = document.getElementById("GalleryDescription");
    
    var oGallery = document.getElementById("GalleryPanelContainer");
    
    if(isRight)
    {
      oCaption = document.getElementById("GalleryCaptionRight");
      oDescription = document.getElementById("GalleryDescriptionRight");
    }
    
    if(!isRight){
    oImage.src = "image/loading.gif"
    }
    
    //Set the caption
    oCaption.innerHTML = galleryCaption;
    oDescription.innerHTML = unescape(galleryDescription);
    
    currentImage = oImage;
    
    //Set the image and display when loaded
    currentImage.src = galleryImagePath;    
    currentImage.onload = function() { displayImage(); }

}


function displayImage(){

  var oGallery = document.getElementById("GalleryPanelContainer");
  
  var usefulWidth = 680;
  var usefulHeight = 0;
  
  if(document.documentElement){
      usefulHeight = (document.documentElement.offsetHeight - oGallery.offsetHeight - 400)/2 + document.documentElement.scrollTop;
  }
  else if (document.all){
      usefulHeight = (document.body.offsetHeight - oGallery.offsetHeight - 400)/2 + document.body.scrollTop;
  }
  else{
      usefulHeight = (document.body.offsetHeight - oGallery.offsetHeight)/2 + window.pageYOffset;
  }
  
  //Show the panel
  oGallery.style.display = "block";
  
  var leftPos = parseInt(((screen.availWidth) - (usefulWidth))/2);
  oGallery.style.left = leftPos + "px";
  
  oGallery.style.top = usefulHeight + "px";        

}


function HideGallery(){

    var oGallery = document.getElementById("GalleryPanelContainer");
    oGallery.style.display = "none";
    return false;

}