var xmlHttpGetList = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	}
}
	catch(e)
	{
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch (e) {}
		}
	}
	if (!xmlHttp)
		alert("Error creating the XMLHttpRequest object.");
	else
		return xmlHttp;
}

/* initiate HTTP request to retrieve suggestions for the current keyword */
function approveCmt(url, divName)
{
	//alert(url);
	//alert(divName);
	divPos = divName;
	if(xmlHttpGetList)
	{
	        try
		{
			if (xmlHttpGetList.readyState == 4 || xmlHttpGetList.readyState == 0)
        		{
        			xmlHttpGetList.open("GET",url, true);
				xmlHttpGetList.onreadystatechange = approveCmt1;
				xmlHttpGetList.send(null);
			}
		}
		catch(e)
		{
			displayError("Can't connect to server:\n" + e.toString());
		}
      }
}


function approveCmt1()
{
	if(xmlHttpGetList.readyState == 1)
	{
		if(divPos != '')
			document.getElementById(divPos).innerHTML = "Loading....";
	}
	else if(xmlHttpGetList.readyState == 4)
	{
		if (xmlHttpGetList.status == 200)
		{
	        approveCmt2();
	    }
	}
}


function approveCmt2()
{
	response = xmlHttpGetList.responseText.split('|');//alert(response);
	if(response[1]){
	divID = response[1];
	//alert(divID);
	//alert(response[0]);
	e = document.getElementById(divID);
	e.innerHTML = response[0];
	//if(divID != divPos)
	//	document.getElementById(divPos).innerHTML = "";		
	}
}