
// three entries per image: seqno, type, caption
var ent = 3;

function photoClass(s) {
	if (s == "v") {
		return("photo_ver");
	} else {
		return("photo_hor");
	}
}

function toolTip(x) {
	var r = todayImages[ent*x+1];
	var s = todayImages[ent*x+2];
	if ((r.length > 1) && (s.length > 0)) {
		s = s + '<br>';
	}
	if (r.length > 1) {
		s = s + '<i>video, ' + r.substring(1, r.length) + '</i>';
	}
	if (s.length > 0) {
		return('onMouseOver="doTooltip(event, '
			+	"'" + s.replace(/'/g, "&amp;#39;")
			+	"'" + ');" onMouseOut="hideTip();"');
	} else {
		return('');
	}
}

function writeImageTable() {
	document.write('<table class=photos><tr>');
	for (var x = 0; x < todayImages.length/ent; x++) {
		document.write('<td><a href="#" onclick="return(showMedia(' + x.toString() + '));" class='
		+				photoClass(todayImages[ent*x+1]) + '><img id=t' + x.toString() + ' src="thumb/IMG_'
		+				todayImages[ent*x] + '_thumb.jpg" ' + toolTip(x) + '></a></td>');
		if ((x+1)/5 == parseInt((x+1)/5)) {
			document.write('</tr><tr>');
		}
	}
	if (todayImages.length < 1) {
		document.getElementById("currentcaption").innerHTML = "van deze dag zijn er helaas geen foto's";
//		document.write("<td align=center colspan=2><div class=caption>Van deze dag zijn er helaas geen foto's.</div></td>");
	}
	document.write('</tr>\n</table>\n');
}

function showMedia(n) {
	// return if there are no images for today
	if (todayImages.length < 1) { return false }

	// color thumbnail border
	document.getElementById('t' + n.toString()).style.borderColor = '#828538';
		// document.getElementById('maintitle').style.color;

	// swap main image or movie
	if (todayImages[3*n+1].substr(0,1) == "m") {
		document.getElementById("currentimage").style.display = 'none';
		document.getElementById("currentmovie").style.display = 'none';
		document.getElementById("currentmovie").innerHTML =
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width=320 height=258\n'
		+	'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"\n'
		+	'><param name="movie" value="movies/MVI_' + todayImages[ent*n] + '.swf"\n'
		+	'><param name="quality" value=high\n'
		+	'><embed src="movies/MVI_' + todayImages[ent*n] + '.swf" quality=high\n'
		+	'	type="application/x-shockwave-flash" width=320 height=258\n'
		+	'	pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"\n'
		+	'></embed'
		+	'></object>'
		document.getElementById("currentmovie").style.display = 'block';
	} else if (todayImages[3*n+1].substr(0,1) == "y") {
		document.getElementById("currentimage").style.display = 'none';
		document.getElementById("currentmovie").style.display = 'none';
		document.getElementById("currentmovie").innerHTML =
			'<object width="425" height="355"\n'
		+	'><param name="movie" value="http://www.youtube.com/v/' + todayImages[ent*n] + '"\n'
		+	'></param><param name="wmode" value="transparent"></param\n'
		+	'><embed src="http://www.youtube.com/v/' + todayImages[ent*n] + '"\n'
		+	'type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"\n'
		+	'></embed></object>'
		document.getElementById("currentmovie").style.display = 'block';
	} else {
		document.getElementById("currentmovie").style.display = 'none';
		document.getElementById("currentimage").firstChild.src = "small/IMG_" + todayImages[ent*n] + "_small.jpg";
		document.getElementById("currentimage").style.display = 'block';
	}

	// show caption
	document.getElementById("currentcaption").innerHTML = todayImages[ent*n+2];
	
	// update prev/next buttons
	var nminus = n - 1;
	var nplus  = n + 1;
	if (nminus >= 0) {
		document.getElementById("button_prev_photo").innerHTML =
			'<a href="#" onclick="return(showMedia(' + nminus.toString() + '));" title="Vorige foto">'
		+	'<img src="images/but_prev.gif" class=navbutton align=left></a>';
		document.getElementById("button_prev_photo").style.display = 'block';
	} else {
		document.getElementById("button_prev_photo").style.display = 'none';
	}
	if (nplus < todayImages.length/ent) {
		document.getElementById("button_next_photo").innerHTML =
			'<a href="#" onclick="return(showMedia(' + nplus.toString() + '));" title="Volgende foto">'
		+	'<img src="images/but_next.gif" class=navbutton align=right></a>';
		document.getElementById("button_next_photo").style.display = 'block';
	} else {
		document.getElementById("button_next_photo").style.display = 'none';
	}
	return false;
}

// vim: set tabstop=4 shiftwidth=4 noexpandtab:
