
  if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
    throw new Error( "This browser does not support XMLHttpRequest." )
  };


function pageclick(event) {
  if (window.event) {
		event = window.event;
	}
  o=document.getElementById("sepot");
  if (o) {
    vzbnas=-1;
    o.style.display='none';
  }
  o=document.getElementById('adrnas0');
  if (o) {
    vybadr0=-1;
    o.style.display='none';
  }
  o=document.getElementById('adrnas1');
  if (o) {
    vybadr1=-1;
    o.style.display='none';
  }
}


function naspohyb(event) {
  if (window.event) {
		event = window.event;
	}
  if ((event.keyCode==38)||(event.keyCode==40)||(event.keyCode==13)) {
    o=document.getElementById("nas_tbl");
    if (o) {
      cnt = o.rows.length - 1;
      if ((event.keyCode==38)&&(vybnas>-1)&&(cnt>0)) {
        vybnas--;
        prekreslinas();
      }  
      if ((event.keyCode==40)&&(vybnas<cnt-1)&&(cnt>0)) {
        vybnas++;
        prekreslinas();
      }  
      if ((event.keyCode==13)&&(vybnas>=0)&&(cnt>0)&&(vybnas<cnt)) {
        hmc(vybnas);
      }
    }
  } 
}


function naseptavac(event) {
  if (window.event) {
		event = window.event;
	}
  if ((event.keyCode==38)||(event.keyCode==40)) {
    return;
  }
  hltxt=document.getElementById('hltxt').value;
  if (hltxt.length<3) {
    o=document.getElementById("sepot");
    o.innerHTML='';
    o.style.display='none';
  } else {  
    naseptej(hltxt);
  }  
}

function naseptej(hltxt) {
  var ar;
  ar = new XMLHttpRequest();
  rnd = Math.random();
  if (encodeURIComponent) {
    hltxt = encodeURIComponent(hltxt);
  } else {
    hltxt = escape(hltxt);
  }  
  ar.open("GET", 'naseptavac.php?rnd='+rnd+'&hltxt='+hltxt, true);
  ar.onreadystatechange=function () {naseptano(ar); } ;
  ar.send(null);
}

function naseptano(ar) {
  if ((ar.readyState == 4)&&(ar.status == 200)) {
    o=document.getElementById("sepot");
    o.innerHTML = ar.responseText;
    o.style.display='block'; 
    vybnas=-1;
    prekreslinas();
  }
}    

vybnas=-1;

function prekreslinas() {
  o=document.getElementById("nas_tbl");
  cnt = o.rows.length - 1;
  for (i=0;i<cnt;i++) {
    if (i==vybnas) {
      document.getElementById("hta"+i).className='mhl_nn2';
      document.getElementById("htb"+i).className='mhl_nc2';
    } else {
      document.getElementById("hta"+i).className='mhl_nn';
      document.getElementById("htb"+i).className='mhl_nc';
    }
  }
  
}

function hmt(i) {
  vybnas=-1;
  prekreslinas();
}
function hmo(i) {
  vybnas=i;
  prekreslinas();
}
function hmc(i) {
  document.getElementById('hltxt').value=document.getElementById("hta"+i).innerHTML;
  document.hlform.submit();
}

function cancelbuble(evt) {
  if (window.event!=null) {	
    window.event.cancelBubble = true;
  } else {
    evt.cancelBubble = true;
  }  
} 

function le() {
  if (!window.addEventListener) {
    document.attachEvent ('onclick', pageclick);
  }
}   

function potvrd_kos() {
  document.kosik.action='doprava';
  document.kosik.submit();
}
function prepocitej_kos() {
  document.kosik.action='kosik';
  document.kosik.submit();
}

function mena(x) {
  if (x<1000) return x;
  y=x.toString();
  return y.substring(0,y.length-3)+' '+y.substring(y.length-3);
}

