var pathArray  = new Array();
var ie55 = window.createPopup;
var slideSpeed = 1400;                      
var imageArray = new Array();
var imageIndex = 0;
var pixelDelay = 0;
var slideWidth = 145;
var slideHeight = 55;


function initSlide() {
  if( !document.getElementById )
    return;
  
  if( ie55 )
   pixelDelay = document.getElementById("slideTable").filters[0].duration * 1000;
  
  if( pathArray.length > 0 ) {
    for( i=0; i < pathArray.length; i++ ) {
      imageArray[i] = new Image();
      imageArray[i].src = pathArray[i];
    }
    slideReferences();
  }
}


function slideReferences() {
  if( ie55 )
    document.getElementById("slideTable").filters[0].apply();

  if( (imageArray[imageIndex].width > slideWidth) || (imageArray[imageIndex].height > slideHeight) ) {
    var aspect = imageArray[imageIndex].width/imageArray[imageIndex].height;

    if( aspect >= 1 ) {
      if( Math.round(slideWidth/aspect) <= slideHeight ) {
        document.images.reference.width = slideWidth;
        document.images.reference.height = Math.round(slideWidth/aspect);
      } else {
        document.images.reference.height = slideHeight;
        document.images.reference.width = Math.round(slideHeight*aspect);
      }
    } else {
      if( Math.round(slideHeight*aspect) <= slideWidth ) {
        document.images.reference.height = slideHeight;
        document.images.reference.width = Math.round(slideHeight*aspect);
      } else {
        document.images.reference.width = slideWidth;
        document.images.reference.height = Math.round(slideWidth/aspect);
      }
    }
  } else {
    document.images.reference.width = imageArray[imageIndex].width;
    document.images.reference.height = imageArray[imageIndex].height;
  }

  document.images.reference.src=imageArray[imageIndex].src;

  if( ie55 )
    document.getElementById("slideTable").filters[0].play();

  if( imageIndex < imageArray.length-1 )
    imageIndex++;
  else
    imageIndex = 0;
  setTimeout( "slideReferences()", slideSpeed+pixelDelay );
}
