	
log = calhoun.util.log;
var acFields = {};
	
var expand = function (img) {
	acFields[img.id].autoComp.sendQuery("");
}

var showValues = function() {
}


		
YAHOO.widget.AutoComplete.prototype._isIgnoreKey = function(nKeyCode) {
	if ((nKeyCode == 9) ||  // tab
        (nKeyCode == 16) || (nKeyCode == 17) || // shift, ctl
        (nKeyCode >= 18 && nKeyCode <= 20) || // alt,pause/break,caps lock
        (nKeyCode == 27) || // esc
        (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
        (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
        (nKeyCode >= 44 && nKeyCode <= 45) || // print screen,insert
        (nKeyCode == 78)) {  // open-apple-n
           return true;
   }
   return false;
}		
		
YAHOO.widget.DS_XHR.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
    var isXML = (this.responseType == YAHOO.widget.DS_XHR.TYPE_XML);
    var sUri = this.scriptURI+"&"+this.scriptQueryParam+"=S"+sQuery;
    if(this.scriptQueryAppend.length > 0) {
        sUri += "&" + this.scriptQueryAppend;
    }
    var oResponse = null;
    var oSelf = this;

    /*
     * Sets up ajax request callback
     *
     * @param {object} oReq          HTTPXMLRequest object
     * @private
     */
    var responseSuccess = function(oResp) {
        // Response ID does not match last made request ID.
        if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
            oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
            return;
        }

        if(!isXML) {
            oResp = oResp.responseText;
        }
        else {
            oResp = oResp.responseXML;
        }
        if(oResp === null) {
            oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATANULL);
            return;
        }

        var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
        var resultObj = {};
        resultObj.query = decodeURIComponent(sQuery);
        resultObj.results = aResults;
        if(aResults === null) {
            oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DataSource.ERROR_DATAPARSE);
            aResults = [];
        }
        else {
            oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
            oSelf._addCacheElem(resultObj);
        }
        oCallbackFn(sQuery, aResults, oParent);
    };

    var responseFailure = function(oResp) {
        oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DS_XHR.ERROR_DATAXHR);
        return;
    };
			
	var oCallback = {
        success:responseSuccess,
        failure:responseFailure
    };
			
    if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
        oCallback.timeout = this.connTimeout;
    }

    if(this._oConn) {
        this.connMgr.abort(this._oConn);
    }

    oSelf._oConn = this.connMgr.asyncRequest("GET", sUri, oCallback, null);
};

calhoun.InputField = function(url, label) {
    this.field = domGet(label + "input");
    this.label = label;
	this.dataSource = new YAHOO.widget.DS_XHR(url, ["Results","Name"]);
	this.dataSource.scriptQueryParam = "sp";	
	this.dataSource.scriptQueryAppend = "sp=S" + label;
	this.autoComp = null;
};

(function() {
    var InputFieldClass = calhoun.InputField.prototype	
	
})()