function dx() {
  i=0;
  cena=0;
  chybi=999999999;
  if (cntdp>1) {
    while ((i<cntdp)&&(!document.doprava.doprava[i].checked)) i++;
  }  
  if (i==cntdp)  return;
  if (cntdp>1) {
    iddoprava=document.doprava.doprava[i].value;
  } else {
    iddoprava=document.doprava.doprava.value;
  }  
  for(k=0;k<cntdp;k++) if (dpid[k]==iddoprava) cena+=dpcn[k];
  for (i=0;i<cntpl;i++) document.doprava.platba[i].disabled=true;
  for (i=0;i<cntk;i++) {
    if (dpk[i][0]==iddoprava) {
      j=0;
      while ((j<cntpl)&&(plid[j]!=dpk[i][1])) j++;
      if (j<cntpl) document.doprava.platba[j].disabled=false;
    }
  }
  musimvybrat=false;
  for (i=0;i<cntpl;i++) 
    if ((document.doprava.platba[i].disabled)&&(document.doprava.platba[i].checked)) {
      document.doprava.platba[i].checked=false;   
      musimvybrat=true;
    }  
  if (musimvybrat) {
    i=0;
    while ((i<cntpl)&&(document.doprava.platba[i].disabled)) i++;
    if (i<cntpl) document.doprava.platba[i].checked=true;   
  } 
  idplatba=0;
  for (i=0;i<cntpl;i++) 
    if (document.doprava.platba[i].checked) {
      cena+=plcn[i];
      idplatba=plid[i];
    }
  i=0;
  var dv2=false;
  var dv3=false;
  cnzdarma=0;
  if (cena>0) {  
    while ((i<cntk)&&!((dpk[i][0]==iddoprava)&&(dpk[i][1]==idplatba))) i++;
    if (i<cntk) {
      if (dpk[i][2]<=kosik_celkem) {
        cena=0;
        chybi=0;
        dv2=true;
        cnzdarma=dpk[i][2];
      } else {
        chybi=dpk[i][2]-kosik_celkem;
        dv3=true;
      }
    }
  }  
  document.getElementById('dp1').innerHTML=mena(cena);
  document.getElementById('dpd1').innerHTML=mena(cena);
  document.getElementById('dp2').innerHTML=mena(cena+kosik_celkem);
  document.getElementById('dpd2').innerHTML=mena(cena+kosik_celkem);
  if (dv2) {
    document.getElementById('dv2').style.display='block';
    document.getElementById('dv2t').innerHTML=mena(cnzdarma);
    document.getElementById('dvd2').style.display='block';
    document.getElementById('dvd2t').innerHTML=mena(cnzdarma);
  } else {
    document.getElementById('dv2').style.display='none';
    document.getElementById('dvd2').style.display='none';
  }
  if (dv3) {
    document.getElementById('dv3').style.display='block';
    document.getElementById('dv3t').innerHTML=mena(chybi);
    document.getElementById('dvd3').style.display='block';
    document.getElementById('dvd3t').innerHTML=mena(chybi);
  } else {
    document.getElementById('dv3').style.display='none';
    document.getElementById('dvd3').style.display='none';
  }
  for(i=0;i<cntdp;i++) {
    o=document.getElementById('dpx'+i).style;
    if (document.doprava.doprava[i].disabled) {
      o.color='#A0A0A0';
      o.textDecoration='line-through';      
    } else {
      o.color='#2c79b6';      
      o.textDecoration='none';      
    }
  } 
  for(i=0;i<cntpl;i++) {
    o=document.getElementById('plx'+i).style;
    if (document.doprava.platba[i].disabled) {
      o.color='#A0A0A0';      
      o.textDecoration='line-through';      
    } else {
      o.color='#2c79b6';      
      o.textDecoration='none';      
    }
  } 
     
}

function druhaadr() {
  if (document.adresa["u[adr_2]"].checked) {
    document.getElementById('druhaadresa').style.display='block';
  } else {
    document.getElementById('druhaadresa').style.display='none';
  }
}

baner_popojizdet=true;
akt_top_banner=-1;

