var CrossFadeDuration = 0.5;
var PageLoaded = false;
var preLoad = new Array();
var CurrentPhoto = 0;
var PhotoCount = Picture.length-1;
function control(action,id)
{
  if (PageLoaded)
  {
    document.getElementById("photo_loading").className = 'show';
    if (action=="home") CurrentPhoto = 1;
    if (action=="next") CurrentPhoto = CurrentPhoto + 1;
    if (action=="prev") CurrentPhoto = CurrentPhoto - 1;
    if (action=="goto") CurrentPhoto = DefaultImagePos;
    if (CurrentPhoto > (PhotoCount)) CurrentPhoto = 1;
    if (CurrentPhoto < 1) CurrentPhoto = PhotoCount;
    if (preLoad[CurrentPhoto])
    {
      PreLoadImage();
    }
    else
    {
      preLoad[CurrentPhoto] = new Image();
      preLoad[CurrentPhoto].src = Picture[CurrentPhoto];
      preLoad[CurrentPhoto].onLoad = PreLoadImage();
    }
  }
}
function PreLoadImage()
{
  document.images.PictureTemp.src = preLoad[CurrentPhoto].src;
}
function FadeImages()
{
  if (document.all && document.images.PictureBox && document.images.PictureBox.filters)
  {
    document.images.PictureBox.style.filter = "blendTrans(duration=" + CrossFadeDuration + ")";
    document.images.PictureBox.filters.blendTrans.Apply();
  }
  if (document.images.PictureBox)
  {
    document.images.PictureBox.src = document.images.PictureTemp.src;
  }
  if (document.getElementById)
  {
    if (document.getElementById("CurrentItemBox")) document.getElementById("CurrentItemBox").innerHTML = Caption[CurrentPhoto];
    if (document.getElementById("TotalItemsBox")) document.getElementById("TotalItemsBox").innerHTML = PhotoCount;
    if (document.getElementById("InfoBox")) document.getElementById("InfoBox").className = 'show';
  }
  if (document.all && document.images.PictureBox && document.images.PictureBox.filters)
  {
    document.images.PictureBox.filters.blendTrans.Play();
  }
}
function AfterPhotoLoad()
{
  FadeImages();
  document.getElementById("photo_loading").className = 'hide';
}
