  //
  // CSS Photo Shuffler v1.0 by
  //   Carl Camera
  //   http://iamacamera.org 
  //
  // SetOpacity Function and inpiration from Photo Fade by
  //   Richard Rutter
  //   http://clagnut.com
  //
  // License: Creative Commons Attribution 2.5  License
  //   http://creativecommons.org/licenses/by/2.5/
  //
  
  // Customize your photo shuffle settings
  // 
  // * Surround the target <img /> with a <div>. specify id= in both
  // * The first and final photo displayed is in the html <img> tag
  // * The array contains paths to photos you want in the rotation. 
  //   If you want the first photo in the rotation, then it's best to
  //   put it as the final array image.  All photos must be same dimension
  // * The rotations variable specifies how many times to repeat array.
  //   images. zero is a valid rotation value.

  var gblPhotoShufflerDivId2 = "shufflediv2";
  var gblPhotoShufflerImgId2 = "photoshuffle2"; 
  var gblImg2 = new Array(
      "/New_Header_images/New/17.jpg",
	  "/New_Header_images/New/18.jpg",
	  "/New_Header_images/New/19.jpg",
	  "/New_Header_images/New/20.jpg",
//	  "/New_Header_images/New/21.jpg",
	  "/New_Header_images/New/22.jpg",
	  "/New_Header_images/New/23.jpg",
	  "/New_Header_images/New/24.jpg",
	  "/New_Header_images/New/25.jpg",
	  "/New_Header_images/New/26.jpg",
	  "/New_Header_images/New/27.jpg",
	  "/New_Header_images/New/28.jpg",
	  "/New_Header_images/New/29.jpg",
	  "/New_Header_images/New/30.jpg",
	  "/New_Header_images/New/31.jpg",
	  "/New_Header_images/New/32.jpg");
  var gblPauseSeconds2 = 16;
  var gblFadeSeconds2 = .85;
  var gblRotations2 = 50;

  // End Customization section
  
  var gblDeckSize2 = gblImg2.length;
  var gblOpacity2 = 100;
  var gblOnDeck2 = 0;
  var gblStartImg2;
  var gblImageRotations2 = gblDeckSize2 * (gblRotations2+1);

  //window.onload = photoShufflerLaunch2;
  
  function photoShufflerLaunch2()
  {
  	var theimg2 = document.getElementById(gblPhotoShufflerImgId2);
        gblStartImg2 = theimg2.src; // save away to show as final image

	document.getElementById(gblPhotoShufflerDivId2).style.backgroundImage='url(' + gblImg2[gblOnDeck2] + ')';
	setTimeout("photoShufflerFade2()",gblPauseSeconds2*1000);
  }

  function photoShufflerFade2()
  {
  	var theimg2 = document.getElementById(gblPhotoShufflerImgId2);
	
  	// determine delta based on number of fade seconds
	// the slower the fade the more increments needed
        var fadeDelta2 = 100 / (30 * gblFadeSeconds2);

	// fade top out to reveal bottom image
	if (gblOpacity2 < 2*fadeDelta2 ) 
	{
	  gblOpacity2 = 100;
	  // stop the rotation if we're done
	  if (gblImageRotations2 < 1) return;
	  photoShufflerShuffle2();
	  // pause before next fade
          setTimeout("photoShufflerFade2()",gblPauseSeconds2*1000);
	}
	else
	{
	  gblOpacity2 -= fadeDelta2;
	  setOpacity2(theimg2,gblOpacity2);
	  setTimeout("photoShufflerFade2()",30);  // 1/30th of a second
	}
  }

  function photoShufflerShuffle2()
  {
	var thediv2 = document.getElementById(gblPhotoShufflerDivId2);
	var theimg2 = document.getElementById(gblPhotoShufflerImgId2);
	
	// copy div background-image to img.src
	theimg2.src = gblImg2[gblOnDeck2];
	// set img opacity to 100
	setOpacity2(theimg2,100);

        // shuffle the deck
	gblOnDeck2 = ++gblOnDeck2 % gblDeckSize2;
	// decrement rotation counter
	if (--gblImageRotations2 < 1)
	{
	  // insert start/final image if we're done
	  gblImg2[gblOnDeck2] = gblStartImg2;
	}

	// slide next image underneath
	thediv2.style.backgroundImage='url(' + gblImg2[gblOnDeck2] + ')';
  }

function setOpacity2(obj2, opacity2) {
  opacity2 = (opacity2 == 100)?99.999:opacity2;
  
  // IE/Win
  obj2.style.filter = "alpha(opacity:"+opacity2+")";
  
  // Safari<1.2, Konqueror
  obj2.style.KHTMLOpacity = opacity2/100;
  
  // Older Mozilla and Firefox
  obj2.style.MozOpacity = opacity2/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj2.style.opacity = opacity2/100;
}


