function buildLoaderIMG()
{
        //graficheskiy status zagruzki
        inner('stat','');
        loader = document.createElement( 'img' );
        loader.setAttribute( 'src', '/images/loading_ajax.gif' );
        loader.style.border     = '0px';
        document.getElementById('stat').appendChild( loader );
}
function killLoaderIMG()
{
        document.getElementById('stat').removeChild( loader );
        loader = document.createElement( 'img' );
        loader.setAttribute( 'src', '/images/loading_ajax_stop.gif' );
        loader.style.border     = '0px';
        document.getElementById('stat').appendChild( loader );
}
function buildLoader()
{
        //textoviy status zagruzki
        loader = document.createElement( 'div' );
        loader.setAttribute( 'id', 'loading' );
        loader.style.position   = 'absolute';
        loader.style.top        = '50%';
        loader.style.left       = '50%';
        loader.style.width      = '300px';
        loader.style.lineHeight = '100px';
        loader.style.margin     = '-50px 0 0 -150px';
        loader.style.textAlign  = 'center';
        loader.style.border     = '1px solid #870108';
        loader.style.background = '#fff';
        loader.appendChild( document.createTextNode( 'Loading... ' ) );
        document.body.appendChild( loader );
}
function killLoader()
{
        document.body.removeChild( loader );
}
function XHConn(load)
{
  if(load == "load"){buildLoader();}
  if(load == "img"){buildLoaderIMG();}
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
          if(load == "load"){killLoader();}
          if(load == "img"){killLoaderIMG();}
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}
function inner(ID,text)
{
       document.getElementById(ID).innerHTML = text;
}
function cli(ID,PHP,GET)
{
       var myConn = new XHConn("load");
       if (!myConn) return;var fnWhenDone = function (oXML){inner(ID,oXML.responseText);};
       myConn.connect(PHP+GET, "POST", "", fnWhenDone);
}
function cli_new(ID,PHP,GET,load)
{
       var myConn = new XHConn(load);
       if (!myConn) return;var fnWhenDone = function (oXML){inner(ID,oXML.responseText);};
       myConn.connect(PHP+GET, "POST", "", fnWhenDone);
}

