  //
  // 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 eleventhgblPhotoShufflerDivId = "photodiv11";
  var eleventhgblPhotoShufflerImgId = "photoimg11";
  var eleventhgblPhotoShufflerAnchorId = "photoanchor11";
  var eleventhgblImg = new Array(
    "images/popup-stand2.jpg?v=0",
    "images/popup-stand3.jpg?v=0",
    "images/popup-stand4.jpg?v=0",
    "images/popup-stand5.jpg?v=0",
	"images/popup-stand6.jpg?v=0",
	"images/popup-stand7.jpg?v=0",
	"images/popup-stand7.jpg?v=0",
    "images/popup-stand1.jpg?v=0"
    );
  var eleventhgblHref = new Array(
    "#mediawall",
    "#mediawall",
    "#mediawall",
    "#mediawall",
    "#mediawall",
    "#mediawall",
    "#mediawall",
    "#mediawall"
    );
  var eleventhgblPauseSeconds = 2;
  var eleventhgblFadeSeconds = 0.25;
  var eleventhgblRotations = 1000;

  // End Customization section
  
  var eleventhgblDeckSize = eleventhgblImg.length;
  var eleventhgblOpacity = 100;
  var eleventhgblOnDeck = 0;
  var eleventhgblStartImg;
  var eleventhgblStartHref;
  var eleventhgblImageRotations = eleventhgblDeckSize * (eleventhgblRotations+1);

// window.onload = eleventhphotoShufflerLaunch;
  
  function eleventhphotoShufflerLaunch()
  {
  	var theimg = document.getElementById(eleventhgblPhotoShufflerImgId);
        eleventhgblStartImg = theimg.src; // save away to show as final image
  	var theanchor = document.getElementById(eleventhgblPhotoShufflerAnchorId);
        eleventhgblStartHref = theimg.href; // save away to show as final image

	document.getElementById(eleventhgblPhotoShufflerDivId).style.backgroundImage='url(' + eleventhgblImg[eleventhgblOnDeck] + ')';
	setTimeout("eleventhphotoShufflerFade()",eleventhgblPauseSeconds*1000);
  }

  function eleventhphotoShufflerFade()
  {
  	var theimg = document.getElementById(eleventhgblPhotoShufflerImgId);
	
  	// determine delta based on number of fade elevenths
	// the slower the fade the more increments needed
        var fadeDelta = 100 / (30 * eleventhgblFadeSeconds);

	// fade top out to reveal bottom image
	if (eleventhgblOpacity < 2*fadeDelta ) 
	{
	  eleventhgblOpacity = 100;
	  // stop the rotation if we're done
	  if (eleventhgblImageRotations < 1) return;
	  eleventhphotoShufflerShuffle();
	  // pause before next fade
          setTimeout("eleventhphotoShufflerFade()",eleventhgblPauseSeconds*1000);
	}
	else
	{
	  eleventhgblOpacity -= fadeDelta;
	  setOpacity(theimg,eleventhgblOpacity);
	  setTimeout("eleventhphotoShufflerFade()",30);  // 1/30th of a eleventh
	}
  }

  function eleventhphotoShufflerShuffle()
  {
	var thediv = document.getElementById(eleventhgblPhotoShufflerDivId);
	var theimg = document.getElementById(eleventhgblPhotoShufflerImgId);
	var theanchor = document.getElementById(eleventhgblPhotoShufflerAnchorId);
	
	// copy div background-image to img.src
	theimg.src = eleventhgblImg[eleventhgblOnDeck];
	theanchor.href = eleventhgblHref[eleventhgblOnDeck];
	window.status = eleventhgblHref[eleventhgblOnDeck]; // updates status bar (optional)
	// set img opacity to 100
	setOpacity(theimg,100);

        // shuffle the deck
	eleventhgblOnDeck = ++eleventhgblOnDeck % eleventhgblDeckSize;
	// decrement rotation counter
	if (--eleventhgblImageRotations < 1)
	{
	  // insert start/final image if we're done
	  eleventhgblImg[eleventhgblOnDeck] = eleventhgblStartImg;
	  eleventhgblHref[eleventhgblOnDeck] = eleventhgblStartHref;
	}

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

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


