	function SelectPart(id, control, lerr)
	{
		//add them to the listbox in the other control
		ClearErrorText(lerr);
		var opt;
		var idctr;
		var ctr;
		var flag;
		if (control.options.length > 19)
		{
			alert('There are already 20 parts selected. There is a 20 part maximum for searching');
		}
		else
		{
			for (idctr = 0 ; idctr < id.options.length; idctr++)
			{
				if (id.options(idctr).selected == true)
				{
					opt = document.createElement('OPTION');
					opt.value = id.options(idctr).value;
					opt.text = id.options(idctr).text;
					flag = 0;
					for (ctr = 0 ; ctr < control.options.length ; ctr++)
					{
						if (control.options(ctr).text == opt.text)
						{
							flag = 1;
						}
					}
					if (flag < 1)
					{
						if (control.options.length < 20)
						{
							control.options.add(opt, control.options.length);
						}
						else
						{
							alert('The maximum number of parts (20) has been reached.');
							return;
						}
					}
					else
					{
						alert('Item ' + opt.text + ' already selected');
					}
				}		
			}
		}
	}
	function KeystrokeRemovePart(id)
	{
		var keycode
		keycode = event.keyCode;
		if ((keycode == 32) | (keycode == 13))
		{
			// remove the part from the list
			RemovePart(id);
		}
	}
	function RemovePart(id)
	{
		var ctr
		for (ctr = id.options.length-1; ctr > -1; ctr--)
		{
			if (id.options(ctr).selected == true)
			{
				id.options.remove(ctr);
			}
		}
	}
	function KeystrokeAddPart(id, control, lerr)
	{
		var keycode
		keycode = event.keyCode;
		if ((keycode == 32) | (keycode == 13))
		{
			// add the part to the list
			SelectPart(id, control, lerr);
		}
	}
	function HighlightParts(id)
	{
		var ctr
		for (ctr = 0; ctr < id.options.length; ctr++)
		{
			id.options(ctr).selected = true;
		}
	}
    function SetFocus(control)
    {
       if (control != null)
          control.focus();
    }

    function OnLoadFocus(sName)
    {
       SetFocus(document.getElementById(sName));
    }
    function ValidatePartNumber(id, ptlist, lerr)
    {
		// check the part number field and see if it is a part type
		// or whether it should be treated as a description
		ClearErrorText(lerr);
		if (id.value.length >= 3)
		{
			if (id.value.length == 3)
			{
				if ((id.value > 0) | (id.value < 999))
				{
					// try to find the part type in the hidden text box
					var opt = document.createElement('OPTION');
					var idctr;
					var flag = false;
					for (idctr = 0; idctr < ptlist.options.length; idctr++)
					{
						if (ptlist.options(idctr).value == id.value)
						{
							ptlist.options(idctr).selected = true;
							flag = true;
							break;
						}
					}
					//if (flag != true)
					//{
					//	alert('Invalid Part Type entered');
					//	SetFocus(id);
					//}
				}
			}
			else
			{
				if (id.value.substring(3,4) == '.' || id.value.substring(3,4) == '-')
				{
					//a complete HIC has been entered
				}
				else
				{
					// try to find the part description in the select list
					var opt = document.createElement('OPTION');
					var idctr;
					var flag = false;
					var textval;
					for (idctr = 0; idctr < ptlist.options.length; idctr++)
					{
						textval = ptlist.options(idctr).text.substring(0,
							id.value.length);
						if (textval.toUpperCase() == id.value.toUpperCase())
						{
							ptlist.options(idctr).selected = true;
							flag = true;
							break;
						}
					}
					if (flag != true)
					{
						alert('No part description match found');
						SetFocus(id);
					}
				}
			}
		}
		else
		{
			if (id.value.length > 0)
			{
				alert('Minimum input is 3 characters');
				SetFocus(id);
			}
		}
    }
    function ClearErrorText(id)
    {
		id.innerHTML = '';
    }
    function SetControlVisible(id)
    {
		id.visible = false;
    }
    function MoreInfo()
    {
		alert('More info clicked');
    }




