var xmlHttp = createXmlHttpRequestObject();
var mydiv='divMessage';
var lastdv='';
var regionsname=[];

function createXmlHttpRequestObject()
{
var xmlHttp;
if(window.ActiveXObject)
  {
  try 
    {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp = false;
    }
  }
else
  {
  try
    {
    xmlHttp = new XMLHttpRequest();
    }
  catch(e)
    {
    xmlHttp = false;
    }
  }

if(!xmlHttp)
 alert("Ошибка создания объекта");
else
 {
 return xmlHttp;
 }
}
function showhide(dv,lastdv)
{
     document.getElementById(lastdv).style.display="none";
     document.getElementById('d'+lastdv).style.display="block";
     document.getElementById('d'+dv).style.display="none";
     document.getElementById(dv).style.display="block";
}

function process(mnm,dv)
{
  mydiv=dv;
  if(lastdv=='') lastdv=dv;
  showhide(dv,lastdv);
  lastdv=dv;
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
     document.getElementById(mydiv).innerHTML = "загрузка";
     xmlHttp.open('GET', '/news/ajload.php?id=' + mnm, true);
     xmlHttp.onreadystatechange = handleServerResponse;
     xmlHttp.send(null);
  }
}


function handleServerResponse()
{
if (xmlHttp.readyState == 4)
  {
  if (xmlHttp.status == 200)
    {
    try
      {
          xmlResponse = xmlHttp.responseXML;
          xmlDocumentElement = xmlResponse.documentElement;
          helloMessage = xmlDocumentElement.firstChild.data;
          document.getElementById(mydiv).innerHTML = helloMessage;

      }
      catch(e)
      {
          document.getElementById(mydiv).innerHTML = 'пустой список';
      }
    }
  else
    {
    alert('Ошибка сервера: ' + xmlHttp.statusText);
    }
  }
}