function openImagePopup(imageURL ) {
	var remote = window.open(imageURL, 'ImageZoom', 'width=600,height=400,scrollbars=no,resizable=yes,screenX=100,screenY=100', true);
} 

//
// Slide show
//
var setCollection = new Array();
var imageElements = new Array();
var setElements = new Array();
var setIndex = 0;
var slideShowSpeed = 15000;
var crossFadeDuration = 6000;

// Allows multiple slide shows on a page
function getSetNumber() {
    return setIndex++;
}

// Add an image to the pre-made list
function addImage(setNumber, image) {
    var imageSet = setCollection[setNumber];
    if (imageSet == null) {
        imageSet = new Array();
        setCollection[setNumber] = imageSet;
    }
    
    var index = imageSet.length;
    imageSet[index] = new Image();
    imageSet[index].src = image;
}

// Set the element that is to be used to display the slideshow
function setObjectElement(index, element) {
    setElements[index] = eval(element);
}

// Set the durations for the slideshow
function setTimings(showSpeed, fadeDuration) {
    slideShowSpeed = showSpeed;
    crossFadeDuration = fadeDuration
}

// Execute the requested slideshow
function runSlideShow(setNum, imageIndex) {
    var imageSet = setCollection[setNum];
    var showElement = setElements[setNum];
    var image = imageSet[imageIndex];
    var isIE = (document.all && (navigator.userAgent.indexOf('Windows CE') == -1));

    if (isIE) {
        showElement.style.filter = "blendTrans(duration=" + eval(crossFadeDuration/1000) + ")";
        showElement.filters.blendTrans.apply();
    }
    
    showElement.src = image.src;
    showElement.onclick="openImagePopup('" + image.src + "');";
    
    if (isIE) {
		showElement.filters.blendTrans.play();
	}

    imageIndex++;
    if (imageIndex >= imageSet.length) {
        imageIndex = 0;
    }
    
    // Prepare for the next loop
    var methodCall = "runSlideShow(" + setNum + ", " + imageIndex + ")";
    setTimeout(methodCall, slideShowSpeed);
}

//
// Mouse over image swapping
//
function MM_swapImgRestore() {
  var i, x, a = document.MM_sr; 
  for (i=0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
  	x.src = x.oSrc;
  }
}
function MM_preloadImages() {
  var d = document; 
  if (d.images) { 
    if (!d.MM_p) {
      d.MM_p=new Array();
    }
    var i , j = d.MM_p.length, a = MM_preloadImages.arguments; 
    for (i = 0; i < a.length; i++) {
	  if (a[i].indexOf("#") != 0) { 
	    d.MM_p[j] = new Image; 
	    d.MM_p[j++].src = a[i];
	  }
	}
  }
}
function MM_findObj(n, d) {
  var p, i, x;  
  if (!d) {
  	d=document; 
  }
  if ((p=n.indexOf("?")) > 0 && parent.frames.length) {
    d = parent.frames[n.substring(p+1)].document; 
    n = n.substring(0,p);
  }
  if (!(x=d[n]) && d.all) {
    x = d.all[n]; 
  }
  for (i=0; !x && i < d.forms.length; i++) {
    x = d.forms[i][n];
  }
  for (i = 0; !x && d.layers && i < d.layers.length; i++) {
    x = MM_findObj(n, d.layers[i].document); 
  }
  return x;
}
function MM_swapImage() {
  var i, j = 0, x, a = MM_swapImage.arguments; 
  document.MM_sr = new Array; 
  for (i = 0; i < (a.length - 2); i+=3) {
    if ((x = MM_findObj(a[i])) != null) {
      document.MM_sr[j++] = x; 
      if (!x.oSrc) 
        x.oSrc = x.src; 
      x.src = a[i+2];
     }
   }
}
