/* 
**   Třídní stránky matematické třídy pana učitele Pařízka
**   (http://tridni.jmx.cz)
**   
**   KONTROLA ZPRAV [a muj oblibeny AJAX]
**   
***************************************************************************
** 
**   Copyright (C)  2005  Tomáš Vítek [-aka- Tomik], 
**                          <tomik@jmx.cz>
**                          http://tomik.jmx.cz
** 
**   This program is free software; you can redistribute it and/or
**   modify it under the terms of the GNU General Public License
**   as published by the Free Software Foundation; either version 2
**   of the License, or (at your option) any later version.
** 
**   This program is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**   GNU General Public License for more details.
** 
**   You should have received a copy of the GNU General Public License
**   along with this program; if not, write to the Free Software
**   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

  // KONTROLA ZDA NENI NOVA nebo NEOZNAMENA DORUCENA SOUKR. ZPRAVA
  // 
  function check_pm(strana, id) {
    var url = strana + "?id_uzivatele=" + id;
    
    if(typeof window.ActiveXObject != 'undefined') {
      httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }
    else {
      httpRequest = new XMLHttpRequest();
      }
  
    httpRequest.open("GET", url, true);
    httpRequest.onreadystatechange= function () {processRequest(strana, id); } ;
    httpRequest.send(null);
  }

  // ZPRACOVANI DAT
  // 
   function processRequest(strana, id)
   {
      
      if (httpRequest.readyState == 4)
      {
        if(httpRequest.status == 200)
        {
          var text = httpRequest.responseText;
          if (text != "") {
            eval(text);
            ajax(strana,"xxx","?id_uzivatele=" + id + "&dokonci=to");
          }
          // POUZE PRI LADENI
          // 
          
          //alert(text);
        }
        else
        {
          // POUZE PRI LADENI
          // 
                   
         //alert("Chyba kontrolování nových zpráv:\n\n"+ httpRequest.status +": "+ httpRequest.statusText);
        }
      }
   }

  // JEDNOU ZA 2 sekundy ZJISTUJE ZDA NEJSOU NEJAKE NOVE NEZNAMENE PRIJATE ZPRAVY
  // 
  window.setInterval("check_pm('http://tridni.jmx.cz/etc/zjisti-dosle-pm.php','')", 6 * 1000);

  // JEDNOU ZA 4 sekundy ZJISTUJE ZDA NEJSOU NEJAKE NOVE DORUCENE ZPRAVY
  //
  window.setInterval("check_pm('http://tridni.jmx.cz/etc/zjisti-nove-pm.php', '')", 8 * 1000);
  

