var txt;
var keyword;
var sub;
var mess;
var page;
var pno;
var currcount = 1;

function fetch(mtype){
		var xmlHttpReq = false;
		var self = this;
		txt=encodeURI(document.getElementById("cat").value);
		var WriteURI = 'fetch.php?action=send&cat='+txt;
		if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', WriteURI, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.send('');
		document.getElementById("load").innerHTML = "<img src=\"images/loading.gif\">";
		//document.getElementById("text").innerHTML = "";
		self.xmlHttpReq.onreadystatechange = handleResponse;
		return false;

}
function fetch1(op,id){
		var xmlHttpReq = false;
		var self = this;
		var WriteURI = 'fetch.php?action=msend&image='+op+'&id='+id;
		if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', WriteURI, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.send('');
		document.getElementById("txt").innerHTML = "<img src=\"images/wait.gif\">";
		self.xmlHttpReq.onreadystatechange = handleResponse4;
		return false;
}
function gets(mtype){
		var xmlHttpReq = false;
		var self = this;
		txt=encodeURI(document.getElementById("ptype").value);
		var WriteURI = 'fetch.php?action=download&ptype='+txt;
		if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', WriteURI, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.send('');
		//document.getElementById("load").innerHTML = "<img src=\"images/loading.gif\">";
		//document.getElementById("text").innerHTML = "";
		self.xmlHttpReq.onreadystatechange = handleResponse1;
		return false;

}
function handleResponse() {
	 if(xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200){
	      var response = xmlHttpReq.responseText;
				if(response) {
				//document.getElementById("txt").value = response;
				document.getElementById("scat").innerHTML = response;
				document.getElementById("load").innerHTML = "";
				}
	}
}
function handleResponse1() {
	 if(xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200){
	      var response = xmlHttpReq.responseText;
				if(response) {
				//document.getElementById("txt").value = response;
				document.getElementById("down").innerHTML = response;
				//document.getElementById("load").innerHTML = "";
				}
	}
}
function handleResponse4() {
	 if(xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200){
	      var response = xmlHttpReq.responseText;
				if(response) {
				document.getElementById("txt").innerHTML = response;
				}
	}
}

