function zobraz(nazev, sirka, vyska) {
  vyska = vyska;
  sirka = sirka;
  p = window.open("zobraz.php?obr="+nazev+"", "nahled", "width="+(sirka)+" ,height="+(vyska)+",left=150,top=60");
  p.focus();
}

function zobraz_text(id, sirka, vyska) {
  vyska = vyska;
  sirka = sirka;
  p = window.open("zobraz_text.php?id="+id+"", "Náhled", "width="+(sirka)+" ,height="+(vyska)+",left=150,top=60");
  p.focus();
}

function zjisti(odkaz) {

  var potvrzeno = window.confirm("Opravdu chcete záznam vymazat???");

  if (potvrzeno) window.location.href = odkaz;
  
}

function ukaz(id, id_nadpis){

	
  if (document.getElementById(id).style.display == 'block') {
    document.getElementById(id).style.display = 'none';
    
  }
  else {document.getElementById(id).style.display = 'block';}
  
  
  
}

function ajax(stranka, kam)
{

    var httpRequest;
    
    if(typeof window.ActiveXObject != 'undefined')
    {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {  
        httpRequest = new XMLHttpRequest();
    }
    httpRequest.open("GET", stranka, true);
    httpRequest.onreadystatechange= function () 
    {
        processRequest(httpRequest, kam) 
    };
    httpRequest.send(null);
}
function ajax_whisper(stranka, kam){
    var httpRequest;
    
    if(typeof window.ActiveXObject != 'undefined')
    {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {  
        httpRequest = new XMLHttpRequest();
    }
    httpRequest.open("GET", '/modules/modul_whisper.php?search=' + document.getElementById('hledej').value, true);
    httpRequest.onreadystatechange = function () 
    {
        processRequest(httpRequest, kam) 
    };
    httpRequest.send(null);
}

function disp(st) {
  self.act = st;
  var ul = document.getElementById("whisper");
  if (st)
  {
    clearTimeout(self.timer);
    ul.style.visibility = "visible";
  }
  else
  {
    var f = function(){ul.style.visibility = "hidden";}
    self.timer = setTimeout(f, 500);
  }
}

function processRequest(httpRequest, kam) 
{
    if (httpRequest.readyState == 4)
    {
        if(httpRequest.status == 200)
        {
            if (typeof kam == 'string') 
            {
                document.getElementById(kam).innerHTML = httpRequest.responseText;
            }
            if (typeof kam == 'function') 
            {
                kam(httpRequest.responseText);
            }
        }
        else
        {
            alert("Chyba pri nacitani stanky " + httpRequest.status +" : "+ httpRequest.statusText);
        }
    }
    else
    {
        if (typeof kam == 'string' && kam != '') 
        {
            
        }
    }
       
}
