//<SCRIPT>
//function openCommentsWindow(id) 
//function MM_swapImgRestore() 
//function MM_preloadImages()
//function MM_findObj(n, d) 
//function MM_swapImage()

    function openCommentsWindow(id) 
	{
    	newWindow = window.open("comments.asp?log-id="+id+"&cmd=view" ,"comments","width=345, height=400, left=0, top=0 scrollbars=yes");
	    newWindow.focus();
    }

	function MM_swapImgRestore() 
	{ //v3.0
  		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function MM_preloadImages() 
	{ //v3.0
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) 
	{ //v3.0
  		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
	}

	function MM_swapImage() 
	{ //v3.0
		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}	

function FillItemBodyList(strItemName, aKeys, aValues)
{
	var nCnt
	var nCol
	var nI
	var nX
	var nZ
				
	var oTab;
	var oRow;
	var oCell;
	
	var strId;
	var aRow;
	var nRow;
	var nRowCount;
	var nFld;
	var oBefore;
	var oTABLE;
	var aRec;
	var oRc;
	var l1;
	var l2;
	

	oTABLE = document.all.item(strItemName);

	if ((oTABLE != undefined) && (oTABLE != null) )
	{
		
		oTab = oTABLE.tBodies(0);
		
		//***************************************************************************************
		//* First parse template rows. 
		//* Template rows are saved in property templateRows of TABLE and removed from the body.
		//* if this property exists, use this property otherwise parse template rows.
		//* Check with parsing if non-templaterows come after template rows. In this case rows 
		//* have to be inserted before the first non-template row otherwise rows can just be added
		//* at the end of the body (faster)
		//***************************************************************************************
		
		if (typeof(aRow = oTABLE.templateRows) != 'undefined')
		{
			nRowCount = aRow.length - 1;
			oBefore = oTABLE.templateRowBefore;

		} else
		{
			aRow = new Array();
			nRowCount = -1;
			nCol = aKeys.length;

			l1 = oTab.rows.length;
			for (nI = 0; nI < l1; nI ++)
			{
				if (oTab.rows[nI].id == 'template')
				{
					nRowCount++;
					oRow = oTab.rows[nI];
					aRow[nRowCount] = oRow;
					l2 = oRow.children.length;
					// RDK zebraatjes
					// even backward compatible zijn: als in alle templates de templateregel een class heeft kan dit weg:
					if (oRow.className == "") oRow.className = "TabRow";
					// RDK zebraatjes
					for ( nX = 0 ; (nX < l2); nX++)
					{
						oCell = oRow.children[nX];
						
						//**************************************************************
						//* Create callback (onformat) function. 
						//**************************************************************
						CheckUserFormat(oCell);

						strId = oCell.id.toLowerCase();
						if (strId != "")
						{
							for (nZ = 0; (nZ < nCol); nZ++)
							{
								if ( aKeys[nZ].toLowerCase() == strId)
								{
									oCell.templateIndex = nZ;
									break;
								}
							}
						}	

					}								

				}	else
				{
					if (aRow.length > 0)
					{
						if (typeof(oBefore) == 'undefined')
						{
							oBefore = oTab.rows[nI];
							oTABLE.templateRowBefore = oBefore;
						}	
					}
				}
			}	
			
			oTABLE.templateRows = aRow;
			// RDK zebraatjes
			// even backward compatible zijn: als in alle templates de templateregel een class heeft kan dit weg:
			
						
			var ZebraStyle = null;
			var intItem = GetClassNumber("." + aRow[0].className + "ZEBRA");

			if (intItem  > 0)	
			{
				ZebraStyle = aRow[0].className + "ZEBRA";
			}
			// RDK
			
			for (nI in aRow)
			{
				oTab.removeChild(aRow[nI]);
			}
		}
				
		//**************************************************************
		//*	Calculate total number of rows
		//**************************************************************
		
				
		if (nRowCount >= 0)
		{
			nCol = aKeys.length;
			if (aValues.length > 0)
			{
				nCnt = aValues.length / nCol;
			}
			else
			{
				nCnt = 0;
			}	

			if (nCnt > 0)								//* we have to fill in values
			{



				//**************************************************************
				//* Process all rows in a loop. In the first iteration an index
				//* into the value array is build up (aIx) to speed up processing.
				//* For each cell (whether or not there is a value) the onformat
				//* function is called. When this function returns true, the 
				//* onformat function has filled the cell so we don't touch it
				//* anymore.
				//**************************************************************
				
				for (nI = 0 ; (nI < nCnt); nI++)
				{
					
					aRec = aValues.slice((nI * nCol), (nI * nCol) + nCol);
					for (nRow = 0; (nRow <= nRowCount); nRow++)								//* for each template row
					{
						oRow = aRow[nRow].cloneNode(true);
						oRow.RowCopy = '1';																			//* Set property so we can find these rows back
						// RDK zebraatjes bij even regels
						if ((nI %2))
						{
							oRow.className = ZebraStyle;
						}	
						// RDK zebraatjes
						oRc = oRow.children;
						l1 = oRc.length;
						for (nZ = 0; (nZ < l1); nZ++)						//* Process every cell in the row
						{
							oCell = oRc[nZ];
							if (typeof(oCell.templateIndex) != 'undefined')										//* Is this field linked to a value?
							{
								FillControl(oCell, aRec[oCell.templateIndex], nI + 1, aKeys, aRec);

							} else
							{
								FillControl(oCell, void aRec[0], nI + 1, aKeys, aRec);
							}
						
						} 

						if (typeof(oBefore) == 'undefined')
						{
							oTab.insertBefore(oRow);
						} else
						{
							oTab.insertBefore(oRow, oBefore);
						}	
							

					}
					// RDK zebraatjes
					//bEven = !bEven;
					// RDK zebraatjes
				}	
			}	
		}
	}				
}

