// ********************************************************************************************

// *********  gallery.js

// *********

// *********

// *********  Functions for manipulating images on web pages

// *********

// ********************************************************************************************



// Specify the image files

var picRef  = new Array() ; // don't touch this

var picText = new Array() ; // don't touch this



// *************************************************************************

// to add more images, just continue the pattern, adding to the picRef array below

// *************************************************************************

picRef[0]  = 'img/coursephotos/1st tee - Copy.jpg' ;

picRef[1]  = 'img/coursephotos/coursephoto2.jpg' ;

picRef[2]  = 'img/coursephotos/coursephoto3.jpg' ;

picRef[3]  = 'img/coursephotos/coursephoto4.jpg' ;

picRef[4]  = 'img/coursephotos/views (5) - Copy.JPG' ;

picRef[5]  = 'img/coursephotos/gdns - Copy.JPG' ;

picRef[6]  = 'img/coursephotos/coursephoto7.jpg' ;

picRef[7]  = 'img/coursephotos/special members - Copy.JPG' ;

picRef[8]  = 'img/coursephotos/coursephoto9.jpg' ;

picRef[9]  = 'img/coursephotos/clubhouse from shadows.jpg' ;

picRef[10] = 'img/coursephotos/towards-the-8th.jpg' ;

picRef[11] = 'img/coursephotos/views (6) - Copy.JPG' ;

picRef[12] = 'img/coursephotos/ponds - Copy.JPG' ;

picRef[13] = 'img/coursephotos/from-middle-of-18th.jpg' ;

picRef[14] = 'img/coursephotos/coursephoto15.jpg' ;

picRef[15] = 'img/coursephotos/coursephoto16.jpg' ;

picRef[16] = 'img/coursephotos/coursephoto17.jpg' ;

picRef[17] = 'img/coursephotos/coursephoto18.jpg' ;

picRef[18] = 'img/coursephotos/ponds (6) - Copy.JPG' ;

picRef[19] = 'img/coursephotos/views (2) - Copy.JPG' ;

picRef[20] = 'img/coursephotos/BearOn4th.jpg' ;



picText[0] = 'The 1st Tee' ;

picText[1] = 'The 18th green and fairway' ;

picText[2] = 'The 6th tee from the 1st green' ;

picText[3] = 'Bridge across the dyke on the 2nd hole' ;

picText[4] = 'View across the first' ;

picText[5] = 'Practice putting and chipping greens' ;

picText[6] = 'The 1st green from the 6th tee' ;

picText[7] = 'Birdies galore' ;

picText[8] = 'Looking across to the 13th tee from the 7th tee' ;

picText[9] = 'Clubhouse from shadows' ;

picText[10] = 'Towards the 8th' ;

picText[11] = 'Clubhouse' ;

picText[12] = '7th Pond' ;

picText[13] = 'from middle of 18th' ;

picText[14] = 'Looking down the 1st fairway' ;

picText[15] = 'The halfway house - variety of refreshments' ;

picText[16] = 'A view of the clubhouse' ;

picText[17] = 'Enjoying a drink outside the clubhouse' ;

picText[18] = '2nd Pond' ;

picText[19] = 'Chipping green' ;

picText[20] = 'Some of the spectacular wildlife on the course' ;



// =======================================

// do not edit anything below this line

// =======================================

var slideShowSpeed = 4000 ;         // Set slideShowSpeed    (milliseconds)

var crossFadeDuration = 3 ;         // Duration of crossfade (seconds)

var numPics = picRef.length ;       // Get how many pictures are in the picRef array



var preLoadedPics = new Array();

for (index = 0; index < numPics; index++)

{

// Create an image object and insert the picture reference (picRef)

   preLoadedPics[index] = new Image() ;

   preLoadedPics[index].src = picRef[index]  ;

}



// ********************************************************************************************

// *********

// *********  This function cycles through some pre-loaded images (see above)

// *********  and displays them using a fade in effect when they are being displayed

// *********

// *********  The fade in effect only works with internet explorer, other browsers will see the image appear immediately

// *********

// ********************************************************************************************

var picToDisplay = 0 ;     // Use the first picture in the preloaded array to display first



function runSlideShow()

{

   // Set up the slide transition and load the next picrure into the DOM Element

   if (document.all)

   {

      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)" ;

      document.images.SlideShow.filters.blendTrans.Apply() ;

   }



   document.images.SlideShow.src = preLoadedPics[picToDisplay].src ;

   if (document.all)

   {

      document.images.SlideShow.filters.blendTrans.Play() ;

   }



    // Insert the description of the photo into the paragraph under the picture

   var newElmt    = document.createElement("b");

   var newElmtTxt = document.createTextNode(picText[picToDisplay]);

   newElmt.appendChild(newElmtTxt);



   var newFrag = document.createDocumentFragment();

   newFrag.appendChild(newElmt);



   var parentElmt = document.getElementById("photoText");

   while (parentElmt.firstChild)  // While there is a first child

   {

      parentElmt.removeChild(parentElmt.firstChild);

   }

   parentElmt.appendChild(newFrag);



   // Increment the count

   picToDisplay++ ;

   if (picToDisplay > (numPics - 1)) picToDisplay=0 ;



   setTimeout('runSlideShow()', slideShowSpeed) ;

}





// ********************************************************************************************

// *********

// *********  Place a new image into an an img tag on an html document and put the alt tag into a text field

// *********  If this runs in Internet explorer it will do it with a fade in effect

// *********

// *********  e.g. swapPic(this,'myImg','myTxt');

// *********

// ********************************************************************************************

function swapPic(srcElmt, imgElmt, txtElmt)

{

// Load the text from the source alt into the target alt

   document.getElementById(imgElmt).title = srcElmt.title ;

// Set up the transition effects parameters  (ie only)

   if (document.all)

   {

      document.getElementById(imgElmt).style.filter="blendTrans(duration=1)" ;

      document.getElementById(imgElmt).filters.blendTrans.Apply() ;

   }



// Load the picture from the source image into the target image

   document.getElementById(imgElmt).src = srcElmt.src ;

   if (document.all)

   {

       document.getElementById(imgElmt).filters.blendTrans.Play() ;

   }



    // Insert the alt text from the original thumbnail image into a text field under the main image

   var newElmt    = document.createElement("span");

   var newElmtTxt = document.createTextNode(srcElmt.title);

   newElmt.appendChild(newElmtTxt);



   var newFrag = document.createDocumentFragment();

   newFrag.appendChild(newElmt);



   var parentElmt = document.getElementById(txtElmt);

   while (parentElmt.firstChild)  // While there is a first child

   {

      parentElmt.removeChild(parentElmt.firstChild);

   }

   parentElmt.appendChild(newFrag);

//   parentElmt.parentNode.replaceChild(newFrag, parentElmt);



}















