var gbl_currentimg = 0;
var gbl_totalimg = 0;

function initimg() {
	var images = document.getElementById('images');
	var prevbutton = document.getElementById('previous');
	var nextbutton = document.getElementById('next');
	var initpassed = false;
	if(images) {
		var lis = images.getElementsByTagName('li');
		if(lis.length > 0) {
			for(var i=0;i<lis.length;i++) {
				if(lis[i].id != 'next' && lis[i].id != 'previous' && lis[i].className != 'current')
				{
					initpassed = true;
				}
			}
			gbl_totalimg = lis.length - 2;
			gbl_currentimg = 1;
		}
	}
	
	if(initpassed == false) {
		if(prevbutton) {prevbutton.style.display = 'none';}
		if(nextbutton) {nextbutton.style.display = 'none';}
	}
}

function previmg() {
	if(gbl_totalimg > 0 && gbl_currentimg > 1) {
		var images = document.getElementById('images');
		var nextbutton = document.getElementById('next');
		var prevbutton = document.getElementById('previous');
		if(images && nextbutton && prevbutton) {
			var lis = images.getElementsByTagName('li');
			
			lis[gbl_currentimg].className = 'notcurrent';
			lis[gbl_currentimg - 1].className = 'current';
			
			gbl_currentimg = gbl_currentimg - 1;
			
			if(gbl_currentimg == 1) {
				prevbutton.className = 'none';
			}
			if(gbl_currentimg < gbl_totalimg)  {
				nextbutton.className = '';
			}
		}		
	}	
	return false;
}
function nextimg() {
	if(gbl_totalimg > 0 && gbl_currentimg < gbl_totalimg) {
		var images = document.getElementById('images');
		var nextbutton = document.getElementById('next');
		var prevbutton = document.getElementById('previous');
		if(images && nextbutton && prevbutton) {
			var lis = images.getElementsByTagName('li');
			
			lis[gbl_currentimg].className = 'notcurrent';
			lis[gbl_currentimg + 1].className = 'current';
			
			gbl_currentimg = gbl_currentimg + 1;
			
			if(gbl_currentimg == gbl_totalimg) {
				nextbutton.className = 'none';
			}
			if(gbl_currentimg > 1)  {
				prevbutton.className = '';
			}
		}		
	}	
	return false;
}

function checkfields_v2()
{
	var pass=true;
	var alerttext="De volgende fouten zijn geconstateerd:"
	var arguments=checkfields_v2.arguments;
	if (arguments.length > 0) {
		for (i=0; i<(arguments.length-2); i+=3)	{
			if (document.getElementById(arguments[i]).value=="") {
				alerttext+="\n- "+arguments[i+1]+" is verplicht";
				pass=false;
			}
		}
	}
	if (pass==false) {
		alert(alerttext);
		return false;
	}
	else {
		return true;
	}
}
