﻿// JScript File

// Array to Images
var photos = new Array();
var photoslider;
// Counter to Photo array
var which = 0;
//define images. You can have as many as you want:
photos[0] = "Images/Sponsor/DjursKloakNy.jpg";
photos[1] = "Images/Sponsor/KoekkenlageretNy.jpg";
photos[2] = "Images/Sponsor/NYTbil.jpg";
photos[3] = "Images/Sponsor/AAlsrode.jpg";
photos[4] = "Images/Sponsor/lyngby-brugs.jpg";
photos[5] = "Images/Sponsor/Gaardbutikken.jpg";
photos[6] = "Images/Sponsor/ok02.jpg";
photos[7] = "Images/Sponsor/TG.jpg";
photos[8] = "Images/Sponsor/allanskoreskole.jpg";
photos[9] = "Images/Sponsor/LyngbyEntrepen.jpg";
photos[10] = "Images/Sponsor/emmas-beautybox.jpg";
photos[11] = "Images/Sponsor/annonce.jpg";


//------------------------------------------------------------------
//Preload Images
//Preload the images in the cache so that the images load faster
//create new instance of images in memory 
var imagePreload = new Array();
for (var i = 0; i < photos.length; i++)
{
   imagePreload[i] = new Image();
  // set the src attribute
  imagePreload[i].src = photos[i];
}

//------------------------------------------------------------------

function applyEffect()
{
  try
  {
  if (document.all && photoslider.filters)
    {
    photoslider.filters.revealTrans.Transition = Math.floor(Math.random() * 23);
    photoslider.filters.revealTrans.stop();
    photoslider.filters.revealTrans.apply();
    }
  }
  catch (er)
  {
  alert(er);
  }
}  

//------------------------------------------------------------------
// Function onLoadForside called by onLoad event in HTML Page

function onLoadForside()
{
  try
  {
  // Value of which counter on init Slide Show
  //which = 0;
  which = Math.floor(Math.random() * photos.length);  
  // Init and Start Play Slide Show
  play();
  }
  catch (er)
  {
  alert(er);
  }
}  


//------------------------------------------------------------------
// Count from 0 to length of photos and start from 0 when all photos
// has been shown. Loop again after 4 seconds

function play()
{
  try
  {
  if (which < photos.length - 1)
    {
    which++;
    }
  else
    {  
    which = 0;
    }
  setPhotos();  
  setTimeout('play()', 7000);
  }
  catch (er)
  {
  alert(er);
  }
}  

//------------------------------------------------------------------

function playEffect()
{
  try
  {
  if (document.all && photoslider.filters)
    photoslider.filters.revealTrans.play();
  }
  catch (er)
  {
  alert(er);
  }
}    


//------------------------------------------------------------------

function setPhotos()
{
  try
  {
  photoslider = getDocumentID('photoslider');
  if (photoslider.style.filter === '')
    {
    photoslider.src = photos[which];
    photoslider.style.filter = 'revealTrans(duration = 2, transition = 23)';
    applyEffect();
    }
  else
    {
    applyEffect();
    photoslider.src = photos[which];
    }
  playEffect();
  }
  catch (er)
  {
  alert(er);
  }
}    

