// JavaScript Document
pic1= new Image(); 
pic2= new Image(); 
pic3= new Image(); 
pic4= new Image(); 
pic5= new Image(); 
pic1.src="images/rotation/photo1-1.jpg";
pic2.src="images/rotation/photo1-2.jpg";
pic3.src="images/rotation/photo1-3.jpg";
pic4.src="images/md_rotation/md_01.jpg";
pic5.src="images/rotation/photo1-5.jpg";

var imageLocations0 = new Array("photo1-1.jpg","photo2-1.jpg","photo3-1.jpg","photo4-1.jpg");
var imageLocations1 = new Array("photo1-2.jpg","photo2-2.jpg","photo3-2.jpg","photo4-2.jpg");
var imageLocations2 = new Array("photo1-3.jpg","photo2-3.jpg","photo3-3.jpg","photo4-3.jpg");
var imageLocations3 = new Array("md_01.jpg","md_02.jpg","md_03.jpg","md_04.jpg","md_05.jpg","md_06.jpg","md_07.jpg","md_08.jpg","md_09.jpg");
var imageLocations4 = new Array("photo1-5.jpg","photo2-5.jpg","photo3-5.jpg","photo4-5.jpg");
var currentImg0 = 0;
var currentImg1 = 0;
var currentImg2 = 0;
var currentImg3 = 0;
var currentImg4 = 0;

function callFadeOut0 () {
	window.setTimeout("fadeOut(\"thephoto0\",100)",9500);
} // end function
function startUpRotation0() {
	imageId = 'thephoto0';
	document.getElementById("photoHolder0").innerHTML="<img src='images/rotation/"+imageLocations0[currentImg0]+"' alt='Photo' name=\"thephoto0\" id='thephoto0' />";
	currentImg0++;
	if (currentImg0>=imageLocations0.length) {currentImg0=0}
	window.setTimeout("startUpRotation0()", 11100);
	callFadeOut0 ()
	initImage0();
} // end function
function initImage0() {
  imageId = 'thephoto0';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function callFadeOut1 () {
	window.setTimeout("fadeOut(\"thephoto1\",100)",9500);
} // end function
function startUpRotation1() {
	imageId = 'thephoto1';
	document.getElementById("photoHolder1").innerHTML="<img src='images/rotation/"+imageLocations1[currentImg1]+"' alt='Photo' name=\"thephoto1\" id='thephoto1' />";
	currentImg1++;
	if (currentImg1>=imageLocations1.length) {currentImg1=0}
	window.setTimeout("startUpRotation1()", 11100);
	callFadeOut1 ()
	initImage1();
} // end function
function initImage1() {
  imageId = 'thephoto1';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function callFadeOut2 () {
	window.setTimeout("fadeOut(\"thephoto2\",100)",9500);
} // end function
function startUpRotation2() {
	imageId = 'thephoto2';
	document.getElementById("photoHolder2").innerHTML="<img src='images/rotation/"+imageLocations2[currentImg2]+"' alt='Photo' name=\"thephoto2\" id='thephoto2' />";
	currentImg2++;
	if (currentImg2>=imageLocations2.length) {currentImg2=0}
	window.setTimeout("startUpRotation2()", 11100);
	callFadeOut2 ()
	initImage2();
} // end function
function initImage2() {
  imageId = 'thephoto2';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function callFadeOut3 () {
	window.setTimeout("fadeOut(\"thephoto3\",100)",9500);
} // end function
function startUpRotation3() {
	imageId = 'thephoto3';
	document.getElementById("docs").innerHTML="<img src='images/md_rotation/"+imageLocations3[currentImg3]+"' alt='Photo' name=\"thephoto3\" id='thephoto3' />";
	currentImg3++;
	if (currentImg3>=imageLocations3.length) {currentImg3=0}
	window.setTimeout("startUpRotation3()", 11100);
	callFadeOut3 ()
	initImage3();
} // end function
function initImage3() {
  imageId = 'thephoto3';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function callFadeOut4 () {
	window.setTimeout("fadeOut(\"thephoto4\",100)",9500);
} // end function
function startUpRotation4() {
	imageId = 'thephoto4';
	document.getElementById("Ads").innerHTML="<img src='images/rotation/"+imageLocations4[currentImg4]+"' alt='Photo' name=\"thephoto4\" id='thephoto4' />";
	currentImg4++;
	if (currentImg4>=imageLocations4.length) {currentImg4=0}
	window.setTimeout("startUpRotation4()", 11100);
	callFadeOut4 ()
	initImage4();
} // end function
function initImage4() {
  imageId = 'thephoto4';
  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+")", 75);
    }
  }
}
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);
    }
  }
}

function fadeOutFirst(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity > 0) {
      setOpacity(obj, opacity);
      opacity -= 5;
      window.setTimeout("fadeOutFirst('"+objId+"',"+opacity+")", 75);
    } // end if
	else {
		switch (objId) {
			case "thephoto0": startUpRotation0(); break;
			case "thephoto1": startUpRotation1(); break;
			case "thephoto2": startUpRotation2(); break;
			case "thephoto3": startUpRotation3(); break;
			case "thephoto4": startUpRotation4(); break;
		} // end switch
	} // end else
  } // end if
} // end function


