  var theInterval;
  var theIntervalID = 0;
  var slideShowIsRunning = false;
  var slideCount = 1;
  var picArray = new Array();
  var CurrentPic = 0;
  var theElt = 0;
  var picNum = 0;
  var imageCount = 0;
  var imageNum = 1;

  var anIEBrowser = "";
  var usrAgnt = navigator.userAgent;
  var StartPos = usrAgnt.indexOf("MSIE");
  var checkVer = usrAgnt.substring((StartPos + 5), usrAgnt.indexOf(".", StartPos));

  if (checkVer >= "4") {
    anIEBrowser = "Yes";
  }
  else {
    anIEBrowser = "No";
  }

  if (anIEBrowser == "Yes") {
    document.writeln('<style type="text/css">img {filter:blendTrans(duration=1)}</style>');
  }

  function setupAll() {
	  generalSetup();
	  //categorySetup('cabins/whitepine', whitepineCnt);
	  //categorySetup('cabins/scotchpine', scotchpineCnt);
	  //categorySetup('cabins/redoak', redoakCnt);
	  //categorySetup('cabins/hemlock', hemlockCnt);
	  //categorySetup('cabins/blackwalnut', blackwalnutCnt);
	  categorySetup('trials', trailsCnt);
	  categorySetup('largeshelter', largeshelterCnt);
	  categorySetup('smallshelter', smallshelterCnt);
	  categorySetup('beach', beachCnt);
	  categorySetup('nec', necCnt);
	  categorySetup('playground', playgroundCnt);
      var theImageObject = document.getElementById("image_area");
      theImageObject.src = imgPath+"Quickview.jpg";
  }
  
  function generalSetup() {
	
	//Preload Campsites
	preloadedImage = new Image();
	imageURL = new Array();
	var i=0;
	for (i=1; i<=26; i++){
		preloadedImage.src = imgPath+"camp"+i+".jpg";
	}
    
	//Preload other features of interest.
	preloadedImage.src = imgPath+"boatramp.jpg";
	preloadedImage.src = imgPath+"willowlake.jpg";
	preloadedImage.src = imgPath+"shower.jpg";
  }
  
  //Setup array of images for the selected catagory.
  function categorySetup(imgCat, imgCnt)  {
    var theImageObject = document.getElementById("image_area");
    imageCount = imgCnt;
    imageNum = 1;
    //replaceCountText(imageNum, imageCount);
    CurrentPic = 0;
    //Set new image array
    picArray = new Array();

    //Turn off slide show if it is running
   if (slideShowIsRunning) {
      toggleSlideShow();
    }
	
    //Check to see if imgCat is INIT.  If so, set array
    //to show first image from each category. Otherwise,
    //set array to show all images of specified category.

    //Set default image for image object
      //  theImageObject.src = imgPath+imgCat+"/pic0"+imgCnt+".jpg";
     // } else {
     //   theImageObject.src = imgPath+imgCat+"/pic"+imgCnt+".jpg";
     // }
      picNum = imgCnt;

      //Loop N times to add N number of images to the image array
      for (theElt=0; theElt<imgCnt; theElt+=1) {
        //Generate a new Image object.
        theImage = new Image();
        if (picNum <= 9) {
          imgName = imgPath+imgCat+"/pic"+"0"+picNum+".jpg";
        } else {
          imgName = imgPath+imgCat+"/pic"+picNum+".jpg";
        }
        picArray[theElt] = new Image();
        picArray[theElt].src = imgName;
        picNum = picNum - 1;
      }

    }
  
  //Change the picture to the first picture in the set.
  function first_pic() {
    var theImageObject = document.getElementById("image_area");
    CurrentPic = 0;
    if (theImageObject.filters) theImageObject.filters[0].Apply();
    theImageObject.src = picArray[0].src;
    if (theImageObject.filters) theImageObject.filters[0].Play();
  }

  //Changes the image object to the next picture when the user clicks the next button.
  function next_pic() {
    var theImageObject = document.getElementById("image_area");
    imageNum = imageNum + 1;
    if (imageNum > imageCount) imageNum = 1;
    //replaceCountText(imageNum, imageCount);
	CurrentPic += 1;
    if (theImageObject.filters) theImageObject.filters[0].Apply();
    if (CurrentPic > (picArray.length - 1)) CurrentPic = 0;
      theImageObject.src = picArray[CurrentPic].src;
    //adjustDivision();
    if (theImageObject.filters) theImageObject.filters[0].Play();
 }

