
function ProductSuggestions()
{
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
ProductSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
	//alert(encodeURIComponent("§A§A"));
	var d = document.brandform;
	var aj = new ajax();
	var aSuggestions = [];
	var sTextboxValue = oAutoSuggestControl.textbox.value;

	if (sTextboxValue == "") return;

	aj.onreadystatechange = function()
	{
		if (aj.readyState == 4)
		{
			if (aj.status == 200)
			{
				var xmldoc = aj.responseXML;
				var root_node = xmldoc.getElementsByTagName('root').item(0);
				var temp = xmldoc.childNodes(0);
				for (i=0; i<temp.childNodes.length; i++)
				{
					var cName = temp.childNodes(i).firstChild.firstChild.nodeValue;
					if (cName.toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0)
					{
						aSuggestions.push(cName);
					} 
				}
				oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
			}
		}
	}
	url = ajaxBaseURL + "/searchxml.php?type=" + d.sType.value;
	aj.open('POST', url + "&str=" + encodeURIComponent(sTextboxValue), true);
	aj.send(null);

};

function ProductSuggestions2()
{
}

ProductSuggestions2.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
	//alert(encodeURIComponent("§A§A"));
	var d = document.brandform;
	var aj = new ajax();
	var aSuggestions = [];
	var sTextboxValue = oAutoSuggestControl.textbox.value;

	if (sTextboxValue == "") return;

	aj.onreadystatechange = function()
	{
		if (aj.readyState == 4)
		{
			if (aj.status == 200)
			{
				var xmldoc = aj.responseXML;
				var root_node = xmldoc.getElementsByTagName('root').item(0);
				var temp = xmldoc.childNodes(0);
				for (i=0; i<temp.childNodes.length; i++)
				{
					var cName = temp.childNodes(i).firstChild.firstChild.nodeValue;
					if (cName.toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0)
					{
						aSuggestions.push(cName);
					} 
				}
				oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
			}
		}
	}
	url = ajaxBaseURL + "brandsxml.php?str=" + encodeURIComponent(sTextboxValue);
	aj.open('POST', url, true);
	aj.send(null);

};