  //
  // 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 fourteenthgblPhotoShufflerDivId = "photodiv14";
  var fourteenthgblPhotoShufflerImgId = "photoimg14";
  var fourteenthgblPhotoShufflerAnchorId = "photoanchor14";
  var fourteenthgblImg = new Array(
    "images/lambda3.jpg?v=0",
    "images/lambda6.jpg?v=0",
    "images/lambda.jpg?v=0"
    );
  var fourteenthgblHref = new Array(
    "#nogo",
    "#nogo",
    "#nogo"
    );
  var fourteenthgblPauseSeconds = 6;
  var fourteenthgblFadeSeconds = 0.25;
  var fourteenthgblRotations = 1000;

  // End Customization section
  
  var fourteenthgblDeckSize = fourteenthgblImg.length;
  var fourteenthgblOpacity = 100;
  var fourteenthgblOnDeck = 0;
  var fourteenthgblStartImg;
  var fourteenthgblStartHref;
  var fourteenthgblImageRotations = fourteenthgblDeckSize * (fourteenthgblRotations+1);

// window.onload = fourteenthphotoShufflerLaunch;
  
  function fourteenthphotoShufflerLaunch()
  {
  	var theimg = document.getElementById(fourteenthgblPhotoShufflerImgId);
        fourteenthgblStartImg = theimg.src; // save away to show as final image
  	var theanchor = document.getElementById(fourteenthgblPhotoShufflerAnchorId);
        fourteenthgblStartHref = theimg.href; // save away to show as final image

	document.getElementById(fourteenthgblPhotoShufflerDivId).style.backgroundImage='url(' + fourteenthgblImg[fourteenthgblOnDeck] + ')';
	setTimeout("fourteenthphotoShufflerFade()",fourteenthgblPauseSeconds*1000);
  }

  function fourteenthphotoShufflerFade()
  {
  	var theimg = document.getElementById(fourteenthgblPhotoShufflerImgId);
	
  	// determine delta based on number of fade fourteenths
	// the slower the fade the more increments needed
        var fadeDelta = 100 / (30 * fourteenthgblFadeSeconds);

	// fade top out to reveal bottom image
	if (fourteenthgblOpacity < 2*fadeDelta ) 
	{
	  fourteenthgblOpacity = 100;
	  // stop the rotation if we're done
	  if (fourteenthgblImageRotations < 1) return;
	  fourteenthphotoShufflerShuffle();
	  // pause before next fade
          setTimeout("fourteenthphotoShufflerFade()",fourteenthgblPauseSeconds*1000);
	}
	else
	{
	  fourteenthgblOpacity -= fadeDelta;
	  setOpacity(theimg,fourteenthgblOpacity);
	  setTimeout("fourteenthphotoShufflerFade()",30);  // 1/30th of a fourteenth
	}
  }

  function fourteenthphotoShufflerShuffle()
  {
	var thediv = document.getElementById(fourteenthgblPhotoShufflerDivId);
	var theimg = document.getElementById(fourteenthgblPhotoShufflerImgId);
	var theanchor = document.getElementById(fourteenthgblPhotoShufflerAnchorId);
	
	// copy div background-image to img.src
	theimg.src = fourteenthgblImg[fourteenthgblOnDeck];
	theanchor.href = fourteenthgblHref[fourteenthgblOnDeck];
	window.status = fourteenthgblHref[fourteenthgblOnDeck]; // updates status bar (optional)
	// set img opacity to 100
	setOpacity(theimg,100);

        // shuffle the deck
	fourteenthgblOnDeck = ++fourteenthgblOnDeck % fourteenthgblDeckSize;
	// decrement rotation counter
	if (--fourteenthgblImageRotations < 1)
	{
	  // insert start/final image if we're done
	  fourteenthgblImg[fourteenthgblOnDeck] = fourteenthgblStartImg;
	  fourteenthgblHref[fourteenthgblOnDeck] = fourteenthgblStartHref;
	}

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

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


