/* 
**   Třídní stránky matematické třídy pana učitele Pařízka
**   (http://tridni.jmx.cz)
**   
**   JAVASCRIPT FUNKCE [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.
*/

  // ZOBRAZENI ODKAZU NA TISK STRANKY
  // 
  function tiskni() {
    document.write('\074a href=\"javascript:window.print();\" title=\"vytiskne tuto stránku\" \076Tisk\074/a\076 | ');
  }
  
  // KONTROLA FORMU PRED ODESLANIM V DISKUSI
  // 
  function zkontroluj(formular) {
    if (formular.text.value!="") {
      return true;
    }
    else {
      alert("Text zprávy musíte vyplnit!");
      formular.text.focus();
      return false;
    }
  }

  // PRO POSLANI GET POZADVKU (AJAX) NA URCITOU "stranku", bez odezvy
  // (inspirovano u Medhiho)
  // 
  function ajax(stranka, prom, hodnota){
   
    if(typeof window.ActiveXObject != 'undefined')
      xmlDocSave = new ActiveXObject("Microsoft.XMLHTTP");
    else
      xmlDocSave = new XMLHttpRequest();
  
    xmlDocSave.open("GET", stranka + "?" + prom + "=" + hodnota, true);
    xmlDocSave.setRequestHeader('Connection', 'Close');
    xmlDocSave.send(null);
  }

  // ZOBRAZENI VYBERU POKUD DOJDE NOVA ZPRAVA ->  odejit na stranku s doruenymi zpravami
  //                                          ->  zustat tak, kde jsem
  // 
  function nova_zprava(pocet_novych, stranka){
    var souhlas;
    
    souhlas = confirm("Maš " + pocet_novych + " nových soukromých zpráv.\n\nChceš nyní přejít na stránku se zprávami?"); 
    if (souhlas) {
      if (window.location.href != stranka) window.location.href = stranka;
      else window.location.reload(true); 
    };
  }

  // POKUD JE ZADANA V URL KOTVA (odkaz na ID), TAK MU POMOCI JS PRIRAD TRIDU "zvyrazneno"
  // POTOM POMOCI CSS JSOU JEDNOTLIVE CASTI NASTYLOVANE
  //
  // TAKE PRIDAVANI KOTEV DO POLE ACTION U PRIHLASOVACICH FORMU 
  // 
  window.onload = init;
  
  function init() { 
    hilite_anchor();
  }

  // inspirovano u PIXIHO
  function hilite_anchor() {
    var o, d, h = document.location.hash;
    if (h) {
      d = h.substr(1);
      o = document.getElementById(d);
      if (o) o.className += ' zvyrazneno';
  
      o = document.getElementById('prihlas');    
      if (o) o.action += h;
      }
  }
