// JavaScript Document

function initImage() {
  imageId = 'thephoto';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 5;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function rotateimage()
{
	if (pause) return;
	
	/* The if statement below completely randomizes the slideshow */
	/*
	if (curindex == (tempindex = Math.floor(Math.random() * (images.length)))) {
		curindex = curindex == 0? 1 : curindex-1;
	}
	else
		curindex = tempindex;
	*/
	
	if (curIndex < (images.length - 1)) {
		curIndex = curIndex + 1;
	} else {
		curIndex = 0;
	}
	
	initImage();
	document.images.slideshowIMG.src = images[curIndex];
	if (document.getElementById) document.getElementById("CaptionLayer").innerHTML= captions[curIndex];
}

function doPause()  {
	if(pause) {
		pause = false;
		document.getElementById("pauseBtn").value = "PAUSE";
	} else {
		pause = true;
		document.getElementById("pauseBtn").value = "PLAY";
	}
}