var win=null;

function picopen(id, width,height, margin) {
	w=width+2*margin;
	h=height+2*margin+2*margin;
	l = (screen.width) ? (screen.width-w)/2 : 0;
	t = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+t+',left='+l+',status=no,scrollbars=no,resizable=no'
	
	// close previous opened window
	if ((win!=null)&&(!win.closed)) { win.close(); }
	// create new window
	url='includes/preview.php?id='+id;
	win = window.open(url,null,settings);
	if(win.focus){win.focus();}
}