function emil(id,jm,dom2,dom1,param){
  if(dom1==''){
    dom1='cz';
  }
  adr=jm+'@'+dom2+'.'+dom1;
  href='mailto:'+adr;
  if(param){href+= '?'+param;}
  document.getElementById(id).href=href;
  document.getElementById(id).innerHTML=adr;
}



function i(id,w,h){
  sw=screen.width;
  sh=screen.height;
  wid=Math.min(w,sw);
  hei=Math.min(h,sh);
  tp=(sh-hei)/2;
  le=(sw-wid)/2;
  url='/index.php?i='+id+'&w='+w+'&h='+h;
  vla='width='+wid+',height='+hei+',toolbar=no, ';
  vla+='menubar=no, location=no, scrollbars=auto, resize=yes, ';
  vla+='top='+tp+', left='+le;
  window.open(url,'foto',vla);
}


var kam1;//global
function redir(kam){
  kam1=kam;
  setTimeout("redir1()",1000);
}
function redir1(){
  document.location=kam1;
}

function timed_redir(kam, time){
  kam1=kam;
  setTimeout("redir1()",time);
}


function max3(a,b,c){
  ab=Math.max(a,b);
  bc=Math.max(b,c);
  return Math.max(ab,bc);
}

function build(){
  if(document.getElementById('main_in')){
    tMainIn=document.getElementById('main_in').offsetTop;
    if(tMainIn>300){ // kdyz main_in ujede,
      wMainIn=document.getElementById('main_in').offsetWidth; // zjistim jeho sirku
      if(wMainIn>200){ // kdyz je sirka vetsi nez minimalni,
        document.getElementById('main_in').style.width=(wMainIn-5) + 'px'; // zmensim sirku
        setTimeout('build()',0); // a zkusim to znovu
      }
    }
    else{
      setTimeout('build()',1000); // obcas to zkontroluju
    }
  }
}


function elementSwap(id){
  if(document.getElementById(id)){
    disp=document.getElementById(id).style.display;
    if(disp=='block'){
      elementClose(id);
    }
    else if(disp=='none'){
      elementOpen(id);
    }
  }
}
function elementClose(id){
  if(document.getElementById(id)){
    document.getElementById(id).style.display='none';
  }
}
function elementOpen(id){
  if(document.getElementById(id)){
    document.getElementById(id).style.display='block';
  }
}


function zmensiObrazek(id_obr,id_blok){
  if(document.getElementById(id_obr) && document.getElementById(id_blok)){
    w_obr =document.getElementById(id_obr).offsetWidth;
    w_blok=document.getElementById(id_blok).offsetWidth;
    if( w_obr > (w_blok/2) ){
      document.getElementById(id_obr).style.width=w_obr/2 + 'px';
      h_obr =document.getElementById(id_obr).offsetHeight;
      document.getElementById(id_obr).style.height=h_obr/2 + 'px';
    }
  }
}


/*
Kontrola formuláře s údaji uživatele:
obchod/_client_data_form.php
user/_client_data_form.php
*/
function k_user_fo(){
  jm=document.getElementById('jmeno');
  ul=document.getElementById('ulice');
  me=document.getElementById('mesto');
  psc=document.getElementById('psc');
  te=document.getElementById('telefon');
  em=document.getElementById('email');

  ret=true;
  if(jm.value==''){
    alert('Zadejte prosím jméno.');
    jm.focus();
    ret=false;
  }
  else if(ul.value==''){
    alert("Zadejte prosím ulici.");
    ul.focus();
    ret=false;
  }
  else if(me.value==''){
    alert("Zadejte prosím město.");
    me.focus();
    ret=false;
  }
  else if(psc.value==''){
    alert("Zadejte prosím PSČ.");
    psc.focus();
    ret=false;
  }
  else if( (te.value=='') && ( (em.value=='@') || (em.value=='') ) ){
    alert("Zadejte prosím telefon nebo e-mail.");
    em.focus();
    ret=false;
  }

  if(ret){
    return(confirm('Hotovo?'));
  }
  else{
    return false;
  }
}

/*
Kontrola jmena a hesla
obchod/client/_client_user_form.php
user/client/_client_user_form.php
*/
function k_client_user(){
  lo=document.getElementById('login');
  he=document.getElementById('heslo');
  ret=true;

  if(lo.value==''){
    alert('Zadejte prosím přihlašovací jméno.');
    lo.focus();
    ret=false;
  }
  else if(he.value==''){
    alert("Zadejte prosím heslo.");
    he.focus();
    ret=false;
  }

  return ret;
}


/*
Kontaktni formular
/Kontakty
*/
function k_mail_fo(){
  jm=document.getElementById('jmeno');
  em=document.getElementById('email');
  pt=document.getElementById('predmet');
  zp=document.getElementById('zprava');
  ret=true;

  if(jm.value==''){
    alert('Zadejte prosím svoje jméno.');
    jm.focus();
    ret=false;
  }
  else if(em.value==''){
    alert('Zadejte prosím svou e-mailovou adresu.');
    em.focus();
    ret=false;
  }
  else if(pt.value==''){
    alert('Zadejte prosím předmět zprávy - čeho se zpráva týká.');
    pt.focus();
    ret=false;
  }
  else if(zp.value==''){
    alert("Zadejte prosím, co nám chcete sdělit.");
    zp.focus();
    ret=false;
  }

  if(ret){
    return(confirm('Odeslat?'));
  }
  else{
    return false;
  }
}



function photoKeyPress(e){
  //alert(event);
  var keynum;
  if(window.event) // IE
    {
    keynum = e.keyCode;
    }
  else if(e.which) // Netscape/Firefox/Opera
    {
    keynum = e.which;
    }
  keychar = String.fromCharCode(keynum);
  //alert(keynum);
  if(keynum==39 && nextURL){ // next
    document.location=nextURL;
  }
  else if(keynum==37 && prevURL){ // prev
    document.location=prevURL;
  }
}
