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(){
  /* Uprava pro male monitory */
  if(document.getElementsByTagName("body")[0]){
    wi=document.getElementsByTagName("body")[0].offsetWidth;
    if( (500<wi) && (wi<960) && document.getElementById('main_in') ){
      //alert(wi);
      document.getElementById('main_in').style.position='absolute';
      document.getElementById('main_in').style.top='230px';
      document.getElementById('main_in').style.left='250px';
      document.getElementById('main_in').style.width=wi-300+'px';

      hMainIn=document.getElementById('main_in').offsetHeight;
      
      document.getElementById('vocas').style.position='absolute';
      document.getElementById('vocas').style.top=hMainIn+300+'px';
      document.getElementById('vocas').style.left='0';
      document.getElementById('vocas').style.right='0';
    }
    if( (wi<900) && document.getElementById('main_in')){
      document.getElementById('papez').style.display='none';
    }
  }

  setTimeout('build()',1000); // obcas to zkontroluju
}


function build1(){
  /* Uprava pro male monitory */
  if(document.getElementsByTagName("body")[0]){
    wi=document.getElementsByTagName("body")[0].offsetWidth;
    if( (500<wi) && (wi<960) && document.getElementById('main_in') ){
      //alert(wi);
      document.getElementById('main_in').style.position='absolute';
      document.getElementById('main_in').style.top='230px';
      document.getElementById('main_in').style.left='250px';
      document.getElementById('main_in').style.width=wi-300+'px';

      hMainIn=document.getElementById('main_in').offsetHeight;

      document.getElementById('vocas').style.position='absolute';
      document.getElementById('vocas').style.top=hMainIn+300+'px';
      document.getElementById('vocas').style.left='0';
      document.getElementById('vocas').style.right='0';
    }
    if( (wi<900) && document.getElementById('main_in')){
      document.getElementById('papez').style.display='none';
    }
  }

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



function k_forum_user_login(){
  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 k_forum_register_login(){
  lo=document.getElementById('forum_login');

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


function k_forum_register_user_data(){
  jm=document.getElementById('jmeno');
  em=document.getElementById('e');
  ret=true;

  if(jm.value==''){
    alert('Zadejte prosím své jméno.');
    jm.focus();
    ret=false;
  }
  else if(em.value==''){
    alert("Zadejte prosím svůj e-mail,\naby Vám mohlo být zasláno heslo pro přihlášení.");
    em.focus();
    ret=false;
  }

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



function k_forum_change_data(){
  he1=document.getElementById('forum_heslo_1');
  he2=document.getElementById('forum_heslo_2');

  ret=true;
  if( (he1.value=='') || (he2.value=='') ){
    alert('Zadejte prosím nové heslo.');
    he1.focus();
    ret=false;
  }
  if( (he1.value) != (he2.value) ){
    alert('Hesla se neshodují!\nAsi jste se překlepl(a).');
    he1.focus();
    ret=false;
  }
  return ret;
}



function k_forum_public_form(id){
  pt=document.getElementById('predmet_' + id);
  tx=document.getElementById('text_' + id);
  ret=true;

  if(pt.value==''){
    alert('Zadejte prosím předmět příspěvku.');
    pt.focus();
    ret=false;
  }
  else if(tx.value==''){
    alert("Zadejte prosím svůj příspěvek.");
    tx.focus();
    ret=false;
  }

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





/*
Obchod
*/


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


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é a balné.';
    break;
    case 'prevodem':
      t='K ceně bude připočteno poštovné a balné.\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 v naší kanceláři v Praze - Dejvicích.\n';
      t+='Až bude objednávka zpracována, budeme Vás informovat.';
    break;
  }

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


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


/*
Vytvori JS-formular pro vlozeni prispevku.
*/
function mk_forum_form(id){
  document.getElementById('forum_reply_'+id).innerHTML='<div class="forum_form"><form action="#forum_text_' + id + '" method="post" onsubmit="return k_forum_public_form(' + id + ');"><div><label for="predmet_' + id + '"><strong>Předmět příspěvku:</strong></label> (o čem je)<br /> <input type="text" name="predmet" value="" id="predmet_' + id + '" class="w100" title="Předmět příspěvku" /></div><div> <label for="text_' + id + '"><strong>Text příspěvku:</strong></label><br /> <textarea name="text" id="text_' + id + '" cols="50" rows="15" class="w100" title="Text příspěvku"></textarea></div><div> <input type="hidden" name="forum_ptr" value="' + id + '" id="forum_ptr_' + id + '" /> <input type="hidden" name="k" value="prispevek" id="k_' + id + '" /> <input type="submit" value="Odeslat" class="submit_button" /></div></form></div>';
}
