var xmlHttp

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

var activeSuggestBox = "suggestList";

function showSuggestions(str, matType, catID, suggestBox)
{
	activeSuggestBox = suggestBox;
	if (str.length==0)
	{
		document.getElementById(activeSuggestBox).style.display = "none";
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url = "list-catalog.asp?sid="+Math.random();
	if (matType == "%") matType = "%25";
	url = url + "&matType=" + matType
	url = url + "&catID=" + catID
	url = url + "&startsWith="+str;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showMusicSuggestions(str, musicID, suggestBox)
{
	activeSuggestBox = suggestBox;
	if (str.length==0)
	{
		document.getElementById("suggestList").style.display = "none";
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="list-music.asp";
	url=url+"?startsWith="+str;
	url=url+"&sid="+Math.random();
	url=url+"&musicID=" + musicID;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showBookSuggestions(str, bookID, suggestBox)
{
	activeSuggestBox = suggestBox;
	if (str.length==0)
	{
		document.getElementById("suggestList").style.display = "none";
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="list-books.asp";
	url=url+"?startsWith="+str;
	url=url+"&sid="+Math.random();
	url=url+"&bookID=" + bookID;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText.search("NO RESULTS") == -1)
		{
			document.getElementById(activeSuggestBox).style.display = "";
			document.getElementById(activeSuggestBox).innerHTML = xmlHttp.responseText;
		}
		else
			blur_suggest();
	}
}

