function lookup(url,inputString,objId,evt,fieldName,mainDiv,innerDiv)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == 40)
	{
		if(document.getElementById(''+mainDiv+'').style.display != 'none')
		{
			if($("#"+objId+""))
			{
				$("#"+objId+"").focus();
				return false;
			}
		}
		else
		{
			$('#'+fieldName+'').focus();
			return false;
		}
	}
	if(charCode == 27 || charCode == 13)
	{
		$('#'+fieldName+'').focus();
		setTimeout("$('#"+mainDiv+"').hide();", 200);
		return false;
	}
	if((charCode > 47 && charCode < 58) || (charCode > 64 && charCode < 91) || (charCode == 8))
	{
		re = /&/i;
		inputString = inputString.replace(re, "--$$--");
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#'+mainDiv+'').hide();
		} 
		else
		{
			$.ajax({
					type	: "POST",
					url		: url,
					data	: "queryString="+inputString+"&fieldName="+fieldName+"&mainDiv="+mainDiv,
					success	: function(data)
					{
						if(data.length  > 0)
						{
							$('#'+mainDiv+'').show();
							$('#'+innerDiv+'').html(data);
						}
						else
						{
							$('#'+mainDiv+'').hide();
						}
					}
				});
		}
	}
	else
	{
		$('#'+fieldName+'').focus();
		return false;
	}
}//lookup
	
function fill(obj,evt,fieldName,mainDiv) {
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(charCode == 13 || charCode == 1)
	{
		txt_array				= $('#'+fieldName+'').val().split(',');
		last_index				= txt_array.length-1;
		txt_array[last_index]	= obj.value;
		
		var set_value = '';
		for(i = 0; i <= last_index; i++)
		{
			set_value = set_value+txt_array[i];
			if(txt_array[i+1])
			{
				set_value = set_value+',';
			}
		}
	
		$('#'+fieldName+'').val('');
		$('#'+fieldName+'').val(set_value);
		$('#'+fieldName+'').focus();
		setTimeout("$('#"+mainDiv+"').hide();", 200);
	}
	if(charCode == 27)
	{
		$('#'+fieldName+'').focus();
		setTimeout("$('#"+mainDiv+"').hide();", 200);
	}
}
function setFocus(objId,evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == 40)
	{
		if($("#"+objId+""))
		{
			$("#"+objId+"").focus();
		}
	}
	if(charCode == 27)
	{
		$('#txtBusinessTags').focus();
		setTimeout("$('#suggestions').hide();", 200);
	}
}
