var XmlHttpObj;
function CreateXmlHttpObj()
{
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpObj = new XMLHttpRequest();
	}
}

function getAnswers(questionid,count)
{
	
	var no_faqs	=	document.getElementById('no_faqs').value;
	while(no_faqs>0)
	{
		var genid1	=	"answertag_"+no_faqs;
		var genid2	=	"answer_"+no_faqs;
		var obj1	=	document.getElementById(genid1);
		var obj2	=	document.getElementById(genid2);
		obj1.innerHTML		=	'';
		obj1.style.display	=	'none';
		
		obj2.innerHTML		=	'';
		obj2.style.display	=	'none';
		
		no_faqs--;
	}
	var loadingid		=	"answertag_"+count;
	var obj3			=	document.getElementById(loadingid);
	obj3.style.display	=	'block';
	obj3.innerHTML		=	"<img src=\"images/ajax-loader.gif\"> Loading...";
	
	var requestUrl;
	requestUrl	=	"ajax_faq.php?question_id="+questionid;
	CreateXmlHttpObj();
	if(XmlHttpObj)
	{
		XmlHttpObj.onreadystatechange = function(){
				Setanswernow(questionid,count)
			};
		XmlHttpObj.open("GET", requestUrl,  true);
		XmlHttpObj.send(null);		
	}
}

function Setanswernow(questionid,count)
{
	if(XmlHttpObj.readyState == 4)
	{
		if(XmlHttpObj.status == 200)
		{		
			var answertag	=	"answertag_"+count;
			var answer		=	"answer_"+count;
			document.getElementById(answertag).style.display	=	'block';
			document.getElementById(answertag).innerHTML		=	'<b>Answer</b>';
			document.getElementById(answer).innerHTML			=	'';
			document.getElementById(answer).innerHTML			=	XmlHttpObj.responseText;
			document.getElementById(answer).style.display		=	'block';
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}