function nastav_top_banner(x,smer) {
  if (smer==-999) {
    if (!baner_popojizdet) return;
    smer=-1;
  }
  if (akt_top_banner>=0) {
    o=document.getElementById('bntmn');
    if (o.filters) {
      o.style.filter="blendTrans(duration=0.5)";
      o.filters.blendTrans.Apply();
      o.src='bannery/'+bimg[x];
      o.filters.blendTrans.Play();
    } else {
      o.src='bannery/'+bimg[x];
    }
    if (smer!=0) posun_pojizdec(smer,1);
  }    
  document.getElementById('bnttx').innerHTML=btxt[x];
  document.getElementById('bnta').href=burl[x];
  akt_top_banner=x;
  if (baner_popojizdet) {
    x--;
    if (x<0) x=bcnt-1;
    setTimeout('nastav_top_banner('+x+',-999)',5000);
  }
}

function posun_pojizdec(smer,krok) {
  if (krok==8) {
    if ((smer<-1)||(smer>1)) {
      if (smer<0) {
        x=akt_top_banner+1;if (x>=bcnt) x=0;
        smer++;
      } else {
        x=akt_top_banner-1;if (x<0) x=bcnt-1;
        smer--;
      }
      nastav_top_banner_pojizdec(x);
      setTimeout('posun_pojizdec('+smer+',1)',50); 
    } else {
      nastav_top_banner_pojizdec(akt_top_banner);
    }
  } else {
    if (krok==1) {
      posun=9;
    } else if (krok==2) {
      posun=14;
    } else if (krok==3) {
      posun=21;
    } else if (krok==4) {
      posun=26;
    } else if (krok==5) {
      posun=35;
    } else if (krok==6) {
      posun=40;
    } else if (krok==7) {
      posun=45;
    }
    if (smer>0) {
      posun=-1*posun;
    }
    for (i=0;i<7;i++) {
      document.getElementById('btnd'+i).style.top=(47*i-51+posun)+'px';
    }
    setTimeout('posun_pojizdec('+smer+','+(krok+1)+')',40);
  }
  
}

function nastav_top_banner_pojizdec(x) {
  for (i=0;i<7;i++) {
    p=x+i-3;
    while (p<0) p+=bcnt;
    while (p>=bcnt) p-=bcnt;
    m=document.getElementById('bntl'+i);
    m.src='bannery/'+bimg[p];
    n=document.getElementById('bntla'+i);
    smer=0;
    if (i<2) {
      smer=-2;
    } else if (i==2) {
      smer=-1;
    } else if (i==4) {
      smer=1;
    } else if (i>4) {
      smer=2;
    }   
    n.href='javascript:baner_popojizdet=false;nastav_top_banner('+p+','+smer+')';
    document.getElementById('btnd'+i).style.top=(47*i-51)+'px';
    opc=0.3;
    if ((i==2)||(i==4)) opc=0.6;
    if (i==3) opc=1;
    m.style.opacity=opc;
    opc*=100;
    m.style.filter="alpha(opacity="+opc+")";
  }
}

function top_banner_dw() {
  baner_popojizdet=false;
  x=akt_top_banner-1;
  if (x<0) x=bcnt-1;
  nastav_top_banner(x,-1);
}
function top_banner_up() {
  baner_popojizdet=false;
  x=akt_top_banner+1;
  if (x>=bcnt) x=0;
  nastav_top_banner(x,1);
}

var okacka=0;

function adrajax(a,x,event) {
  if (window.event) {
		event = window.event;
	}
  if (event && ((event.keyCode==38)||(event.keyCode==40)||(event.keyCode==13))) {
    return;
  }
  var ar2;
  ar2 = new XMLHttpRequest();
  f=document.adresa;
  var data='a='+a+'&akce='+x+'&mesto='+escape(encodeURI(f['u[adr]['+a+'][mesto]'].value));
  data+='&psc='+escape(encodeURI(f['u[adr]['+a+'][psc]'].value));
  data+='&ulice='+escape(encodeURI(f['u[adr]['+a+'][ulice]'].value));
  data+='&cp='+escape(encodeURI(f['u[adr]['+a+'][cp]'].value));
  data+='&okacka='+okacka;
  data+='&adrerr=';
  if (f['u[adr]['+a+'][adrerr]']) {
    if (f['u[adr]['+a+'][adrerr]'].type=='checkbox') {
      if (f['u[adr]['+a+'][adrerr]'].checked) {
        data+='1';
      } else {  
        data+='0';
      }
    } else {
      data+=f['u[adr]['+a+'][adrerr]'].value;
    }
  } else {
    data+='0';
  }  
  rnd = Math.random();
  ar2.open("POST", 'adrajax.php?rnd='+rnd+'&akce='+x, true);
  ar2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ar2.setRequestHeader("Content-length", data.length);
  ar2.setRequestHeader("Connection", "close");
  ar2.onreadystatechange=function () {adrajaxret(ar2); } ;
  ar2.send(data);
}

