  //
  // CSS Linked Photo Shuffler v1.1 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 an anchor <a> and <div>. 
  //   specify unique id= in all three
  // * The first and final photo displayed is in the html <img> tag
  // * The image 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 Href array contains the link you want associated with each image
  //   each image must have a corresponding link.
  // * The rotations variable specifies how many times to repeat array.
  //   images. zero is a valid rotation value.

  var tenthgblPhotoShufflerDivId = "photodiv10";
  var tenthgblPhotoShufflerImgId = "photoimg10";
  var tenthgblPhotoShufflerAnchorId = "photoanchor10";
  var tenthgblImg = new Array(
    "images/otherstands2.jpg?v=0",
    "images/otherstands3.jpg?v=0",
    "images/otherstands4.jpg?v=0",
    "images/otherstands5.jpg?v=0",
	"images/otherstands6.jpg?v=0",
	"images/otherstands6.jpg?v=0",
    "images/otherstands1.jpg?v=0"
    );
  var tenthgblHref = new Array(
    "#bannerstand",
    "#bannerstand",
    "#bannerstand",
    "#bannerstand",
    "#bannerstand",
    "#bannerstand",
    "#bannerstand"
    );
  var tenthgblPauseSeconds = 2;
  var tenthgblFadeSeconds = 0.25;
  var tenthgblRotations = 1000;

  // End Customization section
  
  var tenthgblDeckSize = tenthgblImg.length;
  var tenthgblOpacity = 100;
  var tenthgblOnDeck = 0;
  var tenthgblStartImg;
  var tenthgblStartHref;
  var tenthgblImageRotations = tenthgblDeckSize * (tenthgblRotations+1);

// window.onload = tenthphotoShufflerLaunch;
  
  function tenthphotoShufflerLaunch()
  {
  	var theimg = document.getElementById(tenthgblPhotoShufflerImgId);
        tenthgblStartImg = theimg.src; // save away to show as final image
  	var theanchor = document.getElementById(tenthgblPhotoShufflerAnchorId);
        tenthgblStartHref = theimg.href; // save away to show as final image

	document.getElementById(tenthgblPhotoShufflerDivId).style.backgroundImage='url(' + tenthgblImg[tenthgblOnDeck] + ')';
	setTimeout("tenthphotoShufflerFade()",tenthgblPauseSeconds*1000);
  }

  function tenthphotoShufflerFade()
  {
  	var theimg = document.getElementById(tenthgblPhotoShufflerImgId);
	
  	// determine delta based on number of fade tenths
	// the slower the fade the more increments needed
        var fadeDelta = 100 / (30 * tenthgblFadeSeconds);

	// fade top out to reveal bottom image
	if (tenthgblOpacity < 2*fadeDelta ) 
	{
	  tenthgblOpacity = 100;
	  // stop the rotation if we're done
	  if (tenthgblImageRotations < 1) return;
	  tenthphotoShufflerShuffle();
	  // pause before next fade
          setTimeout("tenthphotoShufflerFade()",tenthgblPauseSeconds*1000);
	}
	else
	{
	  tenthgblOpacity -= fadeDelta;
	  setOpacity(theimg,tenthgblOpacity);
	  setTimeout("tenthphotoShufflerFade()",30);  // 1/30th of a tenth
	}
  }

  function tenthphotoShufflerShuffle()
  {
	var thediv = document.getElementById(tenthgblPhotoShufflerDivId);
	var theimg = document.getElementById(tenthgblPhotoShufflerImgId);
	var theanchor = document.getElementById(tenthgblPhotoShufflerAnchorId);
	
	// copy div background-image to img.src
	theimg.src = tenthgblImg[tenthgblOnDeck];
	theanchor.href = tenthgblHref[tenthgblOnDeck];
	window.status = tenthgblHref[tenthgblOnDeck]; // updates status bar (optional)
	// set img opacity to 100
	setOpacity(theimg,100);

        // shuffle the deck
	tenthgblOnDeck = ++tenthgblOnDeck % tenthgblDeckSize;
	// decrement rotation counter
	if (--tenthgblImageRotations < 1)
	{
	  // insert start/final image if we're done
	  tenthgblImg[tenthgblOnDeck] = tenthgblStartImg;
	  tenthgblHref[tenthgblOnDeck] = tenthgblStartHref;
	}

	// slide next image underneath
	thediv.style.backgroundImage='url(' + tenthgblImg[tenthgblOnDeck] + ')';
  }

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;
}


