// Copyright 2000 SiteExperts.com, InsideDHTML.com, LLC. All rights reserved.
// You can reuse this script as long as the copyright notice is maintained.

// USER-DEFINED SETTINGS

// The list of images to display
var aImages = new Array("bildspel1.jpg","RSC_070505_1.jpg","bildspel6.jpg","RSC_070505_2.jpg","bildspel2.jpg","RSC_070505_3.jpg","bildspel7.jpg","RSC_070505_4.jpg","bildspel3.jpg","RSC_070505_5.jpg","bildspel8.jpg","RSC_070505_6.jpg","bildspel4.jpg","RSC_070505_7.jpg","bildspel9.jpg","RSC_stjarnjul_08.jpg","bildspel5.jpg","RSC_stjarnjul_09.jpg","bildspel10.jpg","RSC_stjarnjul_10.jpg","bildspel11.jpg","RSC_stjarnjul_11.jpg","bildspel12.jpg")

now = new Date();
seed = now.getSeconds();
var TakenImages = ""
var aSortedImages = new Array()
var ii = 0

for (i=0;i<50;i++) 
{
	var rand = Math.round(Math.random(seed) * aImages.length);
	if (rand == aImages.length)
	{
		rand = 0
	}
	if ( TakenImages.indexOf(";;" + aImages[rand]) == -1 ) 
	{ // this one is not yet added to sorted array
		TakenImages = TakenImages + ";;" + aImages[rand]
		aSortedImages[ii] = aImages[rand] 
		ii++
	}
}

// The width and height of the images. 
// All images should be the same size.
var aSize = new Array(230,71)

// The number of milliseconds to wait before switching images
var iDisplay = 6000

// SCRIPT
var oTimer = null 
var iCurrent = 0
var sSource = ""

function doDisplay() {
  // Try and display the image
  clearTimeout(oTimer)
  // The sSource is only set when the image is already available
  if (sSource!="") {
    // Use IE Transition
    if (document.images.slideShow.filters) { 
      document.images.slideShow.filters[0].Stop()
      document.images.slideShow.filters[0].Apply()
      // Use a random transition effect
      document.images.slideShow.filters.revealTrans.transition=23
      
      document.images.slideShow.filters.revealTrans.Duration = 3
    }
    document.images.slideShow.src = sSource
    // Run the transition in IE
    if (document.images.slideShow.filters)
      document.images.slideShow.filters[0].Play()
  }
}

function doReadyImage() 
{
  // Image is ready for display
  sSource = this.src
  // If time period expired just display
  if (oTimer==null) doDisplay()
}

function doErrorDisplay() 
{
  // If error, get next image
  // NOTE - Script not well written if all images fail
  clearTimeout(oTimer)
  doLoad()
}

function doLoad() 
{
  // Start getting the next image
  clearTimeout(oTimer)
  var img = new Image()
  img.onload = doReadyImage
  img.onerror = doErrorDisplay 
  sSource = ""
  iCurrent++
  if (iCurrent==aSortedImages.length) iCurrent=0
  oTimer = setTimeout("oTimer=null;doDisplay()",iDisplay)
  img.src = aSortedImages[iCurrent]
}

// Output the Image tab and next and previous buttons
document.write("<IMG NAME=slideShow SRC=\"" + aSortedImages[iCurrent] + "\"   ONERROR=\"doLoad()\" ONLOAD=\"doLoad()\" WIDTH=\"" + aSize[0] + "\"   HEIGHT=\"" + aSize[1] + "\" STYLE=\"filter: revealTrans(TRANSITION=23)\">")



