function ajax(xUrl,xId,level,id) 
{
    //logdiv('<font color=green>ajax(xUrl): '+xUrl+'</font>');
    //logdiv('<font color=blue>ajax(xId): '+xId+'</font>');
    //alert('test');
    xUrl=xUrl.replace('&amp;','&');
    xUrl=xUrl.replace('&amp;','&');
    xUrl=xUrl.replace('&amp;','&');
    xUrl=xUrl.replace('&amp;','&');
    xUrl=xUrl.replace('&amp;','&');
    xUrl=xUrl.replace('&amp;','&');
    xUrl=xUrl.replace(' ','%20');
    xUrl=xUrl.replace(' ','%20');
    xUrl=xUrl.replace(' ','%20');
    xUrl=xUrl.replace(' ','%20');
    xUrl=xUrl.replace(' ','%20');
    xUrl=xUrl.replace(' ','%20');
    if (!id)
    {
        id=xId;
    }

    if (xId.match(/WCInfoDiv/)!=null)
    {

        var myxId=document.getElementById(xId);  
        if (!myxId)
        {
        return;
        }
        var NodeLocation=getNodeLocationRelative(myxId);

        var LoadingDiv = document.getElementById(xId.replace('WCInfoDiv-','WCLoadingDiv-'));
        //LoadingDiv.style.top=parseInt(NodeLocation.top+2,10)+'px';
        //LoadingDiv.style.left=parseInt(NodeLocation.left+1,10)+'px';
        if (LoadingDiv)
        {
            LoadingDiv.style.display='block';
        }
    }

  var xmlhttp = false;

  /*@cc_on @*/

  /*@if (@_jscript_version >= 5)

  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.

  try 
  {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } 
  catch (e) 
  {
      try 
      {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (E) 
      {
        xmlhttp = false;
      }
   }

  /*@end @*/

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
  {
    xmlhttp = new XMLHttpRequest();
  }

  xUrl=xUrl.replace('&amp;','&');
  xUrl=xUrl.replace('&amp;','&');
  xUrl=xUrl.replace('&amp;','&');
  xUrl=xUrl.replace('&amp;','&');
  xUrl=xUrl.replace('&amp;','&');
  xUrl=xUrl.replace('&amp;','&');

  xmlhttp.open("GET", xUrl,true);
  xmlhttp.onreadystatechange=function() 
  {
      
      if (xmlhttp.readyState==3) 
      {
         if (AjaxQueue.length>0)
         {
            processAJAXQueue(level,false);
         }
      }        
      if (xmlhttp.readyState==4) 
      {
        if (xmlhttp.responseText.match(/The resource cannot be found./) == null)
        {
            //if (document.getElementById(xId))
            //{
                if (xId.match(/WCInfoDiv/)!=null)
                {
                    var LoadingDiv = document.getElementById(xId.replace('WCInfoDiv-','WCLoadingDiv-'));
                    if (LoadingDiv)
                    {
                        LoadingDiv.style.display='none';
                    }
                }
                      
                //if (document.getElementById(xId.replace('WCInfoDiv-','WCAddressDiv-')))
                //{
                    if (id=='WDiv-Top')
                    {
                        document.getElementById(xId).innerHTML = xmlhttp.responseText;
                    }
                    else
                    {
                        if (id.indexOf("Text")>=0)
                        {
                            //editing
                            var c=getURLParameters('c', xUrl);
                            if (c)
                            {
                                var mycc=document.getElementById(xId);
                                mycc.innerHTML=c.replace('%20',' ');
                            }
                            var p=getURLParameters('p', xUrl);
                            if (p)
                            {
                                var mycp=document.getElementById(xId);
                                mycp.innerHTML=p.replace('%20',' ');
                            }
                            var g=getURLParameters('g', xUrl);
                            if (g)
                            {
                                var mycg=document.getElementById(xId);
                                mycg.innerHTML=g.replace('%20',' ');
                            }
                        }
                        else
                        {
                            if (id.indexOf("WCDiv")>=0)
                            {
                                if (xmlhttp.responseText.indexOf('Delete Success')>=0)
                                {
                                    //delete a component
                                    var myWCDiv=document.getElementById(xId);
                                    myWCDiv.parentNode.removeChild(myWCDiv);
                                    myWCTextDiv = document.getElementById(myWCDiv.id.replace('WCDiv-', 'WCTextDiv-'));
                                    myWCTextDiv.parentNode.removeChild(myWCTextDiv);
                                }
                                else
                                {
                                    var oc=getURLParameters('oc', xUrl);
                                    if (oc)
                                    {
                                        document.getElementById(xId).outerHTML = xmlhttp.responseText;
                                        var cw=getURLParameters('cw', xUrl);
                                        if (cw)
                                        {
                                            W=wGetArrayClass(cw);
                                            var ni=getURLParameters('ni', xUrl);
                                            if (ni)
                                            {
                                                cShow(cw,ni);

                                            }
                                        }
                                            
                                    }
                                    else
                                    {
                                    
                                        //add a component
                                        var myWPDiv=document.getElementById(xId);
                                        var WCInsert = document.createElement('div');
                                        WCInsert.setAttribute('id', 'WCInsert');                                
                                        //myWPDiv.style.display='none';
                                        myWPDiv.appendChild(WCInsert);
                                        //myWCDiv.parentNode.insertBefore(WCInsert, myWCDiv);
                                        //myWCDiv.parentNode.insertBefore(WCInsert, myWCDiv);
                                        WCInsert.outerHTML = xmlhttp.responseText;
                                        var cw=getURLParameters('cw', xUrl);
                                        if (cw)
                                        {
                                            W=wGetArrayClass(cw);
                                            var ni=getURLParameters('ni', xUrl);
                                            if (ni)
                                            {
                                                mync=document.getElementById('WCDiv-'+ni);
                                                //W.WID=''; 
                                                wPopulateArrays(W, mync.parentNode)
                                                var WCTextDiv = document.createElement('div');
                                                WCTextDiv.setAttribute('id', 'WCTextDiv-'+ni);
                                                WCTextDiv.setAttribute('className', 'WCTextDiv');
                                                var cp=getURLParameters('cp', xUrl);
                                                WCTextDiv.setAttribute('name', 'WCTextDiv-'+cp);
                                                var WCText = document.createElement('div');
                                                WCText.setAttribute('id', 'WCText-'+ni);
                                                WCText.setAttribute('className', 'WCText');
                                                WCText.setAttribute('name', 'WCText-'+cp);
                                                var c=getURLParameters('c', xUrl);
                                                WCText.innerHTML=c;     
                                                WCTextDiv.appendChild(WCText);  
                                                //var myWCTextDiv=document.getElementById(id.replace('WCDiv-','WCTextDiv-'));   
                                                //myWCTextDiv.parentNode.insertBefore(WCTextDiv, myWCTextDiv);
                                                //wPopulateArrays(W, WCTextDiv.parentNode)
                                                //WCTextDiv.onmouseover = function()
                                                //{
                                                //    if (checkMouseEnter(this, event)) cShow(cw,ni);
                                                //};

                                                
                                                cShow(cw,ni);

                                            }
                                        }

                                    }
      
                                }
                            }
                            if (id.indexOf("WPDiv")>=0)
                            {
                                if (xmlhttp.responseText.indexOf('Delete Success')>=0)
                                {
                                    //delete a page
                                    var myWPDiv=document.getElementById(id);
                                    myWPDiv.parentNode.removeChild(myWPDiv);
                                    var myWPPlaceHolderDiv=document.getElementById(id.replace('WPDiv-','WPPlaceHolderDiv-'));
                                    myWPPlaceHolderDiv.parentNode.removeChild(myWPPlaceHolderDiv);
                                }
                                else
                                {
                                    var op=getURLParameters('op', xUrl);
                                    if (op)
                                    {
                                        document.getElementById(xId).outerHTML = xmlhttp.responseText;
                                    }
                                    else
                                    {
                                        //add a page
                                        //var myWPDiv=document.getElementById(id);
                                        var cg=getURLParameters('cg', xUrl);
                                        var iColumns;
                                        iColumns = 0;
                                        var i = W.WGColumnDivs.length - 1;
                                        do {
                                            if (i == - 1) break;
                                            if (W.WGColumnDivs[i].getAttribute('name') == 'WGColumnDiv-' + cg)
                                            {
                                                iColumns=iColumns+1;
                                            }
                                        }while ( -- i != - 1);
                                        var iWidth;
                                        iWidth=(100 / (iColumns+1)) - 3
                                        i = W.WGColumnDivs.length - 1;
                                        do {
                                            if (i == - 1) break;
                                            if (W.WGColumnDivs[i].getAttribute('name') == 'WGColumnDiv-' + cg)
                                            {
                                                W.WGColumnDivs[i].style.width=iWidth+'%';
                                            }
                                        }while ( -- i != - 1);
                                        
                                        var WGColumnInsert = document.createElement('div');
                                        WGColumnInsert.setAttribute('id', 'WGColumn'+(iColumns+1)+'Div-'+cg);                                
                                        WGColumnInsert.setAttribute('name', 'WGColumnDiv-'+cg); 
                                        WGColumnInsert.name= 'WGColumnDiv-'+cg;                               
                                        WGColumnInsert.className='WGColumnDiv';                                
                                        WGColumnInsert.setAttribute('class', 'WGColumnDiv');                                
                                        WGColumnInsert.setAttribute('className', 'WGColumnDiv');                                
                                        
                                        WGColumnInsert.style.width=iWidth+'%';
                                        var WGColumnsDiv = document.getElementById('WGColumnsDiv-'+cg);
                                        WGColumnsDiv.appendChild(WGColumnInsert);
                                        WGColumnInsert.innerHTML = xmlhttp.responseText;
                                        var cw=getURLParameters('cw', xUrl);
                                        if (cw)
                                        {
                                            W=wGetArrayClass(cw);
                                            mync=document.getElementById('WGColumn'+(iColumns+1)+'Div-'+cg);
                                            W.WGColumnDivs.push(mync)
                                            wPopulateArrays(W, mync)
                                        }

                                    }
                                }
                            }
                            //if (xId.indexOf("WPInsideDiv")>=0)
                            //{
                            //    var myWPInsideDiv=document.getElementById(id);
                            //    var WPCInsert = document.createElement('div');
                            //    WPCInsert.setAttribute('id', 'WPCInsert');                                
                            //    WPCInsert.innerHTML = xmlhttp.responseText;
                            //    var myWPDiv=WPCInsert.firstChild
                            //    myWPInsideDiv.outerHTML=myWPDiv.firstChild.outerHTML;
                            //}

                            if (id.indexOf("WGDiv")>=0)
                            {
                                if (xmlhttp.responseText.indexOf('Delete Success')>=0)
                                {
                                    var myWGDiv=document.getElementById(xId);
                                    myWGDiv.parentNode.removeChild(myWGDiv);
                                    var myWGPlaceHolderDiv=document.getElementById(id.replace('WGDiv-','WGPlaceHolderDiv-'));
                                    myWGPlaceHolderDiv.parentNode.removeChild(myWGPlaceHolderDiv);
                                }
                                else
                                {
                                    //add a group
                                    var myWGDiv=document.getElementById(id);
                                    var cw=getURLParameters('cw', xUrl);
                                    var iColumns;
                                    iColumns = 0;
                                    var i = W.WColumnDivs.length - 1;
                                    do {
                                        if (i == - 1) break;
                                        if (W.WColumnDivs[i].getAttribute('name') == 'WColumnDiv-' + cw)
                                        {
                                            iColumns=iColumns+1;
                                        }
                                    }while ( -- i != - 1);
                                    var iWidth;
                                    iWidth=(100 / (iColumns+1)) - 3
                                    i = W.WColumnDivs.length - 1;
                                    do {
                                        if (i == - 1) break;
                                        if (W.WColumnDivs[i].getAttribute('name') == 'WColumnDiv-' + cw)
                                        {
                                            W.WColumnDivs[i].style.width=iWidth+'%';
                                        }
                                    }while ( -- i != - 1);
                                    
                                    var WColumnInsert = document.createElement('div');
                                    WColumnInsert.setAttribute('id', 'WColumn'+(iColumns+1)+'Div-'+cw);                                
                                    WColumnInsert.setAttribute('name', 'WColumnDiv-'+cw); 
                                    WColumnInsert.name= 'WColumnDiv-'+cw;                               
                                    WColumnInsert.className='WColumnDiv';                                
                                    WColumnInsert.setAttribute('class', 'WColumnDiv');                                
                                    WColumnInsert.setAttribute('className', 'WColumnDiv');                                
                                    
                                    WColumnInsert.style.width=iWidth+'%';
                                    var WColumnsDiv = document.getElementById('WColumnsDiv-'+cw);
                                    WColumnsDiv.appendChild(WColumnInsert);
                                    WColumnInsert.innerHTML = xmlhttp.responseText;
                                    //var cw=getURLParameters('cw', xUrl);
                                    //if (cw)
                                    //{
                                        W=wGetArrayClass(cw);
                                        mync=document.getElementById('WColumn'+(iColumns+1)+'Div-'+cw);
                                        W.WColumnDivs.push(mync)
                                        wPopulateArrays(W, mync)
                                    //}
                                }   
                                
                            }
                            if (id.indexOf("WCInfoDiv")>=0)
                            {
                                var myxId=document.getElementById(xId);
                                if (myxId)
                                {
                                    document.getElementById(xId).innerHTML = xmlhttp.responseText;
                                    var WID=getURLParameters('cw', xUrl);
                                    var CID=getURLParameters('cc', xUrl);
                                    showC(WID, CID, '');
                                }
                            }
                            //else
                            //{
                            //    document.getElementById(xId).outerHTML = xmlhttp.responseText;
                                
                            //}
                        }
                    }
                    //document.getElementById(xId).outerHTML = xmlhttp.responseText;
                    if (xUrl.match(/ShowWorkspacePage/)!=null)
                    {    
                        
                        if (level>=1)
                        {
                            
                            

                            level=level-1;
                            var WID=getURLParameters('nw', xUrl);
                            //W=wGetArrayClass(WID);
                            //if (W)
                           // {
                           // W.WID='';
                            //logdiv('ajax');
                            
                            //}
                            wShow(WID,'yes','ajax');
                        }
                    }
                    else
                    {
                        mypreview = document.getElementById(xId.replace('WCInfoDiv-','MenuView-'));
                        myncpreview = document.getElementById(xId.replace('WCInfoDiv-','NCPreviewDiv-'));
                        if (mypreview)
                        {
                            if (myncpreview)
                            {
                                myncpreview.appendChild(mypreview);
                                mypreview.style.display='block';
                            }
                        }
                    }
                //}
                
            //}
   
        }
     }
  }
  xmlhttp.send(null);
}


