<!-- 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 = 1;

// List image names without extension
var myImg= new Array(count)
 myImg[0]= "Molly_Nilsson_01";
 myImg[1]= "Molly_Nilsson_02";

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


// Imagetexts:
var myText= new Array(count)
 myText[0]= "Molly Nilsson - Illustration for flyer<br>in collaboration with Troisbarres.";
 myText[1]= "Molly Nilsson - Illustration for flyer - Detail<br>in collaboration with Troisbarres.";

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

// 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;
