/*

Js functions
---------------------------------------------------------------------

Copyright (C) 2005 Marek 'juneau' Klusak, <stopar@tiscali.cz>
Web: http://rs.reality-show.net

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.

*/



/*
Spoluprace s kontrolni otazkou.
*/
var typ_otazky;

if(typ_otazky == 3)
	{
	document.getElementById('k-otazka').style.display = 'none';
	document.getElementById('odp_a').value = '52';
	}




/*
	Tato funkce je prirazena odkazum typu "maly obrazek odkazuje na jeho puvodni velikost".
	Je predavana jen adresa obrazku.
	Jenze drive se predavala cela url (popup-img.php?...) a je nutne to odlisit pro zpetnou kompatibilitu.
*/
function popup(img)
	{
	var re = new RegExp("popup-img\.php");
	var nalez = img.search(re);
	
	if (nalez == -1) {
		// nove napsane
		window.open('./popup-img.php?img='+img,'popup','resizable,statusbar=no');		
	} else {
		// stara verze
		window.open(img,'popup','resizable,statusbar=no');		
	}
	return true;
	}



/*
*	Kontrola vyplneni kontrolni otazky
*/
function submitForm()
	{
	if(document.getElementById('otazka-id'))
		{
		if(document.getElementById('odp_a').checked == false && document.getElementById('odp_b').checked == false)
			 {
			 alert('Nezodpovidili jste kontrolní otázku. Vyberte prosím správnou odpovii.');
			 return false;
			 }
		}
	return true;
	}



/*
	Skryvani a odkryvani galerii alb v menu fotoalba
*/

function fotoAlbumHide(id)
	{
    el=document.getElementById(id).style;
    el.display=(el.display == 'block') ? 'none' : 'block';
	}



function vlozSmajla(co,kam) {
	var text = document.getElementById(kam).value;
	document.getElementById(kam).value = text + ' ' + co;
}



/*
window.onload = init;

function init(){
     window.setTimeout("komZ('hl')", 1000);
}
 
function komZ(doc){
  var pole = window.location.href.split("#");
  var doc = doc;
   if(pole[1])
   {
    if(pole[1].substring(0,5) == "comm-")
		 {
      var id = pole[1];
		  if(doc=="hl"){
       document.getElementById(id).className="komentar-zvyraznit";
       doc = id;
      }else{
       if(id == doc){
        document.getElementById(doc).className="komentar-zvyraznit";
        doc = id;
       }else{
        document.getElementById(doc).className="komentar";
        document.getElementById(id).className="komentar-zvyraznit";
        doc = id;
       }	 
      }
      
		 }
    }
    window.setTimeout("komZ('"+doc+"')", 1000);
}
*/

// zkouska: ke kazdemu lichemu/sudemu komentari se prida odpovidajici CSS trida -> lze formatovat

/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}


var pole = getElementsByClassName(document,'div','komentar');

if(pole.length > 0)
        {
        for(var i = 0; i < pole.length; i++)
                {
                var kom = pole[i];
                if ((i+1) % 2 == 0)
                        {
                        var classn = 'kom-sudy';
                        }
                else
                        {
                        var classn = 'kom-lichy';
                        }
                pole[i].className += ' ' + classn;
                }
        }

function reference(cislo,formular) {
	var obsahPole = document.getElementById(formular).value;
	if (obsahPole != '')
		obsahPole += '\n';
	document.getElementById(formular).value = obsahPole + '['+cislo+']';
}




//------------------
//-------------------------------------------------------------------------------------------------------------------------------
//------------------

function libi(id, libi){
 
 var id = id;
 var libi = libi
 var url = 'libi.php?id='+id+'&libi='+libi
 
   if (window.XMLHttpRequest)
   {
    http_request = new XMLHttpRequest();
   } 
   else if (window.ActiveXObject) 
   {
    try 
    {
     http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (eror) {
     http_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
   }

   http_request.onreadystatechange = function() { zpracuj(http_request); };
   http_request.open('GET', url, true);
   http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   http_request.send(null);
   document.getElementById('hlasuj').innerHTML = 'Děkuji za Váš názor!'
  } 
  
  function emailem(uri){
  	var a = screen.width/2 - 500/2; 
    var b = 300 - 150/3;
		window.open(uri,"Emailem","height=300px, width=500px, top="+b+", left="+a+", resizable=no, status=no, toolbar=no, location=no, scrollbars=no");
  	return false;
  } 
 
