var errorIcon = "<img src='../../media/img/error_warning.png' title='Request Failed' alt='Request Failed' />";
var loadingIcon1 = "<img src='../../media/img/loadingfaq.gif' alt='Request In Progress' Title='Request In Progress' /><br />Please wait, retrieving answer to FAQ...";

/**
 *  Create an XMLHttpRequest object with cross browser compatibility
 */
function GetXmlHttpObject(){
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}
	if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

/*
* This function is to LIST zone records of a domain by invoking queryDnsZoneList method
*/
function getAnswerToFaq(faqId){
	var xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser does not support HTTP Request");
		return;
	}
	var url = "/include/ajax/faqanswer.php";
	var param = "?faqid="+faqId;
	url = url + param;
	
	xmlHttp.open("GET",url,true);
	document.getElementById("div_faq_list").innerHTML="<div style='text-align:center;'><br /><br />"+loadingIcon1+"</div>";
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			if (xmlHttp.status == 200) {
				document.getElementById("div_faq_list").innerHTML = xmlHttp.responseText;
			}else{
//				document.getElementById("div_zone_list").innerHTML = errorIcon+" An error occured upon request. Please try again.";
				document.getElementById("div_faq_list").innerHTML = errorIcon+xmlHttp.responseText;
			}
		}
	}
	
	xmlHttp.send(null);
}

/*
* This function is to LIST zone records of a domain by invoking queryDnsZoneList method
*/
function getFaqListBySelectedCategory(faqCategory){
	var xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser does not support HTTP Request");
		return;
	}
	var url = "/include/ajax/listFaqByCategory.php";
	var param = "?category="+faqCategory;
	url = url + param;
	
	xmlHttp.open("GET",url,true);
	document.getElementById("div_faq_list").innerHTML="<div style='text-align:center;'><br /><br />"+loadingIcon1+"</div>";
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			if (xmlHttp.status == 200) {
				document.getElementById("div_faq_list").innerHTML = xmlHttp.responseText;
			}else{
//				document.getElementById("div_zone_list").innerHTML = errorIcon+" An error occured upon request. Please try again.";
				document.getElementById("div_faq_list").innerHTML = errorIcon+xmlHttp.responseText;
			}
		}
	}
	
	xmlHttp.send(null);
}
