<!-- 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(16)
  myImg[0]= "pic1";
  myImg[1]= "pic2";
  myImg[2]= "pic3";
  myImg[3]= "pic4";
  myImg[4]= "pic5";
  myImg[5]= "pic6";
  myImg[6]= "pic7";
  myImg[7]= "pic8";
  myImg[8]= "pic9";
  myImg[9]= "pic10";
  myImg[10]= "pic11";
  myImg[11]= "pic12";
  myImg[12]= "pic13";
  myImg[13]= "pic14";
  myImg[14]= "pic15";
  myImg[15]= "pic16";
  myImg[16]= "pic17";
  myImg[17]= "pic18";
  myImg[18]= "pic19";
  myImg[19]= "pic20";
  
// Tell browser where to find the image
myImgSrc = "/images/Rincondeluna/";

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

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>18){
    var l = i
  } else {
    var l = i+=1;
  }
  document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;
}

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

