function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}


    var timerMPS;
    
    var timerStartMPS = null;
    var nTimerStartCountMPS = 0;
    
    var nTimerCountMPS = 0;
    
    var nState = 0;
    
    var xmlHttpMPS = null;


   var stridentMPS = "";
    var strurlMPS = "";
    
    
    function ReleaseMP()
    {
    	if(null != xmlHttpMPS)
    	{
    		xmlHttpMPS.abort();
    	  xmlHttpMPS = null;
      }
  	if(null != timerStartMPS)
    	     {
    	     	
    	     		clearInterval(timerStartMPS); 
    	     	
    	     	 timerStartMPS = null;
    	      
    	    }
    	    	if(null != timerMPS)
       {
        	clearInterval(timerMPS); 
         	timerMPS = null;
        }
    }


 function GetMP()
    {
    	
    	if(null != timerStartMPS)
    	     {
    	     	
    	     		clearInterval(timerStartMPS); 
    	     	
    	     	 timerStartMPS = null;
    	      
    	    }


    	if(null != xmlHttpMPS)
    	{
    		xmlHttpMPS.abort();
    	  xmlHttpMPS = null;
      }
        
    if(null == xmlHttpMPS)
   {
   	xmlHttpMPS = GetXmlHttpObject(); 
  }
    if(null != xmlHttpMPS)
    {
    var url="/api_quehuo_mpsclient.aspx";
    url=url+"?identlist="+stridentMPS;
    url=url+"&urllist="+escape(strurlMPS);
    url=url+"&type=1&cishu="+new Date().getTime();
    xmlHttpMPS.onreadystatechange=MPSClientStateChanged1;
    xmlHttpMPS.open("GET",url,true);
    xmlHttpMPS.setRequestHeader("If-Modified-Since","0");
    xmlHttpMPS.setRequestHeader("Cache-Control","no-cache");
    xmlHttpMPS.send(null);
    }

    }
    
    
      function CheckMP()
    {
     	if(null != timerMPS)
       {
        	clearInterval(timerMPS); //15秒清除timer
         	timerMPS = null;
        }

     nState = 1;
   
    	if(null != xmlHttpMPS)
    	{
    		xmlHttpMPS.abort();
    	  xmlHttpMPS = null;
      }

    if(null == xmlHttpMPS)
   {
   	xmlHttpMPS = GetXmlHttpObject(); 
  }
      if(null != xmlHttpMPS)
    {
    var url="/api_quehuo_mpsclient.aspx";
    url=url+"?identlist="+stridentMPS;
    url=url+"&type=2&cishu="+new Date().getTime();
    xmlHttpMPS.onreadystatechange=MPSClientStateChanged1;
    xmlHttpMPS.open("GET",url,true);
    xmlHttpMPS.setRequestHeader("If-Modified-Since","0");
    xmlHttpMPS.setRequestHeader("Cache-Control","no-cache");
    xmlHttpMPS.send(null);
    }

    }

    
    
    function MPSClientStateChanged1() 
    { 
      if (xmlHttpMPS.readyState==4)
      { 

					if (xmlHttpMPS.status == 200)        
					{
						if(0 == nState)
						{
            if("1" == xmlHttpMPS.responseText)
            {

               timerMPS= setInterval("CheckMP();",1000);  //1秒执行一次
            }
						}
					else
						{
						  if("" != xmlHttpMPS.responseText)
          	  {
          	    var bHasUnCheck = false;
          
                var arRet = xmlHttpMPS.responseText.split(",");
            
                for(var n=0;n<arRet.length;n++)
                {
                   var arIdentState = arRet[n].split(":");
               
                   if(arIdentState[1] == "2")
                   {
                      document.getElementById(arIdentState[0]).src="images/quehuo.gif";
                      
                      
                      if(document.getElementById(arIdentState[0]+"_2") != null)
                      {
                      document.getElementById(arIdentState[0]+"_2").src="images/quehuo.gif";
                    }
                   }
                   else if(arIdentState[1] == "10")
                   {
                     bHasUnCheck = true;
                   }
                }
            
                nTimerCountMPS++;
            
            
                if(bHasUnCheck)
                {
                  if(nTimerCountMPS > 15)
                  {
                  	ReleaseMP();
                  }
                  else
            	    {
                     timerMPS= setInterval("CheckMP();",1000);  //1秒执行一次
    		     	    }
                }
              else
              	{
              		ReleaseMP();
              	}
                

            
              }
						}
          }
        }
     }
    
   
