<!-- 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/ */

var i = 0;
var count = 2;

// List image names without extension
var myImg= new Array(count)
 myImg[0]= "Bar_Music_Hall_01";
 myImg[1]= "Bar_Music_Hall_02";
 myImg[2]= "Bar_Music_Hall_03";

// ImageNumbers:
var myNr= new Array(count)
 myNr[0]= "1/3";
 myNr[1]= "2/3";
 myNr[2]= "3/3";

// Imagetexts:
var myText= new Array(count)
 myText[0]= "Bar Music Hall - Wallpaper for a bar in London-Shoreditch";
 myText[1]= "Bar Music Hall - Wallpaper for a bar in London-Shoreditch";
 myText[2]= "Bar Music Hall - Wallpaper for a bar in London-Shoreditch";
 
// Tell browser where to find the image
myImgSrc = "images/2005/";

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

// Create function to load image
function loadImg(){
  document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;
  document.getElementById("numbers").innerHTML = myNr[i];
  document.getElementById("imgtxt").innerHTML = myText[i];
}

// Create link function to switch image backward
function prev(){
  if(i>0){
  i = i-=1;
  document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;
  document.getElementById("numbers").innerHTML = myNr[i];
  document.getElementById("imgtxt").innerHTML = myText[i];
}
}

// Create link function to switch image forward
function next(){
  if(i<count){
  i = i+=1;
  document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;
  document.getElementById("numbers").innerHTML = myNr[i];
  document.getElementById("imgtxt").innerHTML = myText[i];
}  
}

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