_cfscriptLocation = "/search/course/ajax.cfm";

function errorHandler(message)
{
	$('disabledZone').style.visibility = 'hidden';
    if (typeof message == "object" && message.name == "Error" && message.description)
    {
        alert("Error: " + message.description);
    }
    else
    {
        alert(message);
    }
};

var profLookup = new Suggest(); 
var searchString = "";

function getData(qry)
{
	searchString = qry;
	if(searchString.length>0) { DWREngine._execute(_cfscriptLocation, null, 'lookup_professor', searchString, getDataResult); }
}

function getDataResult(profArray)
{
	var key = Array();
	var value = Array();
	
	for (i=0; i < profArray.length; i++)
	{
		key[i] = profArray[i].EMPLOYEEID;
		value[i] = profArray[i].FULLNAME;
	}
	strQuery = selectedSuggestObject.name + '.showQueryDiv("' + searchString + '", key , value)';
	eval (strQuery);
}

function onInit()
{
	profLookup.setListStyle("listStyle");
	profLookup.setListItemStyle("listItemStyle");
	profLookup.setListItemKey("listItemKey");
	profLookup.setListItemValue("listItemValue");
	profLookup.setListWidth("15.7em");
	profLookup.setSelectionListener(itemSelectionListener);
	profLookup.setShowKey(false);
	profLookup.setQueryFieldHolds(1);
	
	onSuggestFieldFocus(profLookup);
	profLookup.InitQueryCode('profLookup','instructor')
}

function itemSelectionListener(result)
{
	//alert(result.VALUE);
	//use this function to set the hidden field with key value..
}