// JavaScript Document
var currIndex = 0;
var srcArr= ['arrow.png','arrow_wave.png','arrow_crash.png'];
var commentArr = ['Arrow. Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.',
'Arrow wave. Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.',
'Arrow crash. Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.'];

var imgToChange;
var commentToChange;

function initGallery() {
	var imgNavLinks = document.getElementById('img_navigation').getElementsByTagName('a');
	imgNavLinks[0].onclick = ShowPrevImg;
	imgNavLinks[1].onclick = ShowNextImg;
	imgToChange = document.getElementById('img_container').getElementsByTagName('img')[0];
	commentToChange = document.getElementById('img_comments').getElementsByTagName('p')[0];
}

function ShowPrevImg() {
	if ((currIndex-1)>=0) {
		currIndex--;
		imgToChange.src = 'img/'+srcArr[currIndex];
		commentToChange.innerHTML = commentArr[currIndex];
	}
	else {
		currIndex=0;
		imgToChange.src = 'img/'+srcArr[currIndex];
		commentToChange.innerHTML = commentArr[currIndex];
	}
}

function ShowNextImg() {
	if ((currIndex+1)<srcArr.length) {
		currIndex++;
		imgToChange.src = 'img/'+srcArr[currIndex];
		commentToChange.innerHTML = commentArr[currIndex];
	}
	else {
		currIndex=0;
		imgToChange.src = 'img/'+srcArr[currIndex];
		commentToChange.innerHTML = commentArr[currIndex];
	}
}