vybadr=new Array(2);
vybadr[0]=-1;
vybadr[1]=-1;

function adrajaxret(ar2) {
  if ((ar2.readyState == 4)&&(ar2.status == 200)) {
    //alert(ar2.responseText);
    a=ar2.responseText.substring(0,1);
    c=ar2.responseText.substring(1,2);
    t=ar2.responseText.substring(2);
    if (c=='m') {
      n=document.getElementById('adrnas'+a);
      n.style.display='block';
      n.style.position='absolute';
      n.style.top='20px';
      n.style.left='151px';
      n.innerHTML = t;
      vybadr[a]=-1;
      document.adresa['u[adr]['+a+'][mesto]'].focus();    
    }
    if (c=='p') {
      n=document.getElementById('adrnas'+a);
      n.style.display='block';
      n.style.position='absolute';
      n.style.top='42px';
      n.style.left='151px';
      n.innerHTML = t;
      vybadr[a]=-1;
    }
    if (c=='u') {
      n=document.getElementById('adrnas'+a);
      n.style.display='block';
      n.style.position='absolute';
      n.style.top='64px';
      n.style.left='151px';
      n.innerHTML = t;
      vybadr[a]=-1;
    }
    if (c=='c') {
      n=document.getElementById('adrnas'+a);
      n.style.display='block';
      n.style.position='absolute';
      n.style.top='86px';
      n.style.left='151px';
      n.innerHTML = t;
      vybadr[a]=-1;
    }
    if (c=='x') {
      document.adresa['u[adr]['+a+'][psc]'].value=t;
      if ((a==0)&&(okacka==1)) adrok('psc'); 
    }
    if (c=='y') {
      document.adresa['u[adr]['+a+'][mesto]'].value=t;
      document.adresa['u[adr]['+a+'][ulice]'].focus();    
    }
    if (c=='.') {
      n=document.getElementById('adrnas'+a);
      n.style.display='none';
      n.innerHTML = '';
    }
    if (c==' ') {
      o=document.getElementById('adr'+a);
      o.innerHTML = t;
    }  
  }
}    


function prekresliadr(a) {
  i=0;
  while (o=document.getElementById("hax"+i)) {
    if (i==vybadr[a]) {
      o.className='nadrs';
    } else {
      o.className='nadrn';
    }
    i++;
  }
}

function haxt(i,a) {
  vybadr[a]=-1;
  prekresliadr(a);
}
function haxo(i,a) {
  vybadr[a]=i;
  prekresliadr(a);
}
function haxc(i,a,c) {
  o=document.getElementById("hax"+i);
  t=o.innerHTML;
  if (c=='m') {
    document.adresa['u[adr]['+a+'][mesto]'].value=t;
    document.getElementById('adrnas'+a).style.display='none';
    document.adresa['u[adr]['+a+'][psc]'].focus();    
    adrajax(a,'psc',null)
    if ((a==0)&&(okacka==1)) adrok('mesto'); 
  }
  if (c=='p') {
    document.adresa['u[adr]['+a+'][psc]'].value=t;
    document.getElementById('adrnas'+a).style.display='none';
    if (document.adresa['u[adr]['+a+'][mesto]'].value.length==0) {
      adrajax(a,'mesto',null)
    } else {
      document.adresa['u[adr]['+a+'][ulice]'].focus();    
    }
    if ((a==0)&&(okacka==1)) adrok('psc'); 
  }
  if (c=='u') {
    document.adresa['u[adr]['+a+'][ulice]'].value=t;
    document.getElementById('adrnas'+a).style.display='none';
    document.adresa['u[adr]['+a+'][cp]'].focus();    
    adrajax(a,'cp',null)
  }
  if (c=='c') {
    document.adresa['u[adr]['+a+'][cp]'].value=t;
    document.getElementById('adrnas'+a).style.display='none';
    document.adresa['u[adr]['+a+'][telefon]'].focus();    
    if ((a==0)&&(okacka==1)) adrok('cp'); 
  }
}

