﻿function sendRequest(file, func, params, returnedparam, xhttp)
{
  if (xhttp==null)
    xhttp=http;
  xhttp.open("POST", file, true);
  xhttp.onreadystatechange= function () {processRequest(func,returnedparam,xhttp); } ;
  xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhttp.setRequestHeader("Content-length", params.length);
  xhttp.setRequestHeader("Connection", "close");
  xhttp.send(params);
}



function processRequest(func, returnedparam,http)
{
  if (http.readyState == 4)
  {
    if(http.status == 200)
    {
      if (func)
        if (typeof(returnedparam) != 'undefined')
          func(http.responseText, returnedparam);
        else
          func(http.responseText);
    }
    else
    {
        alert("Chyba p�i na��t�n� str�nky\n" + http.status +" : "+ http.statusText);
    }
  }
}

function getXHTTP( )
{
  var xhttp;
   try 
   {
      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } 
   catch (e) 
   {
      try 
      {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (e2) 
      {
        try 
        {
           xhttp = new XMLHttpRequest();
        } 
        catch (e3) 
        {
          xhttp = false;
        }
      }
    }
  return xhttp;
}

var http = getXHTTP();


