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 vymaz(id, text) {
  if (document.getElementById(id).value == text) document.getElementById(id).value = '';
}

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 kontrola(){
  var chyba = 0;
  if (document.getElementById('krjmeno').value == ''){chyba = 1;}
  if (document.getElementById('prijmeni').value == ''){chyba = 1;}
  if (document.getElementById('mail').value == ''){chyba = 1;}
  if (document.getElementById('telefon').value == ''){chyba = 1;}
  if (document.getElementById('ulice').value == ''){chyba = 1;}
  if (document.getElementById('mesto').value == ''){chyba = 1;}
  if (document.getElementById('psc').value == ''){chyba = 1;}
  if (chyba == 1) {alert('Chybí povinné položky! Vyplňte je prosím!'); return false;} else return true;
}

function parseUrl(url){
  var cleanUrl = (url + " ").replace(/[^a-zA-Z0-9]+/g, "-");
  return cleanUrl.slice(0, cleanUrl.length -1).toLowerCase();
}

function alias(url, output){
  sdiak = "áäčďéěíĺľňóô öŕšťúů üýřžÁÄČĎÉĚÍĹĽŇÓÔ ÖŔŠŤÚŮ ÜÝŘŽ";
  bdiak = "aacdeeillnoo orstuu uyrzAACDEEILLNOO ORSTUU UYRZ"; 
  tx = "";
  txt = url;
  for(p = 0; p < txt.length; p++)
  {
    if (sdiak.indexOf(txt.charAt(p)) != -1)
    {
      tx += bdiak.charAt(sdiak.indexOf(txt.charAt(p)));
    }
    else tx += txt.charAt(p);
  }
  document.getElementById(output).value = parseUrl(tx);
} 

function kontrola_delky(max, input){
  if (document.getElementById(input).value.length >= max){document.getElementById(input).style.borderColor = 'red';}
  else document.getElementById(input).style.borderColor = '#CCC';
}

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", '/geiger/admin/modules/modul_whisper.php?search=' + document.getElementById('jmeno_firmy').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
        {
        }
    }
    else
    {
        if (typeof kam == 'string' && kam != '') 
        {
           
        }
    }
       
}