function adrpohyb(a,c,event) {
  if (window.event) {
		event = window.event;
	}
  if ((event.keyCode==38)||(event.keyCode==40)||(event.keyCode==13)||(event.keyCode==9)) {
    o=document.getElementById("adrnas"+a);
    if (o) {
      cnt = o.getElementsByTagName('div').length - 1;
      if ((event.keyCode==38)&&(vybadr[a]>-1)&&(cnt>0)) {
        vybadr[a]--;
        prekresliadr(a);
      }  
      if ((event.keyCode==40)&&(vybadr[a]<cnt-1)&&(cnt>0)) {
        vybadr[a]++;
        prekresliadr(a);
      }  
      if (((event.keyCode==13)||(event.keyCode==9))&&(vybadr[a]>=0)&&(cnt>0)&&(vybadr[a]<cnt)) {
        x=vybadr[a];
        vybadr[a]=-1;
        haxc(x,a,c);
        return false;  
      }
    }
  } 
}


function handleEnter (event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		return !(keyCode == 13);
	}      

  function chadr(a,c) { 
    if (a>=0) {
      document.adresa['u[adr]['+a+']['+c+']'].style.backgroundColor='white';
    } else {
      document.adresa['u['+c+']'].style.backgroundColor='white';
    }  
    if (((c=='mesto')||(c=='psc')||(c=='ulice')||(c=='cp'))&&(o=document.getElementById("adrerrinfo"+a))) o.style.display='none';
  
  }

function adrfo() {
  if (n=document.getElementById('adrnas0')) {
    n.style.display='none';
    n.innerHTML = '';
  }  
  if (n=document.getElementById('adrnas1')) {
    n.style.display='none';
    n.innerHTML = '';
  }  
}

scpos=1;
scjedu=false;
function srp(smer) {
  if (scjedu) return; 
  l=document.getElementById('scl');
  r=document.getElementById('scr');
  if (smer==-1) {
    if (scpos>1) {
      scpos--;
      if (scpos==1) {
        l.src='img/scl0.png';
        l.style.cursor='default';
      }  
      if (sccnt-scpos>=5) {
        r.src='img/scr1.png';
        r.style.cursor='pointer';
      }  
      i=document.getElementById('sc'+scpos);
      i.style.width='0px';
      i.style.display='inline-block';
    } else {
      return;
    }  
  }
  if (smer==1) {
    if (scpos<=sccnt-5) {
      scpos++;
      if (scpos==sccnt-4) {
        r.src='img/scr0.png';
        r.style.cursor='default';
      }  
      if (scpos>1) {
        l.src='img/scl1.png';
        l.style.cursor='pointer';
      }  
      i=document.getElementById('sc'+(scpos+4));
      i.style.width='0px';
      i.style.display='inline-block';
    } else {
      return;
    }  
  }
  scjedu=true;
  sckrok(0,smer);
}

function sckrok(x,smer) {
  if (x==5) {
    if (smer==-1) {
      document.getElementById('sc'+scpos).style.width=scw[scpos]+'px';
      document.getElementById('sc'+(scpos+5)).style.display='none';
    } else {
      document.getElementById('sc'+(scpos+4)).style.width=scw[scpos+4]+'px';
      document.getElementById('sc'+(scpos-1)).style.display='none';
    }
    scjedu=false;
  } else {
    if (smer==-1) {
      document.getElementById('sc'+scpos).style.width=(scw[scpos]*x/5)+'px';
      document.getElementById('sc'+(scpos+5)).style.width=(scw[scpos+5]*(5-x)/5)+'px';
    } else {
      document.getElementById('sc'+(scpos-1)).style.width=(scw[scpos-1]*(5-x)/5)+'px';
      document.getElementById('sc'+(scpos+4)).style.width=(scw[scpos+4]*x/5)+'px';
    }
    setTimeout('sckrok('+(x+1)+','+smer+')',40);
  }
}

