// Photo Gallery Load script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004-2006 http://www.cryer.co.uk/.
// Script is free to use provided this copyright header is included.

var currentGalleryLink = new Array();

function LoadPicture(pictureName,imageFile,titleID,titleText,captionID,captionText)
{
 if (document.all)
 {
//  document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
//  document.getElementById(pictureName).filters.blendTrans.Apply();
 }

 document.getElementById(pictureName).src = imageFile;
 if (document.all)
 {
//  document.getElementById(pictureName).filters.blendTrans.Play();
 }
 document.getElementById(titleID).innerHTML=titleText;
 document.getElementById(captionID).innerHTML=captionText;

 // Which link is currently selected?
 for (q=0; q < document.links.length;q++)
 {
  var l=document.links[q];
  var n=l.getAttributeNode('onclick');
  if (n)
  {
   var onclick = n.value;
   if ((onclick) && (onclick.indexOf(pictureName) > 0) && (onclick.indexOf(imageFile) > 0))
   {
    currentGalleryLink[pictureName] = q;
    break;
   }
  }
 }
}

function LoadPrev(pictureName)
{
 var current = currentGalleryLink[pictureName];
 if (current == null) current = document.links.length+1;
 var alt = null;
 for (q=document.links.length-1;q>0;q--)
 {
  var link=document.links[q];
  var node = link.getAttributeNode('onclick');
  if (node)
  {
   var onclick = node.nodeValue;
   if ((onclick) && (onclick.indexOf('LoadPicture') >= 0) && (onclick.indexOf(pictureName) > 0))
   {
    if (q < current)
    {
     eval(onclick);
     return;
    } else if (alt == null)
     alt = onclick;
   }
  }
 }
 if (alt) eval(alt);
}

function LoadNext(pictureName)
{
  var current = currentGalleryLink[pictureName];
  if (current == null)
  {
   currentGalleryLink[pictureName]=-1;
   LoadNext(pictureName);
   current = currentGalleryLink[pictureName];
  }
  var alt = null;
 for (q=0;q<document.links.length;q++)
 {
  var link = document.links[q];
  var node = link.getAttributeNode('onclick');
  if (node)
  {
   var onclick = node.value;
   if ((onclick) && (onclick.indexOf('LoadPicture') >= 0) && (onclick.indexOf(pictureName) > 0))
   {
    if (q > current)
    {
     eval(onclick);
     return;
    } else if (alt == null)
     alt = onclick;
   }
  }
 }
 if (alt)
 {
  eval(alt);
 }
}

