function init_city_ac(input_id, matches_id, feedback_id, feedbackHandler) {
    oACDS = new YAHOO.widget.DS_XHR("/service/cities/", ["ResultSet.Result","Title","Id"]);
    oACDS.queryMatchContains = true;
	oACDS.maxCacheEntries = 200; 
	oACDS.queryMatchSubset = true; 

    oAutoComp = new YAHOO.widget.AutoComplete(input_id,matches_id, oACDS);
    oAutoComp.useShadow = true;
	oAutoComp.minQueryLength = 1;
	oAutoComp.queryDelay = 0.2;
	oAutoComp.delimChar = "";
	oAutoComp.forceSelection = true; 
	oAutoComp.useIFrame = true;
    oAutoComp.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
        var pos = YAHOO.util.Dom.getXY(oTextbox);
        pos[1] += YAHOO.util.Dom.get(oTextbox).offsetHeight + 2;
        YAHOO.util.Dom.setXY(oContainer,pos);
        return true;
    };

	if (feedback_id != null) {
	    oAutoComp.feedback_id = feedback_id;
	    oAutoComp.dataReturnEvent.subscribe(feedbackHandler);
	}
	
    return oAutoComp;
}


function locationFeedbackHandler(e, data) {
	sQuery = data[1]
	aResults = data[2]
			
	var eFeedback = document.getElementById(this.feedback_id);
	if (aResults.length == 0) {
		eFeedback.innerHTML = 'Sorry, we don\'t recognize that city. Please check your spelling, or try a nearby city instead.';
		eFeedback.style.display = 'block';
	} else {
		eFeedback.style.display = 'none';
	}	
}