function getheight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement &&  document.documentElement.clientHeight ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    myHeight = document.body.clientHeight;
  }
  return Number(myHeight);
}

function getwidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
  } else if( document.documentElement &&  document.documentElement.clientWidth ) {
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth ) {
    myWidth = document.body.clientWidth;
  }
  return Number(myWidth);
}

function getScrollX() {
  var scrOfX = 0;
  if( typeof( window.pageXOffset ) == 'number' ) {
    scrOfX = window.pageXOffset;
  } else if( document.body && document.body.scrollLeft ) {
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && document.documentElement.scrollLeft ) {
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}  

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}  

function scsscrool() {
  alert('r');
}

function scs(x) {
  h=getheight();  if (h<480) h=480;
  w=getwidth();  if (w<640) w=640;
  o=document.getElementById('sc');
  o.style.width=w+'px';
  o.style.left=getScrollX()+'px';
  o.style.height=h+'px';
  o.style.top=getScrollY()+'px';
  o.style.display='block';
  o.onclick=scz;
  if (window.addEventListener)
    window.addEventListener('DOMMouseScroll', posun, false);
  window.onmousewheel = document.onmousewheel = posun;
  window.onscroll = document.onscroll = posun;
  scsajax(x);
}

function scz() {
  o=document.getElementById('sc');
  o.innerHTML='';
  o.onclick=null;
  o.style.display='none';
}

function posun() {
  o=document.getElementById('sc');
  o.style.left=getScrollX()+'px';
  o.style.top=getScrollY()+'px';
}

function scsajax(x) {
  var ar3;
  ar3 = new XMLHttpRequest();
  rnd = Math.random();
  ar3.open("GET", 'sc.php?rnd='+rnd+'&id='+x+'&w='+getwidth()+'&h='+getheight(), true);
  ar3.onreadystatechange=function () {scax(ar3); } ;
  ar3.send(null);
}

function scax(ar3) {
  if ((ar3.readyState == 4)&&(ar3.status == 200)) {
    document.getElementById("sc").innerHTML = ar3.responseText;
  }
}    

function prodinfoajax(x) {
  var ar4;
  ar4 = new XMLHttpRequest();
  rnd = Math.random();
  ar4.open("GET", 'prodinfo.php?rnd='+rnd+'&id='+x+'&w='+getwidth()+'&h='+getheight(), true);
  ar4.onreadystatechange=function () {prodax(ar4); } ;
  ar4.send(null);
}

function prodax(ar4) {
  if ((ar4.readyState == 4)&&(ar4.status == 200)) {
    document.getElementById("sc").innerHTML = ar4.responseText;
  }
}    



function scn(x,y) {
  o=document.getElementById("scnavig");
  if (x==1) {
    o.style.display='block';
  } else {
    o.style.display='none';
  }
  if (y=='x') return;
  o=document.getElementById('scx'+y);
  o.className='scx'+y+x;
}

function regajax(x) {
  var ar4;
  ar4 = new XMLHttpRequest();
  rnd = Math.random();
  ar4.open("GET", 'regajax.php?rnd='+rnd+'&typ='+x, true);
  ar4.onreadystatechange=function () {rgax(ar4); } ;
  ar4.send(null);
}

function rgax(ar4) {
  if ((ar4.readyState == 4)&&(ar4.status == 200)) {
    t=ar4.responseText;
    if (t.substring(0,4)=='js::') {
      t=t.substring(4,t.length);
      eval(t);
    } else {
      document.getElementById("dalsiadresy").innerHTML = ar4.responseText;
    }
  }
}

