///////////////////////////////////////////////////////////////////////////////
// main.js
//
// OMSCHRIJVING
//     JavaScript routines voor Combifoto en Fotografie Van Eerd
///////////////////////////////////////////////////////////////////////////////

// ============================================================================
// Variabelen
// ============================================================================

var currentIndex = 0;

// ============================================================================
// Functies
// ============================================================================

// ----------------------------------------------------------------------------
// getElementById
// ----------------------------------------------------------------------------

function getElementById(id) {
	var el = null;
	
	if (document.getElementById)
		el = document.getElementById(id);
		
	return el;
}

// ----------------------------------------------------------------------------
// prevImage
// ----------------------------------------------------------------------------

function prevImage() {
	var el = getElementById("image");
	if (el) {
		if (currentIndex > 0) {
			currentIndex--;
			el.src = IMAGES[currentIndex];
				
			el = getElementById("current");
			if (el)
				el.innerHTML = (currentIndex + 1).toString();
		}
	}
}

// ----------------------------------------------------------------------------
// nextImage
// ----------------------------------------------------------------------------

function nextImage() {
	var el = getElementById("image");	
	if (el) {
		if (currentIndex < IMAGES.length - 1) {
			currentIndex++;
			el.src = IMAGES[currentIndex];
			
			el = getElementById("current");
			if (el)
				el.innerHTML = (currentIndex + 1).toString();
		}
	}	
}

// ----------------------------------------------------------------------------
// initImage
// ----------------------------------------------------------------------------

function initImage() {
	var el = getElementById("image");
	if (el)
		el.src = IMAGES[currentIndex];
		
	var el = getElementById("current");
	if (el)
		el.innerHTML = (currentIndex + 1).toString();

	var el = getElementById("total");
	if (el)
		el.innerHTML = IMAGES.length.toString();
}

