<h3>Title</h3>

<table>
<tr>
<th id="participantField">patientCode</th>
<td id="participantCode">Loading1b</td>
</tr>
<tr>
<th id="visitField">visitCode</th>
<td id="visitCode">Loading2</td>
</tr>
</table>

<div id="organ3">
	<table>
	<tr>
		<td id="CT_organ3"></td>
		<td id="PET_organ3"></td>
		<td id="SUVall_organ3"></td>
		<td id="SUVparticipant_organ3"></td>
	</tr>
	<tr>
		<td id="CT_organ4"></td>
		<td id="PET_organ4"></td>
		<td id="SUVall_organ4"></td>
		<td id="SUVparticipant_organ4"></td>
	</tr>
	<tr>
		<td id="CT_organ5"></td>
		<td id="PET_organ5"></td>
		<td id="SUVall_organ5"></td>
		<td id="SUVparticipant_organ5"></td>
	</tr>
	</table>
</div>
<div id="debugDiv">
	<textarea id="debugCode"></textarea>
</div>

<script type="text/javascript">

let searchParams = new URLSearchParams(window.location.search);

//update this to pick crfRef from url
let participantCode=searchParams.get('participantCode');
let visitCode=searchParams.get('visitCode');
document.getElementById("participantCode").innerHTML=participantCode;
document.getElementById("visitCode").innerHTML=visitCode;
let project=LABKEY.ActionURL.getContainer();
document.getElementById("debugCode").value+='\n'+project;

let server="https://merlin.fmf.uni-lj.si/labkey";
let basePath=server+"/_webdav/";
basePath+=project;
basePath+="/@files/preprocessedImages/";
basePath+=participantCode+"/"+visitCode+"/";
document.getElementById("debugCode").value+='\n'+basePath;
let studyPath=server+project;

//let divImg=document.getElementById("organ3_PET");

let organs=["3","4","5"];
let im=["PET","CT"];
for (let i=0;i<organs.length;i++){
	let organ=organs[i];
	let type="PET";

	let img=document.createElement('img');
	let imgSrc=basePath+participantCode+"-"+visitCode+"_"+type+"_"+organ+"_v5.png";
	img.src=imgSrc;
	img.width="300";
	document.getElementById(type+"_organ"+organ).appendChild(img);
							

	type="CT";
	let img1=document.createElement('img');
	let img1Src=basePath+participantCode+"-"+visitCode+"_"+type+"_"+organ+"_v5.png";
	img1.src=img1Src;
	img1.width="300";
	document.getElementById(type+"_organ"+organ).appendChild(img1);
}
LABKEY.requiresScript('/vis/genericChart/genericChartHelper.js', 
      function(){LABKEY.vis.GenericChartHelper.loadVisDependencies(plotAll);});
LABKEY.requiresScript('/vis/genericChart/genericChartHelper.js', 
      function(){LABKEY.vis.GenericChartHelper.loadVisDependencies(plotParticipant);});


</script>