function makeRequest(url, params, reqtype)
{
	var httpRequest;

	if (window.XMLHttpRequest){  // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		try{
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try{
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{}
		}
	}

	if (!httpRequest){
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	document.getElementById('output-'+reqtype).innerHTML="<div style='padding-top: 2em; padding-left: 1em'><img src='tabcontent/loading.gif' /></div><br />"
	httpRequest.onreadystatechange = function() { displaycode(httpRequest, reqtype)};
	httpRequest.open('GET', url + params, true);
	httpRequest.send(null);

}

function displaycode(httpRequest, reqtype){
	if (httpRequest.readyState == 4){
		if (httpRequest.status == 200){
			result = httpRequest.responseText;
   document.getElementById('output-'+reqtype).innerHTML = '<h3>.htaccess output:</h3><p>Add the below code to your .htaccess file (blank or existing), and upload to your root web directory:' + '<textarea id="outputbox" wrap="off" onClick="this.select()">'+result+'</textarea><br /><br />';
}
		else{
			alert('There was a problem with the request.');
		}
	}
}

function getindividual(reqtype)
{
	var poststr="?"
	if (reqtype=="userban")
		poststr += "ip_deny_list=" + encodeURI(document.getElementById("ip_deny_list").value)
	else if (reqtype=="referrerban")
		poststr += "referer_deny_list=" + encodeURI(document.getElementById("referer_deny_list").value)
	else if (reqtype=="hotlinkban"){
		poststr += "filetype_ip_allow_list=" + encodeURI(document.getElementById("filetype_ip_allow_list").value);
		poststr += "&filetype_list=" + encodeURI(document.getElementById("filetype_list").value);
	}
	
	if (document.getElementById("deny_htaccess").checked == true)
		poststr += "&deny_htaccess=" + encodeURI(document.getElementById("deny_htaccess").value);
	makeRequest('generator.php', poststr, reqtype);
}
