// Script to support the dynamic images available through the GetPhoto.aspx page.
//
// The images must have the following events defined for them to be removed when the image
// does not exist:
//  onload="DynImgLoaded(this)" onerror="DynImgHide(this)"
//
// Author:  OrdinaSoft
//          Patrick Lanz
//          Lausanne
//
// First version: October 16, 2005

var
  DynImages = [],
  DynImgTags = [],
  DynNbImages = 0;

function DynImgHide (Item) {
  Item.style.display = 'none';
}

function CheckDynImg (id) {
  if (DynImages [id].width) {
    if (DynImages [id].width <= 2)
      DynImgHide (DynImgTags [id])
  }
  else setTimeout ('CheckDynImg(' + id + ')', 100);
}

function DynImgLoaded (Item) {
  var
    id = ++DynNbImages;
  DynImgTags [id] = Item;
  DynImages [id] = new (Image);
  DynImages [id].src = Item.src;
  setTimeout ('CheckDynImg(' + id + ')', 50);
}