﻿function getAjax(vO)
{
   var xmlHttp;
   if(window.ActiveXObject)
   {
      try
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
   }
   else if(window.XMLHttpRequest)
   {
      xmlHttp = new XMLHttpRequest();
      if(xmlHttp.overrideMimeType)
      {
         xmlHttp.overrideMimeType('text/' + type);
      }
   }
   if ( ! xmlHttp)
   {
      return null;
   }
   var returnString = null;
   this.connect = function(sendUrl, postString, callBack)
   {
      if ( ! xmlHttp)
      {
         return false;
      }

      xmlHttp.open("POST", sendUrl, true);
      xmlHttp.setRequestHeader("Method", "POST" + sendUrl + " HTTP/1.1");
      xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

      xmlHttp.onreadystatechange = function()
      {
         switch(xmlHttp.readyState )
         {
            case 0 :
               window.status =  "Initial data request.....";
               break;
            case 1 :
               window.status =  "Data loading......";
               break;
            case 2 :
               window.status =  "Data request success.";
               break;
            case 3 :
               window.status =  "Receiving server data......";
               break;
            case 4 :
                if(xmlHttp.status == 200)
                {
                   window.status =  "Success.";                   
                   if(vO == null)
                   {
                      callBack(xmlHttp);
                   }
                   else
                   {
                      callBack(xmlHttp, vO);
                   }
                }
                else
                {
                    window.status="数据下载失败";
                    var vNode = document.createElement("DIV");
                    vNode.innerHTML = "数据下载失败";
                    My$(vO).appendChild(vNode);                     
                }
                break;
         }
      };

      xmlHttp.send(postString);

      return returnString;
   }
   ;
   return this;
}

// JScript 文件
function getGalleryImage(type)
{
   if( ! type)
   {
      type = "html";
   }
   var xmlHttp;
   if(window.ActiveXObject)
   {
      try
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
   }
   else if(window.XMLHttpRequest)
   {
      xmlHttp = new XMLHttpRequest();
      if(xmlHttp.overrideMimeType)
      {
         xmlHttp.overrideMimeType('text/' + type);
      }
   }
   if ( ! xmlHttp)
   {
      return null;
   }
   var returnString = null;
   this.connect = function(sendUrl, postString, callBack)
   {
      if ( ! xmlHttp)
      {
         return false;
      }

      xmlHttp.open("POST", sendUrl, false);
      xmlHttp.setRequestHeader("Method", "POST" + sendUrl + " HTTP/1.1");
      xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      // if(type == 'xml')
      // xmlHttp.setRequestHeader("Content-Type", "text/" + type);


      xmlHttp.onreadystatechange = function()
      {
         switch(xmlHttp.readyState )
         {
            case 0 :
               window.status =  "Initial data request.....";
               break;
            case 1 :
               window.status =  "Data loading......";
               break;
            case 2 :
               window.status =  "Data request success.";
               break;
            case 3 :
               window.status =  "Receiving server data......";
               break;
            case 4 :
                if(xmlHttp.status == 200)
                {
                   window.status =  "Success.";
                   returnString = xmlHttp.responseXML.text;
                }
                else
                {
                   window.status = xmlHttp.statusText;
                }
                break;
         }
      };

      xmlHttp.send(postString);

      return returnString;
   }
   ;
   return this;
}

function RequestDataStart(vO)
{
   var vvO = My$(vO);
   var vNewImageElement01 = document.createElement("IMG");
   vNewImageElement01.id = "v" + vO;
   vNewImageElement01.src = vUrlPart01 + "/Icons/loading.gif";
   vvO.appendChild(vNewImageElement01);
   vvO.style.visibility = "visible";   
}

function RequestDataEnd(vO)
{
   var vO01 = My$(vO);
   var vO02 = My$("v" + vO);
   if(vO02!=null)
   {
    vO01.removeChild(vO02); 
   }
}