function zva(x) {
  document.getElementById('adrprepinac').style.display='none';
  if (x==1) {
    document.getElementById('druhaadresa').style.display='block';
  } else {
    document.getElementById('druhaadresa').style.display='none';
  }
  o=document.getElementById('dalsiadresy');
  o.style.display='block';
  regajax('show');
}

aktrva=0;

function rvao(x,y) {
  if (x==aktrva) return;
  o=document.getElementById('rvatr'+x);
  if (y==1) {
    o.style.backgroundColor='#FFFFCC';
  } else {
    o.style.backgroundColor='#FFFFFF';
  } 
}


function rvae(x) {
  m=document.getElementById('rvatb').rows;
  for (i=0;i<m.length;i++) {
    if (m[i].id) m[i].style.backgroundColor='#FFFFFF';
  }
  if (x==-1) {
    f=document.adresa;
    f['u[adr][1][titul]'].value='';
    f['u[adr][1][jmeno]'].value='';
    f['u[adr][1][prijmeni]'].value='';
    f['u[adr][1][firma]'].value='';
    f['u[adr][1][ulice]'].value='';
    f['u[adr][1][cp]'].value='';
    f['u[adr][1][mesto]'].value='';
    f['u[adr][1][psc]'].value='';
    f['u[adr][1][telefon]'].value='';
    f['u[adr][1][adrerr]'].checked=false;
    f['u[zasilaci_adresa]'].value=-1;
    document.getElementById('adrerrinfo1').style.display='none';
    aktrva=0;
  } else {
    aktrva=x;
    o=document.getElementById('rvatr'+x).style.backgroundColor='#FFA0E0';
    regajax(x);
  }
  document.getElementById('adr_poznamka').style.display='none';
  document.getElementById('druhaadresa').style.display='block';
}

function bcx(url,e) {
  evt = e || window.event;
  if (evt.srcElement) {
    if (evt.srcElement.id=='bdid') {
      window.location =url;
    }  
  } else {
    if (evt.target.id=='bdid') {
     window.location =url;
    }
  }    
}


function kpp() {
  document.getElementById('kprp').style.display='inline-block';
  document.getElementById('kpdl').style.display='none';
}

function adrok(x) {
  var status=false;
  if ((x=='jmeno')&&(document.adresa['u[adr][0][jmeno]'].value.length>1)) status=true;
  if ((x=='prijmeni')&&(document.adresa['u[adr][0][prijmeni]'].value.length>1)) status=true;
  if ((x=='telefon')&&(document.adresa['u[adr][0][telefon]'].value.length>8)) status=true;
  if (x=='email') {
    mtest=new RegExp('^[0-9a-z\\._-]+@[0-9a-z\\._-]+[a-z]{2,5}\$','i');
    if (mtest.test(document.adresa['u[email]'].value)) status=true;
  }  
  if ((x=='mesto')&&(document.adresa['u[adr][0][mesto]'].value.length>1)) status=true;
  if ((x=='psc')&&(document.adresa['u[adr][0][psc]'].value.length>4)) status=true;
  if ((x=='cp')&&(document.adresa['u[adr][0][cp]'].value.length>0)) status=true;
  o=document.getElementById('adrok_'+x);
  if (status) {
    o.src='img/adrok_ok.gif';
  } else {
    o.src='img/adrok_bad.gif';
  } 
}

function hrzzs(x) {
  for (i=1;i<=5;i++) {
    o=document.getElementById('hrzs'+i);
    p=document.getElementById('hrzx'+i);
    if (i==Number(x)) {
      if (o) o.className='hra_nav_sel';
      if (p) p.className='hra_zal_vid';
    } else {
      if (o) o.className='hra_nav_sek';
      if (p) p.className='hra_zal_nevid';
    }
  }
}

function sklinfo(x) {
  o=document.getElementById('sc');
  o.style.width='100%';
  o.style.left=0;
  o.style.height='200%';
  o.style.top=getScrollY()+'px';
  o.style.display='block';
  o.onclick=scz;
  prodinfoajax(x);
}

