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 build(){
  debug=0;
  //document.getElementsByTagName('h1')[0].innerHTML=wMain;

  hMainMin=450;

  if(document.getElementById('main-obal')){
    hMaino=document.getElementById('main-obal').offsetHeight;
  }
  else{
    hMaino=0;
  }

  if(document.getElementById('main')){
    hMain=document.getElementById('main').offsetHeight;
  }
  else{
    hMain=0;
  }

  if(document.getElementById('left-obal')){
    hLefto=document.getElementById('left-obal').offsetHeight;
  }
  else{
    hLefto=0;
  }

  if(document.getElementById('left')){
    hLeft=document.getElementById('left').offsetHeight;
  }
  else{
    hLeft=0;
  }

  if(debug){
    a='Omluvte prosím tuto zprávu,\nmomentálně se testuje.';
    a+='\nhMaino: '+hMaino;
    a+='\nhMain: '+hMain;
    a+='\nhLefto: '+hLefto;
    a+='\nhLeft: '+hLeft;
    //alert(a);
  }

  hLeft=Math.max(hLefto,hLeft);
  hMain=Math.max(hMaino,hMain);
  
  max=max3(hMainMin,hMain,hLeft);
  if(hMain<max){ // kdyz je left vetsi
    if(document.getElementById('main-obal')){
      document.getElementById('main-obal').style.height = max+130+'px';
    }
  }
  if(hLeft<max){ // kdyz je main vetsi
    if(document.getElementById('left-obal')){
      document.getElementById('left-obal').style.height = max+'px';
    }
  }


  if(debug){
    a+='\n\nhMaino: '+document.getElementById('main-obal').style.height;
    a+='\nhMain: '+document.getElementById('main').style.height;
    a+='\nhLefto: '+document.getElementById('left-obal').style.height;
    a+='\nhLeft: '+document.getElementById('left').style.height;
    alert(a);
  }


  /*
  k=0;
  if(hLeft>hMain-k){ // kdyz je left vetsi
    hLeft=hLeft+k;
    document.getElementById('main-obal').style.height = hLeft+'px';
  }
  else{ // kdyz je main vetsi
    hMain=hMain-k;
    document.getElementById('left-obal').style.height = hMain+'px';
  }
  setTimeout('build()',500);
  */
}



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



function itemSwap(id){
  elementSwap(id);
  build();
}
function itemOpen(id){
  elememtOpen(id);
  build();
}
function itemClose(id){
  elementClose(id);
  build();
}


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

function k_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;
  }
}

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;
}


function help(co){
  t=false;
  switch(co){
    case 'postovni-adresa':
      t='Vaše kontaktní údaje a zároveň adresa pro dodání zásilky.';
    break;
    case 'fakturacni-adresa':
      t='Adresa pro vystavení faktury - daňového dokladu.\n';
      t+='Vyplňte pouze v případě, že je jiná než poštovní adresa.';
    break;
    case 'doklad':
      t='Pro zjednodušení a urychlení dodávky\n';
      t+='daňový doklad nevystavujeme automaticky,\n';
      t+='ale pouze na základě tohoto požadavku.';
    break;
    case 'dobirka':
      t='Zaplatíte při převzetí na poště.\n';
      t+='K ceně bude připočteno poštovné podle Nákupního řádu.';
    break;
    case 'prevodem':
      t='K ceně bude připočteno poštovné podle Nákupního řádu.\n';
      t+='Číslo účtu Vám bude sděleno v potvrzujícím e-mailu.';
    break;
    case 'osobne':
      t='Objednané zboží si můžete vyzvednout na prodejně v Benátkách.\n';
      t+='Až bude objednávka zpracována, budeme Vás informovat.';
    break;
  }

  if(t){
    alert(t);
  }
}
