
  //
  // 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 gbl2PhotoShufflerDivId = "photodiv2";
  var gbl2PhotoShufflerImgId = "photoimg2";
  var gbl2PhotoShufflerAnchorId = "photoanchor2";
  var gbl2Img = new Array(
	"http://www.csmmediafiles.com/home-page-2011/showfacts/showfacts-2-REVISED.jpg",
    "http://www.csmmediafiles.com/home-page-2011/showfacts/showfacts-3-REVISED.jpg",
    "http://www.csmmediafiles.com/home-page-2011/showfacts/showfacts-4-REVISED.jpg",
    "http://www.csmmediafiles.com/home-page-2011/showfacts/showfacts-5-REVISED.jpg",
	"http://www.csmmediafiles.com/home-page-2011/showfacts/showfacts-6-REVISED.jpg",
	"http://www.csmmediafiles.com/home-page-2011/showfacts/showfacts-1-REVISED.jpg"
    );
  var gbl2Href = new Array(
    "http://www.cruiseshippingmiami.com/show-facts",
    "http://www.cruiseshippingmiami.com/show-facts",
    "http://www.cruiseshippingmiami.com/show-facts",
    "http://www.cruiseshippingmiami.com/show-facts",
    "http://www.cruiseshippingmiami.com/show-facts",
    "http://www.cruiseshippingmiami.com/show-facts"
    );
  var gbl2PauseSeconds = 4;
  var gbl2FadeSeconds = .35;
  var gbl2Rotations = 4;

  // End Customization section
  
  var gbl2DeckSize = gbl2Img.length;
  var gbl2Opacity = 100;
  var gbl2OnDeck = 0;
  var gbl2StartImg;
  var gbl2StartHref;
  var gbl2ImageRotations = gbl2DeckSize * (gbl2Rotations+1);

  window.onload = photoShufflerLaunch2;
  
  function photoShufflerLaunch2()
  {
  	var theimg2 = document.getElementById(gbl2PhotoShufflerImgId);
        gbl2StartImg = theimg2.src; // save away to show as final image
  	var theanchor2 = document.getElementById(gbl2PhotoShufflerAnchorId);
        gbl2StartHref = theimg2.href; // save away to show as final image

	document.getElementById(gbl2PhotoShufflerDivId).style.backgroundImage='url(' + gbl2Img[gbl2OnDeck] + ')';
	setTimeout("photoShufflerFade2()",gbl2PauseSeconds*1000);
  }

  function photoShufflerFade2()
  {
  	var theimg2 = document.getElementById(gbl2PhotoShufflerImgId);
	
  	// determine delta based on number of fade seconds
	// the slower the fade the more increments needed
        var fadeDelta2 = 100 / (30 * gbl2FadeSeconds);

	// fade top out to reveal bottom image
	if (gbl2Opacity < 2*fadeDelta2 ) 
	{
	  gbl2Opacity = 100;
	  // stop the rotation if we're done
	  if (gbl2ImageRotations < 1) return;
	  photoShufflerShuffle2();
	  // pause before next fade
          setTimeout("photoShufflerFade2()",gbl2PauseSeconds*1000);
	}
	else
	{
	  gbl2Opacity -= fadeDelta2;
	  setOpacity(theimg2,gbl2Opacity);
	  setTimeout("photoShufflerFade2()",30);  // 1/30th of a second
	}
  }

  function photoShufflerShuffle2()
  {
	var thediv = document.getElementById(gbl2PhotoShufflerDivId);
	var theimg2 = document.getElementById(gbl2PhotoShufflerImgId);
	var theanchor2 = document.getElementById(gbl2PhotoShufflerAnchorId);
	
	// copy div background-image to img.src
	theimg2.src = gbl2Img[gbl2OnDeck];
	theanchor2.href = gbl2Href[gbl2OnDeck];
	window.status = gbl2Href[gbl2OnDeck]; // updates status bar (optional)
	// set img opacity to 100
	setOpacity(theimg2,100);

        // shuffle the deck
	gbl2OnDeck = ++gbl2OnDeck % gbl2DeckSize;
	// decrement rotation counter
	if (--gbl2ImageRotations < 1)
	{
	  // insert start/final image if we're done
	  gbl2Img[gbl2OnDeck] = gbl2StartImg;
	  gbl2Href[gbl2OnDeck] = gbl2StartHref;
	}

	// slide next image underneath
	thediv.style.backgroundImage='url(' + gbl2Img[gbl2OnDeck] + ')';
  }

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;
}


