var xmlHttp;
var globpid;

function build_img_list() {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not meet the minimum requirements to access this page.");
		return;
	}
	xmlHttp.onreadystatechange = img_list_loaded;
	xmlHttp.open("GET", "ajax-p3gp3.php", true);
	xmlHttp.send(null);
}

function img_list_loaded() {
	if (xmlHttp.readyState == 4) {
		filelist = xmlHttp.responseText;
		var filearray = new Array();
		filearray = filelist.split(';');
		filecount = filearray.length -1;
		selectObj = document.getElementById("p3gp3-k");
		for (var c=selectObj.options.length-1; c>=0; c--) {
			selectObj.options[c] = null;
		}
		for (i=0;i<filecount;i++) {
			// alert(filearray[i]);
			selectObj.options[selectObj.options.length] = new Option(filearray[i], filearray[i], false, false);
		}
		// alert(xmlHttp.responseText);
	}
}

function event_master_search(str) {
	if (str.length + 1 > 2) {
		xmlHttp = GetXmlHttpObject();
		if (xmlHttp == null) {
			alert("Your browser does not meet the minimum requirements to access this page.");
			return;
		}
		xmlHttp.onreadystatechange = event_master_results;
		xmlHttp.open("GET", "ajax_emaster.php?s=" + str, true);
		xmlHttp.send(null);
	}
}

function event_master_results() {
	if (xmlHttp.readyState == 4) {
		document.getElementById("div_evsearchadmin").innerHTML = xmlHttp.responseText;
	}
}

function prayer_confirm(pid, status) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert("Your browser does not meet the minimum requirements to access this page.");
		return;
	}
	globpid = pid;
	xmlHttp.onreadystatechange = prayer_status;
	if (status == "y") {
		xmlHttp.open("GET", "eprayer.php?action=confirm&pid=" + pid, true);
	}
	else if (status == "h") {
		xmlHttp.open("GET", "eprayer.php?action=ignore&pid=" + pid, true);
	}
	else if (status == "d") {
		xmlHttp.open("GET", "eprayer.php?action=remove&pid=" + pid, true);
	}
	xmlHttp.send(null);
}

function prayer_status() {
	if (xmlHttp.readyState == 4) {
		document.getElementById("span_prayeradm" + globpid).innerHTML = xmlHttp.responseText;
	}
}

function GetXmlHttpObject() {
	var xmlHttp = null;
	try {
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}