// JavaScript Document
// web portfolio changer
// generate random number to select random image

// List image names without extension
var myImg= new Array(12)
  myImg[0]= "slideshow1";
  myImg[1]= "slideshow2";
  myImg[2]= "slideshow3";
  myImg[3]= "slideshow4";
  myImg[4]= "slideshow5";
  myImg[5]= "slideshow6";
  myImg[6]= "slideshow7";
  myImg[7]= "slideshow8";
  myImg[8]= "slideshow9";
  myImg[9]= "slideshow10";
  myImg[10]= "slideshow11";
  myImg[11]= "slideshow12";
  myImg[12]= "slideshow13";

// Tell browser where to find the image
myImgSrc = "/images/";

// Tell browser the type of file
myImgEnd = ".jpg";

var i = 0;

// Create function to load image
function loadImg(){
  document.getElementById('slideshow').src = myImgSrc + myImg[i] + myImgEnd;
	var firstCaption = document.getElementById('caption' + i );
	firstCaption.className = 'show';  
}   

// Create link function to switch image backward
function showPrev(){
	var oldCaption = document.getElementById('caption' + i);
	oldCaption.className = 'hide';

  if(i<1){
    var l = i
  } else {
    var l = i-=1;
  }
  document.getElementById('slideshow').src = myImgSrc + myImg[l] + myImgEnd;
  var newCaption = document.getElementById('caption' + i);
  newCaption.className = 'show';
}

// Create link function to switch image forward

function showNext(){
	var oldCaption = document.getElementById('caption' + i);
	oldCaption.className = 'hide';
	
  if(i>11){
    var l = i
  } else {
    var l = i+=1;
  }
  document.getElementById('slideshow').src = myImgSrc + myImg[l] + myImgEnd;
  var newCaption = document.getElementById('caption' + i);
  newCaption.className = 'show';
}

// Load function after page loads
window.onload=loadImg;






//var imgNum=Math.floor(Math.random()*14)
//document.getElementById('slideshow').src = '/images/slideshow' + imgNum +'.jpg';
//var firstCaption = document.getElementById('caption' +imgNum);
//firstCaption.className = 'show';


//function showNext(imgNum) {
	//var oldCaption = document.getElementById('caption' + imgNum);
	//oldCaption.className = 'hide';
	// determine the next image number
	//var nextNum = (imgNum + 1);
	// if image number is 14, then reset to 1
	//if (nextNum = 14) {
	//	nextNum = 1;
	//}
	// replace the image with the next picture
	//document.getElementById('slideshow').src = '/images/slideshow' + imgNum +'.jpg';
	//show the new caption
	//var newCaption = document.getElementById('caption' + imgNum);
	//newCaption.className = 'show';
	//imgNum = nextNum;
//}
//function showPrev (imgNum) {
	//var oldCaption = document.getElementById('caption' + imgNum);
	//oldCaption.className = 'hide';
	// determine the previous image number
	//var prevNum = (imgNum - 1);
	// if image number is 0, then reset to 13
	//if (prevNum = 0) {
	//	prevNum = 13;
	//}
	// replace the image with the previous picture
	//document.getElementById('slideshow').src = '/images/slideshow' + prevNum +'.jpg';
	//show the new caption
	//var newCaption = document.getElementById('caption' + prevNum);
	//newCaption.className = 'show';
	//imgNum = prevNum;
//}

