<PUBLIC:COMPONENT>
	<PUBLIC:ATTACH EVENT="onclick" ONEVENT="CopySuggestedLineItem()"/>

	<script Language="Javascript">
		function CopySuggestedLineItem()
		{
			var aActuals = GetActualsColumn();
			var aSuggesteds = GetSuggestedColumn();
		
			if(element.getAttribute("copyall") == null)
			{	
				// now copy the value from the source into the text box in the relevant
				// row/column
				element.parentElement.cells[aActuals.cellIndex].firstChild.value = element.innerText;
			}
			else
			{
				// need to copy all values from the table
				var aTable = GetTableElement(element);
				var aRow;
				var i;
				for(i=0;i<aTable.rows.length;i++)
				{
					aRow = aTable.rows[i];
					if(aRow.cells[aActuals.cellIndex].children.length > 0)
					{
						aRow.cells[aActuals.cellIndex].firstChild.enabled = "false";
						aRow.cells[aActuals.cellIndex].firstChild.value = aRow.cells[aSuggesteds.cellIndex].innerText;
						aRow.cells[aActuals.cellIndex].firstChild.enabled = "true";
					}
				}	
			}
		}
		
		function GetSuggestedColumn()
		{
			return window.document.getElementById("suggestedQuantities");
		}

		function GetActualsColumn()
		{
			return window.document.getElementById("currentQuantities");
		}
		
		function GetTableElement(inSource)
		{
			if(inSource.tagName.toLowerCase() == "table")
			{
				return inSource;
			}
			else if(inSource.tagName.toLowerCase() == "body")
			{
				return null;
			}
			else if(inSource.getAttribute("table") != null)
			{
				return window.document.getElementById(inSource.getAttribute("table"));
			}
			else
			{
				var aElement = inSource.parentElement;
				return GetTableElement(aElement);
			}
		}
	</script>
</PUBLIC:COMPONENT>
