function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';

	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-250;//150 is half popup's height
	//popUpDiv.style.top = popUpDiv_height + 'px';
	popUpDiv.style.top = 0 + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-350;//150 is half popup's width
	
	popUpDiv.style.left = window_width + 'px';
	//popUpDiv.style.left = 0 + 'px';
}

function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}
function setimage(imgname,imgholder,windowname,titel,opmerking,door) {
	//document.getElementById(imgholder).src=imgname;
//	<a href="#" onclick="popup('popUpDiv')"><IMG name="imgdiv" src=""></a>

	var vhref = '<a href="#" onclick="popup(\'popUpDiv\')">';
	var img = '<IMG name="imgdiv" src="'+imgname+'"></a><br/>';
	var table = '<table width="700px" cellpadding=2 cellspacing="1" align="center" >';
		table = table + '<tr >';
		table = table + '<td class="popupHeader" width=597px>Artikel '+titel;
		table = table + '</td>' ;
		table = table + '<td class="popUpClose" width=3px >';
		table = table + '<a href="#" onclick="popup(\'popUpDiv\')">';
		table = table + '<IMG alt="Klik om te sluiten" name="close" height="14px" width="14px" src="./style_red/cross.png"></a>';
		table = table + '</td>' ;
		table = table + '</tr>';
		table = table + '<tr align="center">';
		table = table + '<td with=100% colspan="2">'+opmerking;
		table = table + '</td>' ;
		table = table + '</tr>';		
		table = table + '<tr align="center">';
		table = table + '<td colspan="2">';
		if(door!=""){
			table = table + 'Opmerking: <i>'+door+'</i>';
		}	
		table = table + '</td>';
		table = table + '</tr>';
		table = table + '<tr  align="center">';
		table = table + '<td colspan="2">';
		table = table + vhref + img ;
		table = table + '</td>';
		table = table + '</tr>';		
		table = table + '</table>'; 
		table = '<p align="center">' + table + '</p>';
	
	document.getElementById(windowname).innerHTML=table;

	popup(windowname);		
}

