proklik=0;
zmenakos=0;
matel=0;
doprava=0;

function smaz(co,textik) {
  if (co.value == textik) co.value = '';
}

function potomci(n) {
  for (i=0;i<lmncnt;i++) 
    if (lmnpr[i]==n) return 1;
  return 0;  	
}	

function lmn(x) {  	
  st=new Array (lmncnt);
  for (i=0;i<lmncnt;i++) st[i]=0;
  reky=x;	
  if (lmncnt<1) reky='';
  while (reky!='') {  
    rekx=0;
    while ((rekx<lmncnt-1)&&(reky!=lmnid[rekx])) rekx++;
    if (potomci(lmnid[rekx])==1) {
      st[rekx]=1;
    } else {
      st[rekx]=3;
    }
    for (j=0;j<lmncnt;j++) {
      if ((rekx!=j)&&(lmnpr[rekx]==lmnpr[j])) {
        if (potomci(lmnid[j])==1) {
          st[j]=2;
        } else {
          st[j]=3;
        }
      }		
    }	
    reky=lmnpr[rekx];
  }	
  for (j=0;j<lmncnt;j++) {
    if (lmnpr[j]==x) {
      if (potomci(lmnid[j])==1) {
        st[j]=2;
      } else {
        st[j]=3;
      }
    }		 
  }	
  for (i=0;i<lmncnt;i++) {
    o=document.getElementById('zx_'+lmnid[i]);
    if (st[i]>0) {
      o.style.display='block';
      p=document.getElementById('zd_'+lmnid[i]);
      if (st[i]==1) {
      	p.src='img/mnminus.gif';
      }	else if (st[i]==2) {
      	p.src='img/mnplus.gif';
      }	else {
      	p.src='img/mnnic.gif';
      }	
    } else {
      o.style.display='none';
    }  
  }
}

function znclick(co) {
  o=document.getElementById('zd_'+co);
  s=o.src;
  if (s.indexOf('minus.gif')>0) {
    i=0;
    while ((i<lmncnt-1)&&(lmnid[i]!=co)) i++;
    co=lmnpr[i];
  }	
  lmn(co);
  proklik=1;
}	

function lmclass(x,y) {
  o=document.getElementById('zx_'+x);
  o.className=y;
}	

function lmclick(x) {
  if (proklik==0) document.location='index.php?a=1&p='+x;
  proklik=0;
}		

function l(i,id,pr,lvl,ds,iovr,txt) {
  lmnid[i]=id;
  lmnpr[i]=pr;
  document.write('<div class="lmn'+lvl+'_'+ds+'" id="zx_'+id+'" onclick="lmclick(\''+id+'\')"');
  if (iovr==1) {
    document.write(' onmouseover="lmclass(\''+id+'\',\'lmn'+lvl+'_'+ds+'_o\')" onmouseout="lmclass(\''+id+'\',\'lmn'+lvl+'_'+ds+'\')"');
  } else {  
    document.write(' onmouseover="lmclass(\''+id+'\',\'lmn'+lvl+'_'+ds+'\')" onmouseout="lmclass(\''+id+'\',\'lmn'+lvl+'_'+ds+'\')"');
  }  
  document.write('><img id="zd_'+id+'" src="img/mnnic.gif" alt="" onclick="znclick(\''+id+'\')">'+txt+'</div>');
}

function zobrazsc() {
  for (i=levy;i-levy<6;i++) {
    p=document.getElementById('txg'+(i-levy+1));
    o=document.getElementById('sc_thx'+(i-levy+1));
    if (i<prcnt) {	
      p.src=imgsrc[i];
      if (i==aktualni) {
        o.className='sc_th'+(i-levy+1)+'_s';    	
      } else {  
        o.className='sc_th'+(i-levy+1);    	
      }  
    } else {
      p.src=cesta+'img/sc_th_neni.gif';
      o.className='sc_th'+(i-levy+1)+'_n';    	
    }	
  }
}

function sczvets(x) {
  if (levy+x<=prcnt) {	
    aktualni=levy+x-1;	
    p=document.getElementById('scmainimg');
    p.src=imgsrc[aktualni];
    zobrazsc();
  }  
}

function sctl(x) {
  z=levy+x;
  if (z>=prcnt) z=levy;
  if (z<0) z=0;
  levy=z;
  zobrazsc();
  if (x<0) {
    p=document.getElementById('sc_tl');
    if (levy==0) {
      p.className='sc_tl_left_n';
    }	
    p=document.getElementById('sc_tr');
    if (levy+6<=prcnt) {
      p.className='sc_tl_right';
    } else {
      p.className='sc_tl_right_n';
    }	
  } else {
    p=document.getElementById('sc_tr');
    if (levy+6>=prcnt) {
      p.className='sc_tl_right_n';
    }  
    p=document.getElementById('sc_tl');
    if (levy==0) {
      p.className='sc_tl_left_n';
    } else {
      p.className='sc_tl_left';
    }	
  }	
}
function sctlo(ktery) {
  if (ktery=='L') {
    if (levy>0) {
      p=document.getElementById('sc_tl');
      p.className='sc_tl_left_o';
    }	
  } else {
    if (levy+6<prcnt) {
      p=document.getElementById('sc_tr');
      p.className='sc_tl_right_o';
    }	
  }	 	
}
function sctlu(ktery) {
  if (ktery=='L') {
    if (levy>0) {
      p=document.getElementById('sc_tl');
      p.className='sc_tl_left';
    }	
  } else {
    if (levy+6<prcnt) {
      p=document.getElementById('sc_tr');
      p.className='sc_tl_right';
    }	
  }	 	
}

