YAHOO.example.RemoteCustomRequest = function() {    
	// Use an XHRDataSource
    var suggestion = new YAHOO.util.XHRDataSource("suggestion.php");
    // Set the responseType
    suggestion.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
    // Define the schema of the JSON results
    suggestion.responseSchema = {resultsList : "ResultSet.Result",fields : ["suggestions", "data"], data :["data"]};
    var AutoComp = new YAHOO.widget.AutoComplete("city", "suggestions", suggestion);
	// Throttle requests sent
	AutoComp.queryDelay = 0;
	AutoComp.animVert = true;
	AutoComp.autoHighlight = false;
	//AutoComp.highlightClassName = "selected";
	AutoComp.prehighlightClassName = "selected";
	AutoComp.minQueryLength = 2;

	AutoComp.formatResult = function(oResultData, sQuery, sResultMatch) {
	   var reEscape = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'].join('|\\') + ')', 'g');
	   var sKey = new String(sResultMatch);
	   // Extract the part of the match that the user did not type
	   var sKeyRemainder = sQuery; 
	   sKey=sKey.replace(new RegExp(sKeyRemainder, 'gi'),'<strong>'+sKeyRemainder+'</strong>');
	   //alert(sKeyRemainder2);
	   // some other piece of data defined by schema
	   //alert(oResultData.suggestions); 
	   // and another piece of data defined by schema
	   var moreData2 = "hotel"; 
	 
	   var aMarkup = ["<div class='myCustomResult'>",
		  sKey,
/*		  ": ",
		  moreData2,
		  ", ",
		  moreData2,*/
		  "</div>"];
	  return (aMarkup.join(""));
	};
    
    	//define your itemSelect handler function:
	var itemSelectHandler = function(sType, aArgs) {   
		var oData = aArgs[2] // object literal of data for the result
        location.href = oData[1];
//		alert(oData);
		
	};
	
	//subscribe your handler to the event, assuming
	//you have an AutoComplete instance myAC:
	AutoComp.itemSelectEvent.subscribe(itemSelectHandler);

    AutoComp.generateRequest = function(sQuery) {
        return "?query=" + sQuery ;
    };
    
    return {
        suggestion: suggestion,
        AutoComp: AutoComp
    };
}();



