﻿// About ajax , Created by Mike on 2007-09-18 
var XMLHttpReq=null; 
var returnHtml="";
//创建xmlhttprequset对象 
function createXMLHttpRequest()
{ 
  if(window.XMLHttpRequest)
  { 
     XMLHttpReq=new XMLHttpRequest(); 
  } 
  else if (window.ActiveXObject)
  { 
     try
     { 
        XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP"); 
     }catch(e){} 
  } 
} 

function showContent()
{
     returnHtml="";
     if(XMLHttpReq==null)
     {
        createXMLHttpRequest(); 
     }
     XMLHttpReq.open("POST",'getLatestApp.aspx',false); 
     XMLHttpReq.onreadystatechange=processResponse_NewApp;
     XMLHttpReq.send(); 
}

function processResponse_NewApp()
{ 
   if(XMLHttpReq.readyState==4)
   { 
       if(XMLHttpReq.status==200)
       { 
            updateMenu_NewApp(); 
       }
       else{alert("您请求的页面有异常!")} 
   } 
}

function updateMenu_NewApp()
{
    //XMLHttpReq.responseXml.documentElement
    var doc= null ;
    if(doc==null)
    {                               
       alert(XMLHttpReq.responseText.documentElement);
       return;
    }
    var nodes_id = doc.getElementsByTagName("userName"); 
    var nodes_ShowName = doc.getElementsByTagName("CompName");
    var nodes_Count = doc.getElementsByTagName("StationName");
    var i=0;
    var Name = "";
    var StationName = "";
    returnHtml += "<table width='92%' border='0' cellspacing='0' align='center' cellpadding='0' bgcolor='#FFFFFF'>";
    var j=0;
    for(i=0;i<nodes_ShowName.length;i++)
    {
        if(j==0)
        {
           returnHtml += "<tr>";
           j=1;
        }
        returnHtml += "<td height='36' width='50%'><table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
        Name = nodes_ShowName[i].firstChild.data;
        StationName = nodes_Count[i].firstChild.data;
        if(Name.length > 20)
        {
            Name = Name.substring(0,15)+"..";
        }
        if(StationName.length > 20)
        {
            StationName = StationName.substring(0,15)+"..";
        }
        
        returnHtml += "<tr><td height='18'>·<a href=\"CompManage/CompView.aspx?username="+ nodes_id[i].firstChild.data +"\" target=\"_blank\">"+ Name +"</a></td></tr>";
        returnHtml += "<tr><td height='18'>"+ StationName +"</td></tr></table></td>";
        
	    if((i+1)%2==0)
        {
	      returnHtml += "</tr>";
	      j=0; 
        }
	}
	if(j!=0)
	{
       returnHtml += "<td height='40'>&nbsp;</td></tr>";
    }
      returnHtml += "</table>";
      document.writeln(returnHtml);
}
