var xmlHttp = createXmlHttpRequestObject(); 

function createXmlHttpRequestObject() { 
	var xmlHttp; 

    if(window.ActiveXObject) { 
        try { 
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
        } catch (e) { 
            xmlHttp = false; 
        } 
    }else { 
        try { 
            xmlHttp = new XMLHttpRequest(); 
        } catch (e) { 
            xmlHttp = false; 
        } 
    } 

    if (!xmlHttp) 
        alert("Error creating the XMLHttpRequest object."); 
    else 
        return xmlHttp; 
} 
// Table Listing For Children
function getChildTableList($key, $value, $orderKey, $index) {
	var childTable;
	
	childTable ="tablelist.php?action=child&key=" + $key + "&value=" + $value + "&orderKey=" + $orderKey + "&index=" + $index;
	
	//alert(childTable);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { 
		xmlHttp.open("GET", childTable, true); 
		
        xmlHttp.onreadystatechange = handleChildTableListResponse; 

        xmlHttp.send(null); 
    } else {
		alert("Request Reject");
        setTimeout('getChildTableList($key, $value, $orderKey, $index)', 1000); 
    }
}
// Child Response Handle
function handleChildTableListResponse() { 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") { 
		document.getElementById("childTable").innerHTML = xmlHttp.responseText
	}
}

// Table Listing For Churches
function getChurchTableList($key, $value, $orderKey, $index, $path) {
	var churchTable;
	if ($path=="1"){
		churchTable ="./tablelist.php?action=church&key=" + $key + "&value=" + $value + "&orderKey=" + $orderKey + "&index=" + $index;
	}else{
		churchTable ="/donateGift/admin/tablelist.php?action=church&key=" + $key + "&value=" + $value + "&orderKey=" + $orderKey + "&index=" + $index;
	}
	//alert(churchTable);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { 
		xmlHttp.open("GET", churchTable, true); 
		
        xmlHttp.onreadystatechange = handleChurchTableListResponse; 

        xmlHttp.send(null); 
    } else {
		alert("Request Reject");
        setTimeout('getChurchTableList($key, $value, $orderKey, $index)', 1000); 
    }
}

/*
// Table Listing For Churches
function getPaginationTable($key, $value, $page, $path) {
	var churchTable;
	
	// alert($path);
	
	if ($path=="1"){
		churchTable ="pagination.php?action=child&key=" + $key + "&value=" + $value + "&page" + $page;
	}else{
		churchTable ="./admin/pagination.php?action=child&page=" + $page + "&key=" + $key + "&value" + $value;
	}
	// alert(churchTable);
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { 
		xmlHttp.open("GET", churchTable, true); 
		
        xmlHttp.onreadystatechange = handleChurchTableListResponse; 

        xmlHttp.send(null); 
    } else {
		alert("Request Reject");
        setTimeout('getChurchTableList($key, $value, $orderKey, $index)', 1000); 
    }
}
*/
function handleChurchTableListResponse() { 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") { 
		document.getElementById("churchTable").innerHTML = xmlHttp.responseText
	}
}

