// DO NOT EDIT BELOW THIS LINE!
function CacheImage(ImageSource) 
{ // TURNS THE STRING INTO AN IMAGE OBJECT
   var ImageObject = new Image();
   ImageObject.src = ImageSource;
   return ImageObject;
}

function ShowSlide(Direction) 
{
  var NextSlide;
  if (SlideReady) 
   {
      NextSlide = CurrentSlide + Direction;
      // THIS WILL DISABLE THE BUTTONS (IE-ONLY)
      document.SlideShow.Previous.disabled = (NextSlide == 0);
      document.SlideShow.Next.disabled = (NextSlide == (Slides.length-1));    
	if ((NextSlide >= 0) && (NextSlide < Slides.length)) 
     {
            document.images['Screen'].src = Slides[NextSlide].src;
            CurrentSlide = NextSlide++;
            Message = 'Picture ' + (CurrentSlide+1) + ' of ' + Slides.length;
            self.defaultStatus = Message;
            if (Direction == 1) CacheNextSlide();
     }
      return true;
   }
}

function Download() 
{
   if (Slides[NextSlide].complete) 
   {
      SlideReady = true;
      self.defaultStatus = Message;
   }
   else setTimeout("Download()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
   return true;
}

function CacheNextSlide() 
{
   if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 'string'))
   { // ONLY CACHES THE IMAGES ONCE
      SlideReady = false;
      self.defaultStatus = 'Downloading next picture...';
      Slides[NextSlide] = CacheImage(Slides[NextSlide]);
      Download();
   }
   return true;
}

// --------------
function ShowSlide2(Direction) 
{
   if (SlideReady2) 
   {
      NextSlide2 = CurrentSlide2 + Direction;
      // THIS WILL DISABLE THE BUTTONS (IE-ONLY)
      //document.SlideShow2.Previous.disabled = (NextSlide2 == 0);
      //document.SlideShow2.Next.disabled = (NextSlide2 == (Slides2.length-1));
      document.images["Previous"].src = "http://www.bhmanagement.com/communities/Properties/images/prev-button.gif"
      document.images["Next"].src = "http://www.bhmanagement.com/communities/Properties/images/next-button.gif"
      if (NextSlide2 <= 0)
          document.images["Previous"].src="http://www.bhmanagement.com/communities/Properties/images/no-prev.gif";
      if (NextSlide2 >= (Slides2.length-1))          
      	  document.images["Next"].src="http://www.bhmanagement.com/communities/Properties/images/no-next.gif";
	if ((NextSlide2 >= 0) && (NextSlide2 < Slides2.length)) 
     {
            document.images['Screen2'].src = Slides2[NextSlide2].src;
            CurrentSlide2 = NextSlide2++;
            Message = 'Picture ' + (CurrentSlide2+1) + ' of ' + Slides2.length;
			document.getElementById("pictureIndex").innerHTML = (CurrentSlide2+1) + ' of ' + Slides2.length;
			//document.getElementById('pictureIndex').innerText = (CurrentSlide2+1) + ' of ' + Slides2.length;
            self.defaultStatus = Message;
            if (Direction == 1) CacheNextSlide2();
     }
      return true;
   }
}

function Download2() 
{
   if (Slides2[NextSlide2].complete) 
   {
      SlideReady2 = true;
      self.defaultStatus = Message;
   }
   else setTimeout("Download2()", 100); // CHECKS DOWNLOAD STATUS EVERY 100 MS
   return true;
}

function CacheNextSlide2() 
{
   if ((NextSlide2 < Slides2.length) && (typeof Slides2[NextSlide2] == 'string'))
   { // ONLY CACHES THE IMAGES ONCE
      SlideReady2 = false;
      self.defaultStatus = 'Downloading next picture...';
      Slides2[NextSlide2] = CacheImage(Slides2[NextSlide2]);
      Download2();
   }
   return true;
}
// --------------------
function StartSlideShow()
{
   CurrentSlide = -1;
   CurrentSlide2 = -1;
   //Slides[0] = CacheImage(Slides[0]);
   //document.write ("Slides[0]" + Slides[0]);
   Slides2[0] = CacheImage(Slides2[0]);
   //SlideReady = true;
   SlideReady2 = true;
   //ShowSlide(1);
   ShowSlide2(1);
}