
//AJAXroutine - ajax common routine for the tree view implementation
//v1.01- Author: AJFK (http://www.alhamdgroup.com)
//Last updated: November 22th 06
<!--
 
 	
var xmlHttp;
/***********************************************************
//Builds the query string and invoke a request to the server 
//using javascript async call
/***********************************************************/
function showContentsEx(div, str, lmsg,conregids){	
	if (div == null) return;
	divObj = div;
	if(conregids==null)return;		
	var objDivContainer="";
	objDivContainer = document.getElementById(eval("'"+div+"'"));
	
	if (objDivContainer == null) return;
	
	if (str == "") {
		objDivContainer.innerHTML= "";		
	return;
	}
	
	//else
	//show the processing image to the user
	objDivContainer.innerHTML = "<img src='/rfpimages/loading.gif' border='0'/>";
	
	
	//get the xml http object
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	} 
	
	//build the processing page and it's query string
	//invoke a request to the server using javascript async call
	var url="/GetTreeContents.aspx?q="+str+"&d="+lmsg+"&"+conregids;	
	url=url+"&sid="+Math.random();					
	xmlHttp.onreadystatechange=stateChangedEx;	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	/**/
}

//The extented method to check the http request state has changed
//Then the dynamic div tag will be filled with the response text
function stateChangedEx() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		
		document.getElementById(eval("'"+divObj+"'")).innerHTML=xmlHttp.responseText; 
	} 
} 

//The core function to get the xml http request object
function GetXmlHttpObject(){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

//To toggle the node image and expand collapse
function Toggle(node){

	// Unfold the branch if it isn't visible	
	if (node.nextSibling.nextSibling.style)	{		
		if (node.childNodes.length > 0)	{
			if (node.childNodes.item(0).nodeName == "IMG"){
				if(node.childNodes.item(0).src.indexOf("plus.gif")> -1){
					
					node.nextSibling.nextSibling.style.display = 'block';
					node.childNodes.item(0).src = "/rfpimages/minus.gif";
					return true;
				}
				else {
				
					node.nextSibling.nextSibling.style.display = 'none';
					node.childNodes.item(0).src = "/rfpimages/Tplus.gif";
					return false;
				}				 
			}
		}		
	}
}
//-->
