<!-- Paste this code into an external JavaScript file named: nextPrevious.js  -->

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Solomon, the Sleuth :: http://www.freewebs.com/thesleuth/scripts/ */

// List image names without extension
var myImg= new Array(4)
  myImg[0]= "Bloxham_Tom";
  myImg[1]="3-Towers-Manchester-residential";
  myImg[2]= "Chips-Manchester-mixed-use";
  myImg[3]= "Fort-Dunlop-Birmingham-commercial";
  myImg[4]= "Royal-William-Yard-Plymouth-mixed-use";


// Tell browser where to find the image
myImgSrc = "images/";

// Tell browser the type of file
myImgEnd = ".gif"

var i = 0;

// Create function to load image
function loadImg(){
  document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;
}

// Create link function to switch image backward
function prev(){
  if(i<1){
    var l = i
  } else {
    var l = i-=1;
  }
  document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}

// Create link function to switch image forward
function next(){
  if(i>3){
    var l = i
  } else {
    var l = i+=1;
  }
  document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}

// Load function after page loads
window.onload=loadImg;

