$().ready(function() {
	var ac = $("#searchField").autocomplete(doc_root + "includes/ajax/box.autocomplete.get.php",{
		autoFill: false,
		cacheLength: 1,
		matchSubset: 0
		});
	//ac[0].autocompleter.flushCache();

	var myServer = "" + doc_root + "includes/ajax/box.autocomplete.get.php"; 
	var mySchema = ["search_results", "res_value"]; 
	var yui_datasource = new YAHOO.widget.DS_XHR(myServer, mySchema);
	yui_datasource.queryMatchContains = true;



	
	var myAutoComp = new YAHOO.widget.AutoComplete("searchfield", 'yui-container', yui_datasource); 
//	myAutoComp.setFooter("<b>Displaying </b>");
	myAutoComp.animSpeed = 0.1;
	myAutoComp.autoHighlight = true;
	myAutoComp.useShadow = true; 
//	myAutoComp.animHoriz = false; 
//	myAutoComp.animVert = false; 
	myAutoComp.autoHighlight = true; 
	myAutoComp.highlightClassName = "ac_over"; 
	myAutoComp.typeAhead = false;

	// This function returns markup that bolds the original query, 
	// and also displays to additional pieces of supplemental data. 
	myAutoComp.formatResult = function(aResultItem, sQuery) { 
		return "<span style=\"font-weight:bold\">" 
					+ aResultItem[1].res_value + 
				"</span>" + 
				"<div style=\"font-size:11px;\">" 
					+ aResultItem[1].res_path +
				"</div>";
		
		/*
		var sKey = aResultItem[0]; // the entire result key 
		var sKeyQuery = sKey.substr(0, sQuery.length); // the query itself 
		var sKeyRemainder = sKey.substr(sQuery.length); // the rest of the result 
			 
		// some other piece of data defined by schema 
		var attribute1 = aResultItem[1];  
		// and another piece of data defined by schema 
		var attribute2 = aResultItem[2]; 
		
		var aMarkup = ["<div id='ysearchresult'>", 
		"<span style='font-weight:bold'>", 
		sKeyQuery, 
		"</span>", 
		sKeyRemainder, 
		": ", 
		attribute1, 
		", ", 
		attribute2, 
		"</div>"]; 
		return (aMarkup.join("")); */
	}; 	
	
	myAutoComp.sendQuery = function() {
		alert("send?");
	}
});

