/*
Smart Cache Slide Show
Copyright Jason Moon
To add more shock to your site, visit www.DHTML Shock.com
*/
// PUT THE URL'S OF YOUR IMAGES INTO THIS ARRAY...
var Slides = new Array('casestudies/images/wef.jpg','casestudies/images/ab.jpg','casestudies/images/qmarine.jpg','casestudies/images/adr.jpg','casestudies/images/house.jpg','casestudies/images/css.jpg','casestudies/images/art.jpg','casestudies/images/quantum.jpg','casestudies/images/tgbatv.jpg','casestudies/images/wd.jpg','casestudies/images/ucpc.jpg');

var Caption = new Array('Bio Fuels','Electronics Cable Assembly','Boat Sales','Industrial Training','Holiday Home Rental','Kitchen Components','Motorcycle Training','Quad Bikes (1)','Quad Bikes (2)','Water Borehole Driling','Parish Council');

var Links = new Array('http://www.wessexecofuels.co.uk','http://www.abcableandwiring.co.uk','http://www.quantummarine.co.uk','http://www.adrtraining.org.uk','http://www.ahouseinnormandy.co.uk','http://www.contractservicessouthern.co.uk','http://www.andoverridertraining.co.uk','http://www.quantumquads.co.uk','http://www.tgbatv.co.uk/','http://www.wardledrilling.co.uk','http://www.upperclatfordpc.org');

// 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) {
   if (SlideReady) {
      NextSlide = CurrentSlide + Direction;
      NextCaption = CurrentCaption + Direction
      NextLink = CurrentLink + Direction

      // THIS WILL DISABLE THE BUTTONS (IE-ONLY)
      document.SlideShow.Previous.disabled = (NextSlide == 0);
      document.SlideShow.Previous.disabled = (NextCaption == 0);
      document.SlideShow.Previous.disabled = (NextLink == -1);

      document.SlideShow.Next.disabled = (NextSlide == (Slides.length-1));   
      document.SlideShow.Next.disabled = (NextCaption == (Caption.length-1)); 
      document.SlideShow.Next.disabled = (NextLink == (Links.length-2)); 
 
 if ((NextSlide >= 0) && (NextSlide < Slides.length)) {
            document.images['Screen'].src = Slides[NextSlide].src;
            CurrentSlide = NextSlide++;

	    if (document.getElementById) document.getElementById("CaptionBox").innerHTML = Caption[NextCaption];

	    CurrentCaption = NextCaption++;
	    CurrentLink = NextLink++;

            Message = 'Picture ' + (CurrentSlide+1) + ' of ' + Slides.length;

	    if (document.getElementById) document.getElementById("MessageBox").innerHTML = Message;
            if (Direction == 1) CacheNextSlide();
      }
      return true;
   }
}

function TheLink() {

if (!window.winslide||winslide.closed)
winslide=window.open(Links[NextLink])
else
winslide.location=Links[NextLink]
winslide.focus()

}

function Download() {
   if (Slides[NextSlide].complete) {
      SlideReady = true;
      if (document.getElementById) document.getElementById("MessageBox").innerHTML = Message;
//      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;
      if (document.getElementById) document.getElementById("MessageBox").innerHTML = 'Downloading next picture...';
//      	self.defaultStatus = 'Downloading next picture...';
      Slides[NextSlide] = CacheImage(Slides[NextSlide]);
      Download();
   }
   return true;
}

function StartSlideShow() {
   CurrentSlide = -1;
   CurrentCaption = -1;
   CurrentLink = -2;
   Slides[0] = CacheImage(Slides[0]);
   SlideReady = true;
   ShowSlide(1);
}