function adjustDivision() {
   var picWidth = picArray[CurrentPic].width;
   var picHeight = picArray[CurrentPic].height;
   var picDiv = getElementById("HomePagePicDiv");

   if (picWidth >= picHeight) {
      picDiv.style.left = "450";
   } else {
      picDiv.style.left = "480";
   }
}

  //Changes the image object back to the previous picture when the user clicks the previous button.
  function prev_pic() {
    var theImageObject = document.getElementById("image_area");
    imageNum = imageNum - 1;
    if (imageNum == 0) imageNum = imageCount;
	//replaceCountText(imageNum, imageCount);
    CurrentPic -= 1;
    if (theImageObject.filters) theImageObject.filters[0].Apply();
    if (CurrentPic < 0) CurrentPic = (picArray.length - 1);
    theImageObject.src = picArray[CurrentPic].src;
    if (theImageObject.filters) theImageObject.filters[0].Play();
  }

  //Change the picture to the last picture in the set.
  function last_pic() {
   var theImageObject = document.getElementById("image_area");
   CurrentPic = picArray.length - 1;
   if (theImageObject.filters) theImageObject.filters[0].Apply();
   theImageObject.src = picArray[picArray.length - 1].src;
   if (theImageObject.filters) theImageObject.filters[0].Play();
  }  

  function toggleSlideShow() {
    if (slideShowIsRunning) {
        //var stopSlideDiv = document.getElementById("StopSlideDiv");
        //var startSlideDiv = document.getElementById("StartSlideDiv");
        //stopSlideDiv.style.visibility = "hidden";
        //startSlideDiv.style.visibility= "visible";
        stopSlideShow();
    }
    else {
        //var stopSlideDiv = document.getElementById("StopSlideDiv");
        //var startSlideDiv = document.getElementById("StartSlideDiv");
        //stopSlideDiv.style.visibility = "visible";
        //startSlideDiv.style.visibility= "hidden";
        startSlideShow();
    }
  }

  function startSlideShow() {
    //var theImage = document.getElementById("ToggleSlideImg")
    //theImage.src = "buttons/StopSlide.gif";
    theInterval = 3;
    theIntervalID = setInterval("flipSlide()", (theInterval * 1000));
    slideShowIsRunning = true;        
  }

  function flipSlide() {
    slideCount += 1;
    next_pic();
  }

  function stopSlideShow() {
    clearInterval(theIntervalID);
    //var theImage = document.getElementById("ToggleSlideImg")
    //theImage.src = "buttons/StartSlide.gif";
    slideShowIsRunning = false;
  }


  function replaceCountText(slideNum, imgCnt) {
    var theVisDiv = document.getElementById("PicCountDiv");
    var para = document.getElementById("CntDesc");
    var newTextStr = "";
    var newPara1 = document.createElement("span");

    newPara1TextStr = slideNum+" of "+imgCnt;
    var newPara1Text = document.createTextNode(newPara1TextStr);
    newPara1.appendChild(newPara1Text);
    newPara1.id = "CountSpan";
    var oldPara1 = document.getElementById("CountSpan");
    var replaced = para.replaceChild(newPara1,oldPara1);
}

//  function clickButton(btnName, btnPosition) {
//    var theImage = document.getElementById(btnName);
//    if (btnPosition == "Up") {
//      theImage.src = "buttons/"+btnName+"Off.gif";
//    } else {
//      theImage.src = "buttons/"+btnName+"On.gif";
//    }
//  }

