
//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,qmsg,mstr,str, lmsg){
function showContentsEx(div,cid,cname,gcode,gname,lcode,lname,compcode,compname){
    if (div == null) return;
    divObj = div;
    
    var objDivContainer = document.getElementById(eval("'"+div+"'"));
    //alert(objDivContainer.id);
    if (objDivContainer == null) return;
    
    if (gcode == "") {
        objDivContainer.innerHTML= "";       
        return;
    }
    if (lcode == "") {
        objDivContainer.innerHTML= "";       
        return;
    }
    
    //else
    //show the processing image to the user
    objDivContainer.innerHTML = "<img src='images/tree/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="groupTree.view?cid="+cid+"&cname="+cname+"&gcode="+gcode+"&gname="+gname+"&lcode="+lcode+"&lname="+lname+"&compcode="+compcode+"&compname="+compname;
   //alert(url);
    //var url="groupTree.view?m="+mstr+"&q="+str;
    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){
//alert("toggle....");

    // Unfold the branch if it isn't visible
    if (node.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.style.display = 'block';
                    node.childNodes.item(0).src = "images/tree/minus.gif";
                    return true;
                }
                else {
                    node.nextSibling.style.display = 'none';
                    node.childNodes.item(0).src = "images/tree/plus.gif";
                    return false;
                }               
            }
        }       
    }else{
//alert("style ....");
        }
}
//--> 
