// JavaScript Document
var imageLocations = new Array("big-image-1.jpg","big-image-3.jpg","big-image-4.jpg","big-image-5.jpg","big-image-6.jpg","big-image-8.jpg");
var currentImg = 0;
var firstTimeThroughTheArrray=true;
var preloaded = new Array();
function preloadImages() {
    for (var i = 0; i < arguments.length; i++){
        preloaded[i] = document.createElement('img');
        preloaded[i].setAttribute('src','images/'+arguments[i]);
    } // end for
} // end function
preloadImages("big-image-1.jpg","big-image-3.jpg","big-image-4.jpg","big-image-5.jpg","big-image-6.jpg","big-image-8.jpg");
function callFadeOut () {
	window.setTimeout("fadeOut(\"thephoto\",100)",5500);
} // end function
function firstStart() {
	changeContentScrollDiv(1);
	startUpRotation();
} // end function
function startUpRotation() {
	imageId = 'thephoto';
	document.getElementById("photoHolder").innerHTML="<img src='images/"+imageLocations[currentImg]+"' name=\"thephoto\" id='thephoto' style=\"filter: alpha(opacity:00);opacity:0.0;\" />";
	//if(firstTimeThroughTheArrray==false){document.getElementById("thephoto").src=preloaded[currentImg].src;} else {firstTimeThroughTheArrray=false;}
	currentImg++;
	if (currentImg>=imageLocations.length) {currentImg=0}
	callFadeOut ()
	initImage();
} // end function
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, 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+")", 75);
    } // end if
  } // end if
} // end function
function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity > 0) {
      setOpacity(obj, opacity);
      opacity -= 5;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 75);
    } // end if
	else {
		startUpRotation();
	} // end else
  } // end if
} // end function
preloadImages(imageLocations);
