var photos = new Object();
photos.aantal = 0;

var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;

function photo_popup(nr){
	if (photos[nr]){
		var ID = photos[nr].ID;
		var width = photos[nr].width * 2;
		var height = photos[nr].height * 2;
		var html = "";
		
		if (width > height) {	// landscape
			html = html + '<table width="600" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">';
			html = html + '<tr><td height="'+ (height + 5) + '" colspan="5" align="center" valign="top"><img src="http://fotos.stichtingtoverbal.nl/foto/' + ID + '" alt="" title="Klik om te sluiten" onClick="photo_popup_close(); return false;"></'+'td></'+'tr>';	
			html = html + '<tr><td height="25" width="95" align="right">';
			html = html + '</td>';
				if (photos.URL != '') {
				html = html + '<td width="200" align="right"><a href="http://fotos.stichtingtoverbal.nl/e-card/send/' + ID + '" target="_blank" onclick="popup_ecard(' + ID + '); return false;"><img src="http://fotos.stichtingtoverbal.nl/img/ecard-nl.gif" alt="Stuur deze foto als E-card" width="190" height="25" border="0"></a></td>';
				html = html + '<td width="10"></td>';
				html = html + '<td width="200" align="left"><a href="'+ photos.URL + '" target="_top"><img src="http://fotos.stichtingtoverbal.nl/img/serie-nl.gif" alt="Bekijk de complete foto-serie" width="190" height="25" border="0"></a></td>';
			} else {
				html = html + '<td width="105"></td>';
				html = html + '<td width="200" align="center"><a href="http://fotos.stichtingtoverbal.nl/e-card/send/' + ID + '" target="_blank" onclick="popup_ecard(' + ID + '); return false;"><img src="http://fotos.stichtingtoverbal.nl/img/ecard-nl.gif" alt="Stuur deze foto als E-card" width="190" height="25" border="0"></a></td>';
				html = html + '<td width="105"></td>';
			}
			html = html + '<td width="95" align="left">';
			html = html + '<img src="/count/' + ID + '" width="1" height="1" alt=""></td></tr>';
			html = html + '</table>';
			document.getElementById('fotoDiv').innerHTML = html;
			document.getElementById('fotoDiv').style.width='600px';
			document.getElementById('fotoDiv').style.height= '' + (height + 30) + 'px';
			
			if (window.innerWidth) { //if browser supports window.innerWidth
				screenwidth = window.innerWidth;
				screenheight = window.innerHeight;
				screentop = window.pageYOffset;
				screenleft = window.pageXOffset;
			} else {
				screenwidth = iebody.clientWidth;
				screenheight = iebody.clientHeight;
				screentop = iebody.scrollTop;
				screenleft = iebody.scrollLeft;
			}
			if (screenwidth > 612) {
				fotoDivLeft = parseInt((screenwidth - 612) /2);
			} else {
				fotoDivLeft = 0;
			}
			fotoDivLeft = 20;
			fotoDivTop = parseInt(screentop + (screenheight - 642) /2);
			if (fotoDivTop <0) fotoDivTop = 0;
			fotoDivTop = fotoDivTop + 100;
			document.getElementById('fotoDiv').style.left = fotoDivLeft + 'px';
			document.getElementById('fotoDiv').style.top = fotoDivTop + 'px';

			document.getElementById('fotoDiv').style.display='block';
			//overlib(html, WIDTH, 612 , HEIGHT, 442 ,  FULLHTML, STICKY, CLOSECLICK, CENTERPOPUP );
		} else { //portrait
			html = html + '<table width="400" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">';

//			html = html + '<tr><td width="25" height="505"></td><td width="5" rowspan="4"></td>';
			html = html + '<td colspan="3" height="605" rowspan="3" align="center" valign="top"><img src="http://fotos.stichtingtoverbal.nl/foto/' + ID + '" alt="" title="Klik om te sluiten" onClick="photo_popup_close(); return false;"></td>';
//			html = html + '<td width="5" rowspan="4"></td><td width="25"></td>';
			html = html + '</tr><tr>';
//			html = html + '<tr><td height="25" align="right">';
			html = html + '</td>';				
			html = html + '<td align="left">';
			html = html + '</td></tr>';
			html = html + '<tr><td height="75"></td><td></td></tr>';
//			html = html + '<tr><td height="25"></td>';
			html = html + '<tr>';
			if (photos.URL != '') {
				html = html + '<td height="25" width="200" align="right"><a href="http://fotos.stichtingtoverbal.nl/e-card/send/' + ID + '" target="_blank" onclick="popup_ecard(' + ID + '); return false;"><img src="http://fotos.stichtingtoverbal.nl/img/ecard-nl.gif" alt="Stuur deze foto als E-card" width="190" height="25" border="0"></a></td>';
				html = html + '<td width="10"></td>';
				html = html + '<td width="200" align="left"><a href="'+ photos.URL + '" target="_top"><img src="http://fotos.stichtingtoverbal.nl/img/serie-nl.gif" alt="Bekijk de complete foto-serie" width="190" height="25" border="0"></a></td>';
			} else {
				html = html + '<td height="25" width="105"></td>';
				html = html + '<td width="200" align="center"><a href="http://fotos.stichtingtoverbal.nl/e-card/send/' + ID + '" target="_blank" onclick="popup_ecard(' + ID + '); return false;"><img src="http://fotos.stichtingtoverbal.nl/img/ecard-nl.gif" alt="Stuur deze foto als E-card" width="190" height="25" border="0"></a><img src="http://fotos.stichtingtoverbal.nl/count/' + ID + '" width="1" height="1" alt=""></td>';
				html = html + '<td width="105"></td>';
			}
//			html = html + '<td width="400" align="center"><a href="http://fotos.stichtingtoverbal.nl/e-card/send/' + ID + '" target="_blank" onclick="popup_ecard(' + ID + '); return false;"><img src="http://fotos.stichtingtoverbal.nl/img/ecard-nl.gif" alt="Stuur deze foto als E-card" width="190" height="25" border="0"></a></td>';
//			html = html + '<td><img src="http://fotos.stichtingtoverbal.nl/count/' + ID + '" width="1" height="1" alt=""></td></tr>';
			html = html + '</table>';
			document.getElementById('fotoDiv').innerHTML = html;
			document.getElementById('fotoDiv').style.width='400px';
			document.getElementById('fotoDiv').style.height='630px';
			
			if (window.innerWidth) { //if browser supports window.innerWidth
				screenwidth = window.innerWidth;
				screenheight = window.innerHeight;
				screentop = window.pageYOffset;
				screenleft = window.pageXOffset;
			} else {
				screenwidth = iebody.clientWidth;
				screenheight = iebody.clientHeight;
				screentop = iebody.scrollTop;
				screenleft = iebody.scrollLeft;
			}
			if (screenwidth > 612) {
				fotoDivLeft = parseInt((screenwidth - 412) /2);
			} else {
				fotoDivLeft = parseInt((612 - 472) /2);
			}
			fotoDivLeft = parseInt((612 - 412) /2);
			fotoDivLeft = fotoDivLeft + 20;
			fotoDivTop = parseInt(screentop + (screenheight - 642) /2);
			if (fotoDivTop <0) fotoDivTop = 0;
			document.getElementById('fotoDiv').style.left = fotoDivLeft + 'px';
			document.getElementById('fotoDiv').style.top = fotoDivTop + 'px';
			document.getElementById('fotoDiv').style.display='block';
			//overlib(html, WIDTH, 472 , HEIGHT, 642,  FULLHTML, STICKY, CLOSECLICK, CENTERPOPUP );
		}
		return true;
	}
}

function photo_popup_close(){
	document.getElementById('fotoDiv').style.display='none';
}
