
YAHOO.example.ItemSelectHandler = function() {
    // Use an XHRDataSource
    var oDS = new YAHOO.util.XHRDataSource("/autocomplete.php");
    // Set the responseType
    oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;
    // Define the schema of the delimited results
    oDS.responseSchema = {
        recordDelim: "\n",
        fieldDelim: "\t"
    };
    // Enable caching
    oDS.maxCacheEntries = 5;

    // Instantiate the AutoComplete
    var oAC = new YAHOO.widget.AutoComplete("myInput", "myContainer", oDS);
    //oAC.resultTypeList = false;
   
    // Define an event handler to populate a hidden form field
    var myHandler = function(sType, aArgs) {
        var myAC = aArgs[0]; // reference back to the AC instance
        var elLI = aArgs[1]; // reference to the selected LI element
        var oData = aArgs[2]; // object literal of selected item's result data
		var oid = oData[1];

		if(oid)
			location.href="/shop/"+oid+"/shop.php";
    };
    oAC.itemSelectEvent.subscribe(myHandler);

/*    
    // Rather than submit the form,
    // alert the stored ID instead
    var onFormSubmit = function(e, myForm) {
        YAHOO.util.Event.preventDefault(e);
        alert("Company ID: " + myHiddenField.value);
    };
    YAHOO.util.Event.addListener(YAHOO.util.Dom.get("myForm"), "submit", onFormSubmit);
*/
    return {
        oDS: oDS,
        oAC: oAC
    };
}();