function mo(x,y) {
  o=document.getElementById(x);
  o.src='img/'+y+'.gif';
}  
function mx(x,y) {
  o=document.getElementById(x);
  o.src=y;
}  

function trcl(x) {
  document.trfrm.xsestupne.value=x;	
  document.trfrm.submit();	
}
function zbr(x) {
  document.trfrm.xzobr.value=x;	
  document.trfrm.submit();	
}

function kontrolareg() {
  errtxt='';
  b=document.regform;
  if (b.zmena.value=='ano') {
    if (b.oldpass.value.length<4) {errtxt+='Zadejte prosím vaše heslo.\n';}
  } else {	
    if (b.login.value.length<4) {errtxt+='Uživatelské jméno musí mít alespoň 4 znaky.\n';}
    if (b.pass1.value.length<4) {errtxt+='Heslo musí mít alespoň 4 znaky.\n';}
  }  
  if (b.pass1.value!=b.pass2.value) {errtxt+='Heslo a jeho kontrola se neshodují.\n';}
  if (b.jmeno.value.length<2) {errtxt+='Vyplňte prosím jméno.\n';}
  if (b.prijmeni.value.length<2) {errtxt+='Vyplňte prosím příjmení.\n';}
  if (b.ulice.value.length<2) {errtxt+='Vyplňte prosím ulici.\n';}
  s=b.ulice.value;
  x=s.split(' ');
  nasel=false;
  for (i=0;i<x.length;i++) {
    if (parseInt(x[i])>0) {
      nasel=true;
    }  
  };	
  if (!nasel) {errtxt+='Ulice musí obsahovat číslo popisné.\n';} 
  if (b.mesto.value.length<2) {errtxt+='Vyplňte prosím město.\n';}
  if (b.psc.value.length<2) {errtxt+='Vyplňte prosím PSČ.\n';}
  if (b.email.value.length<2) {errtxt+='Vyplňte prosím e-mail.\n';}
  if (errtxt>'') {
    window.alert(errtxt);	
    return false;
  } else {	
    return true;
  }	
}

function kontrolaobj() {
  if (zmenakos==1) {
    window.alert('Změnili jste množství zboží nebo způsob dopravy.\nPřed objednáním stlačte prosím aktualizovat.\n');	
    return false;
  }	
  if (doprava==1) {
    if (((document.objd.telefon.value.length>0)||(matel==0))&&(document.objd.telefon.value.length<9)) {
      window.alert('Při objednávce expresní službou PPL je nutno uvést telefonní kontakt.\n');	
      return false;
    }	
  }	
}	

var gmhsel=1;

function gmhc(x,y) {
  if (x!=gmhsel) {
    o=document.getElementById('gmhid'+x);
    if (y==1) {
      o.style.backgroundImage='url(gamedesign/img2/gm_hp_'+(x-1)+'1.gif)';
      o.style.cursor='pointer';      
    } else {
      o.style.backgroundImage='url(gamedesign/img2/gm_hp_'+(x-1)+'0.gif)';
      o.style.cursor='auto';      
    }  
  }
}
function gmhl(x) {
  o=document.getElementById('gmhid'+gmhsel);
  o.style.backgroundImage='url(gamedesign/img2/gm_hp_'+(gmhsel-1)+'0.gif)';
  o.style.cursor='pointer';
  gmhsel=x;
  o=document.getElementById('gmhid'+gmhsel);
  o.style.backgroundImage='url(gamedesign/img2/gm_hp_'+(gmhsel-1)+'1.gif)';
  o.style.cursor='auto';      
  for (i=1;i<4;i++) {
    o=document.getElementById('hmhdt'+i);
    if (i==gmhsel) {
      o.style.display='block';
    } else {
      o.style.display='none';
    }
  }
}


var gm2hsel=1;

function gm2hc(x,y) {
  if (x!=gm2hsel) {
    o=document.getElementById('gm2hid'+x);
    if (y==1) {
      o.style.backgroundImage='url(gamedesign/img2/gm_sz_'+(x-1)+'1.gif)';
      o.style.cursor='pointer';      
    } else {
      o.style.backgroundImage='url(gamedesign/img2/gm_sz_'+(x-1)+'0.gif)';
      o.style.cursor='auto';      
    }  
  }
}
function gm2hl(x) {
  o=document.getElementById('gm2hid'+gm2hsel);
  o.style.backgroundImage='url(gamedesign/img2/gm_sz_'+(gm2hsel-1)+'0.gif)';
  o.style.cursor='pointer';
  gm2hsel=x;
  o=document.getElementById('gm2hid'+gm2hsel);
  o.style.backgroundImage='url(gamedesign/img2/gm_sz_'+(gm2hsel-1)+'1.gif)';
  o.style.cursor='auto';      
  for (i=1;i<3;i++) {
    o=document.getElementById('hm2hdt'+i);
    if (i==gm2hsel) {
      o.style.display='block';
    } else {
      o.style.display='none';
    }
  }
}

