pathBig = "images/photos/";
pathThumb = "images/photos/thumbs/";

function telThumbs() {
	var ttelThumbs = foto.length;
	if (ttelThumbs>3) {
		ttelThumbs = 3;
	}
	return ttelThumbs;
}

/*
function updateThumbActiveDiv() {
	divthumb1 = document.getElementById('divThumb1');
	divthumb2 = document.getElementById('divThumb2');
	divthumb3 = document.getElementById('divThumb3');	
	setClass1 = "";
	setClass2 = "";
	setClass3 = "";
	if (huidigefotono == huidigethumbno) {
		setClass1 = "active";
	} else if (huidigefotono == (huidigethumbno+1)) {
		setClass2 = "active";
	} else if (huidigefotono == (huidigethumbno+2)) {
		setClass3 = "active";
	}
	divthumb1.className = setClass1;
	divthumb2.className = setClass2;
	divthumb3.className = setClass3;
}
*/

function updateThumbActiveDiv() {
	var vTelThumbs = telThumbs();
	for (i=0; i!=vTelThumbs; i++) {
		divthumb = document.getElementById('divThumb'+(i+1));
		//alert('divThumb'+(i+1));
		setClass = "";
		if (huidigefotono == (huidigethumbno + i)) {
			setClass = "active";
		} else {
			setClass = "";
		}
		divthumb.className = setClass;
	}
}
/*
function photoSwitch(f) {
	fo = document.getElementById('productPhoto');
	setf = f + huidigethumbno;
	huidigefotono = setf;
	fo.src = pathBig + foto[setf] + ".jpg";
	
	if (f == 0) {
		setClass1 = "active";
		setClass2 = "";
		setClass3 = "";
	}
	if (f == 1) {
		setClass1 = "";
		setClass2 = "active";
		setClass3 = "";
	}
	if (f == 2) {
		setClass1 = "";
		setClass2 = "";
		setClass3 = "active";
	}
//	divthumb1.className = setClass1;
//	divthumb2.className = setClass2;
//	divthumb3.className = setClass3;
	updateThumbActiveDiv();
	
	//alert(document.getElementById('productPhoto').src);
	//huidigefoto = fotono;
	//alert( pathThumb + foto[fotono] + ".jpg");
}
*/
function photoSwitch(f) {
	fo = document.getElementById('productPhoto');
	setf = f + huidigethumbno;
	huidigefotono = setf;
	fo.src = pathBig + foto[setf] + ".jpg";
	updateThumbActiveDiv();
}


function photoForward() {
	aantalfotos = foto.length;
	var vTelThumbs = telThumbs();
	if (huidigethumbno<(aantalfotos-vTelThumbs)) {
		huidigethumbno++;
		for (i=0; i!=vTelThumbs; i++) {
			document.getElementById('productPhotoThumb'+(i+1)).src = pathThumb + foto[(huidigethumbno+i)] + ".jpg";
		}
		//document.getElementById('productPhotoThumb1').src = pathThumb + foto[huidigethumbno] + ".jpg";
		//document.getElementById('productPhotoThumb2').src = pathThumb + foto[(huidigethumbno+1)] + ".jpg";
		//document.getElementById('productPhotoThumb3').src = pathThumb + foto[(huidigethumbno+2)] + ".jpg";
		updateThumbActiveDiv();
		showhidePhotoArrows();
	}
}

function photoBack() {
	var vTelThumbs = telThumbs();
	if (huidigethumbno>0) {
		huidigethumbno--;
		for (i=0; i!=vTelThumbs; i++) {
			document.getElementById('productPhotoThumb'+(i+1)).src = pathThumb + foto[(huidigethumbno+i)] + ".jpg";
		}
		//document.getElementById('productPhotoThumb1').src = pathThumb + foto[huidigethumbno] + ".jpg";
		//document.getElementById('productPhotoThumb2').src = pathThumb + foto[(huidigethumbno+1)] + ".jpg";
		//document.getElementById('productPhotoThumb3').src = pathThumb + foto[(huidigethumbno+2)] + ".jpg";
		updateThumbActiveDiv();
		showhidePhotoArrows();
	}
}

function showhidePhotoArrows() {
	var vTelThumbs = telThumbs();
	aantalfotos = foto.length;
	document.getElementById('divPhotoArrowBack').display = 'none';
	//alert(document.getElementById('divPhotoArrowBack').display);
	
	arrowBack = document.getElementById('divPhotoArrowBack');
	arrowForward = document.getElementById('divPhotoArrowForward');
	if (huidigethumbno==0) {
		//alert("hide back");
		arrowBack.style.visibility = 'hidden';
		arrowBack.style.display = 'none';
	} else {
		//alert("show back");
		arrowBack.style.visibility = 'visible';
		arrowBack.style.display = 'inline';
	}
	if (huidigethumbno==(aantalfotos-vTelThumbs)) {
		arrowForward.style.visibility = 'hidden';
		arrowForward.style.display = 'none';
	} else {
		arrowForward.style.visibility = 'visible';
		arrowForward.style.display = 'inline';
	}
}
