
  //
  // CSS Photo Shuffler v1.0 by
  //   Carl Camera
  //   http://iamacamera.org 
  //
  // setOpacity2 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 imagenumber2 = 9 ;
var randomnumber2 = Math.random() ;
var rand2 = Math.round( (imagenumber2-1) * randomnumber2) ;
  
  var gblPhotoShufflerDivId2 = "gull";
  var gblPhotoShufflerImgId2 = "photoimg2"; 
  var gblImg2 = new Array(
    "images/sponsorer/01.gif",
    "images/sponsorer/02.gif",
    "images/sponsorer/03.gif",
	"images/sponsorer/04.gif",
    "images/sponsorer/05.gif",
    "images/sponsorer/06.gif",
    "images/sponsorer/08.gif"
);
  var gblPauseSeconds2 = 5;
  var gblFadeSeconds2 = .85;
  var gblRotations2 = 50000000;

  // End Customization section
  
  var gblDeckSize2 = gblImg2.length;
  var gblOpacity2 = 100;
  var gblOnDeck2 = rand2;
  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*100);
  }

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