// =======================================
// Functions for banner photos
// =======================================

// Vars
var slideShowSpeed = 4000;
var crossFadeDuration = 2;
var photoFrames = 4;

// Thumbnails
var Pic = new Array();
Pic[0] = 'gallery/th_Anglesea.jpg';
Pic[1] = 'gallery/th_BawBaw.jpg';
Pic[2] = 'gallery/th_Bay.jpg';
Pic[3] = 'gallery/th_BogongMist.jpg';
Pic[4] = 'gallery/th_Campsite1.jpg';
Pic[5] = 'gallery/th_Campsite2.jpg';
Pic[6] = 'gallery/th_CathedralsPanorama.jpg';
Pic[7] = 'gallery/th_CrossCut.jpg';
Pic[8] = 'gallery/th_CrossCutSaw.jpg';
Pic[9] = 'gallery/th_Fainter.jpg';
Pic[10] = 'gallery/th_Gow.jpg';
Pic[11] = 'gallery/th_Grampians1.jpg';
Pic[12] = 'gallery/th_Grampians2.jpg';
Pic[13] = 'gallery/th_Grampians3.jpg';
Pic[14] = 'gallery/th_GuysHut.jpg';
Pic[15] = 'gallery/th_HowquaRiver.jpg';
Pic[16] = 'gallery/th_Koala.jpg';
Pic[17] = 'gallery/th_LittleBullerSpur.jpg';
Pic[18] = 'gallery/th_MarinerFalls.jpg';
Pic[19] = 'gallery/th_MoggsCreek.jpg';
Pic[20] = 'gallery/th_MtDarlingLookout.jpg';
Pic[21] = 'gallery/th_MtFeatherTop.jpg';
Pic[22] = 'gallery/th_MtWorth1.jpg';
Pic[23] = 'gallery/th_MtWorth2.jpg';
Pic[24] = 'gallery/th_Otways.jpg';
Pic[25] = 'gallery/th_PhillipIsland1.jpg';
Pic[26] = 'gallery/th_PhillipIsland2.jpg';
Pic[27] = 'gallery/th_PieAndAndrew.jpg';
Pic[28] = 'gallery/th_RazorViking.jpg';
Pic[29] = 'gallery/th_RiverCrossing.jpg';
Pic[30] = 'gallery/th_Rosea.jpg';
Pic[31] = 'gallery/th_SnakeIsland.jpg';
Pic[32] = 'gallery/th_TorquayAnglesea.jpg';
Pic[33] = 'gallery/th_Wabonga.jpg';
Pic[34] = 'gallery/th_Walhalla1.jpg';
Pic[35] = 'gallery/th_Walhalla2.jpg';
Pic[36] = 'gallery/th_WarburtonTrail1.jpg';
Pic[37] = 'gallery/th_WarburtonTrail2.jpg';
Pic[38] = 'gallery/th_Wattle.jpg';
Pic[39] = 'gallery/th_WilsonsProm1.jpg';
Pic[40] = 'gallery/th_WilsonsProm2.jpg';
Pic[41] = 'gallery/th_WilsonsProm3.jpg';
Pic[42] = 'gallery/th_WilsonsProm4.jpg';
Pic[43] = 'gallery/th_Wyperfeld.jpg';

var t;
var j = 0;
var numPhotos = Pic.length;
var preLoad = new Array();
for (i = 0; i < numPhotos; i++) {
   preLoad[i] = new Image();
   preLoad[i].src = Pic[i];
}
var photoOffset = Math.floor(numPhotos / photoFrames);

function runBannerSlideShow() {
  fnum = Math.floor(Math.random() * photoFrames);
  pnum = Math.floor(Math.random() * photoOffset);
  if (fnum == '' || fnum<0 || fnum>=photoFrames) { fnum = 0; }
  if (pnum == '' || pnum<0 || pnum>=photoOffset) { pnum = 0; }
  pnum = pnum + (fnum * photoOffset);
  var imgname = 'photoFrame'+(fnum+1);

  var imgobj = document.getElementById(imgname);
  if (document.all) {
    imgobj.style.filter = "blendTrans(duration=2)";
    imgobj.style.filter = "blendTrans(duration=crossFadeDuration)";
    imgobj.filters.blendTrans.Apply();
  }
  imgobj.src = preLoad[pnum].src;
  if (document.all) {
    imgobj.filters.blendTrans.Play();
  }
  t = setTimeout('runBannerSlideShow()', slideShowSpeed);
}

// =======================================
// Functions for photo gallery page
// =======================================
function changePhoto() {
  var list = document.getElementById('photolist');
  document.photo.src = list.options[list.selectedIndex].value;
}
function prevPhoto() {
  var list = document.getElementById('photolist');
  if(list.selectedIndex == 0) {
    list.selectedIndex = list.options.length-1;
  }
  else {
    list.selectedIndex--;
  }
  changePhoto();
}
function nextPhoto() {
  var list = document.getElementById('photolist');
  if(list.selectedIndex == list.options.length-1) {
    list.selectedIndex = 0;
  }
  else {
    list.selectedIndex++;
  }
  changePhoto();
}