var mydiv,mhlpid;
var oScript;
var BoolNasept = false;
var myInterval;
var Pocitadlo=1
var AllTop;
var myNasept;
var myx,myy,el;
function stOP(ev)
{

if(!document.all)
 {
 ev.stopPropagation();
 el=ev.target;
 }
 else
 {
 event.cancelBubble=true;
 el=event.srcElement;
 }
if(el.className=="open")
   {
   el.className="closed"
   return;
   }
if(el.className=="closed")
   {
   el.className="open"
   
   return;
   }

}
function setSbal()
{
myLis=document.getElementsByTagName('li');
var c=0;
for(i=0;i<myLis.length;i++)
 {
  if(myLis[i].className=='open' || myLis[i].className=='closed' )
    {
 if (window.addEventListener)
    {
    myLis[i].addEventListener("click", stOP, false); 
    
    }
  else
    {
    myLis[i].attachEvent("onclick",stOP); 
    c =c +1
    }
    
    }
 
 }

}
function revriteMail(el)
{
 mystr=el.href
 mystrA=mystr.split('(a)');
 el.href=mystrA[0]+'@'+mystrA[1];
 return true
 
}
function setBorder(el,nr)
{
 if(nr==1)
   {
   el.style.borderColor="white";
   el.style.cursor="pointer";
   }
   else
   {
    el.style.borderColor="black";
    
   }
}
function clickTD(el)
{
 if(el.tagName!='TD')return false;
 myA= el.getElementsByTagName('A') 
 if(myA.length<1)return false;
 myPth=myA[0].href;
 location.href=myPth;
 return false;
}
function clickDiv(ev)
{
 if(!document.all)
   {
   el=ev.target;
   ev.stopPropagation()
   if(el.tagName!='DIV')el=el.parentNode;
   }
   else
   {
   el=event.srcElement;
   event.cancelBubble=true;
   if(el.tagName!='DIV')el=el.parentElement;
   }
 
 myA= el.getElementsByTagName('A') 
 if(myA.length<1)return false;
 myPth=myA[0].href;
 location.href=myPth;
 return false;
}
function GoOBR2(el)
{
myPATH= el.href
//alert(myPATH)
//return false
self.name="togot";
feath="resizable=1,width=200,height=200,location=0,directories=0,toolbar=0,menubar=0,status=1,dependent=1,scrollbars=1"
myM=window.open(myPATH,"OBRGAL",feath)
if(myM)myM.focus();
myM=!myM
return false
}
function GoOBR(nr)
{
myPATH='/image.php?ID='+nr
//alert(myPATH)
//return false
self.name="togot";
feath="resizable=1,width=200,height=200,location=0,directories=0,toolbar=0,menubar=0,status=1,dependent=1,scrollbars=1";
myM=window.open(myPATH,"OBRGAL",feath);
if(myM)myM.focus();
}
function svTM(el,nr)
{
 if(nr==1)
  {
   el.className='tablemenuA';
   
  }
else
  {
   el.className='tablemenu';
   
  }
return false; 
}
function ReCountFl(pol,el,toid)
{
 pocet=parseInt(el.value)
 cena=parseFloat(pol)*pocet
 //alert(cena);
 document.getElementById('toid').value=cena;
 
}
function confirmSendOrd(el)
{
  //PR,KS
  ks=parseInt(document.getElementById('KS').value);
  //alert(ks);
  cn=parseFloat(document.getElementById('PR').value);
  vysl=ks*cn
  document.getElementById('toid').value=vysl;
  myF=confirm('Chci objednat - '+ ks +' ks zboží o celkové ceně ' +  vysl + '!')
  if(!myF)return false;
  el.form.submit();
 return true; 
}

function setTR(el,nr)
{
if(nr==1)
  {
    if(!document.all)
      {
      el.setAttribute("oldClass",el.className);
      el.setAttribute("class","trActiv");
      
      }
      else
      {
      el.oldClass=el.className;
      el.className="trActiv";
      
      }
   }   
else
  {
    if(!document.all)
      {
      myClass=el.getAttribute("oldClass");
      el.setAttribute("class",myClass);
      }
    else
      {
      myClass=el.oldClass;
      el.className=myClass;
      }
  
  }
  return false;
}
function confirmDel(el)
{
  //PR,KS
  ks=parseInt(document.getElementById('KS').value);
  //alert(ks);
  cn=parseFloat(document.getElementById('PR').value);
  vysl=ks*cn
  document.getElementById('toid').value=vysl;
  myF=confirm('Skutočne chcete zmazať vybraný záznam?')
  return myF;
  
  
}
function checkImageInA(imgName,nr,el)
{
 switchPath='http://'+ location.hostname +'/alff/';
 if(el.tagName!='A')return false
 myEl=el.getElementsByTagName('img');
 //alert(myEl.length)
 myEl[0].src= switchPath + 'new_ico/' + imgName + nr + '.gif';
 return false;
}
function swpCTYP(el)
{
 if(el.value==0)
  {
   document.getElementById('fyob').style.display="";
   document.getElementById('prob').style.display="none";
  }
 else
  {
   document.getElementById('fyob').style.display="none";
   document.getElementById('prob').style.display="";
  }
 return false;
}
function kontrola(frm)
{
//if (EregI("^[a-z0-9]+[a-z0-9\._-]*[a-z0-9]+@[a-z0-9]+[a-z0-9\._-]*[a-z0-9]+\.[a-z]{2,3}$", $adresa) && !EregI("\.{2,}", $adresa) && !EregI("_{2,}", $adresa) && !EregI("-{2,}", $adresa) ):
var r=new RegExp("^[a-z0-9]+[a-z0-9\._-]*[a-z0-9]+@[a-z0-9]+[a-z0-9\._-]*[a-z0-9]+\.[a-z]{2,3}$","i");
mymail=document.getElementById('mail').value
if(mymail=='')
  {
  alert('pole adresa je nutno vyplnit')
  return false;
  }
ino=r.test(mymail)
if(!ino)
 {
 alert('pole adresa musí obsahovat platnou adresu elektronické pošty')
 return false;
 }
mynick=document.getElementById('nick').value
  if(mynick=='')
  {
  alert('Takhle by to nešlo, alespoň přezdívku proím!')
  return false;
  }
mytelo=document.getElementById('telo').value
  if(mytelo=='')
  {
  alert('Něco napiš než to pošleš')
  return false;
  }
frm.submit();
return true;
}
function swD(nr)
{
if(nr==1)
  {
  document.getElementById('proo').style.display='none';
  document.getElementById('pridat').style.display='';
  
  }
  else
  {
  document.getElementById('pridat').style.display='none';
  document.getElementById('proo').style.display='';
  }
  return false;
}
function setMenu()
{
myDivs=document.getElementById("myMenu").getElementsByTagName('DIV');
for (i=0;i<myDivs.length;i++)
  {
   if (window.addEventListener)
    {
   myDivs[i].addEventListener("click",clickDiv, false); 
    
    }
  else
    {
    myDivs[i].attachEvent("onclick",clickDiv); 
    
    }
   
  }
 setHlist()
 return false; 
}
function setHlist()
{
if(!document.getElementById('hlist'))
  {
  return false
  
  }
  else
  {
  myH2=document.getElementsByTagName('H2')
  myOut='';
  for (i=0;i<myH2.length;i++)
    {
    myH2[i].id='mhl'+i;
    myOut=myOut+'<li><a href="#'+myH2[i].id+'" class="mhlist">'+myH2[i].firstChild.data+'</a></li>';
    dt=myH2[i].firstChild.data;
    dt=document.createElement('A');
    dt.href='#hlist';
    dt.title='zpět na obsah';
    dt.innerHTML='<span style="background:rgb(204,102,0);padding:1px 3px 1px 3px;color:white;font-weight:bold">&uarr;</span>';
    dt.style.fontSize='10px';
    dt.className='mhlist'
    myH2[i].appendChild(dt);
    }
    if(myOut!='')
    {
    //myOut='<ul>'+myOut+'</ul>';
    myUL=document.createElement("UL");
    myUL.innerHTML=myOut;
    document.getElementById('hlist').appendChild(myUL);
    }
  }
  return false;
}
function goNasept(ev,myid)
{
myNasept=document.getElementById('nasept');
if(!myNasept)
   {
	 myNasept=document.createElement('div');
	 myNasept.setAttribute('id','nasept');
	 document.getElementsByTagName('body')[0].appendChild(myNasept);
	 }

var oScript = document.createElement('script');
oScript.setAttribute('type','text/javascript');
oScript.setAttribute('src','/lbr/desc_add.php?DID='+myid);
document.getElementById('nasept').appendChild(oScript);
ShowY(ev);
}


function getTableSet(){
setHlist();
var testH=screen.availHeight-50;
var testW=screen.availWidth-50;
setCookie('CAW',testW);
setCookie('CAH',testH);
var myTables=document.getElementById('obsah').getElementsByTagName('table');
var t=0;
//alert(myTables.length);
for(t;t<myTables.length;t++)
   {
	 if(myTables[t].className=='tablegen')getRowSet(myTables[t]);
	 }
return false;	 
}
function getRowSet(myTable)
{
myRows=myTable.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
myClass='';
//alert(myRows.length);
for(r=0;r<myRows.length;r++)
   {
   getTDset(myRows[r]);
	 myClass=(myClass=='lichy')?'sudy':'lichy';
	 myRows[r].className=myClass;
	
	 
	 }
return false;  
}
function getTDset(myRow)
{
myTDs=myRow.getElementsByTagName('td');
//alert(myTDs.length);
for(p=0;p<myTDs.length;p++)
   {
   window.status=p;
	 myTDs[p].style.backgroudColor='';
	 }
return false;
}
function goDict(ev,myid)
{
myNasept=document.getElementById('nasept');
if(!myNasept)
   {
	 myNasept=document.createElement('div');
	 myNasept.setAttribute('id','nasept');
	 document.getElementsByTagName('body')[0].appendChild(myNasept);
	 }
var oScript = document.createElement('script');
oScript.setAttribute('type','text/javascript');
oScript.setAttribute('src','/lbr/dict.php?DID='+myid);
document.getElementById('nasept').appendChild(oScript);
ShowY(ev);
return false;
}
 function ShowY(ev)
  {
  BoolNasept=true  
  ZrusNasept();
  mydiv=document.getElementById('nasept')
    if(!window.addEventListener)
       {
       el=event.srcElement
       //if(el.tagName!='SUP' && el.tagName!='IMG')return false
               
       myy=event.clientY+document.documentElement.scrollTop;
       myx=event.clientX;
       mydiv.attachEvent("onmouseover", ukazNasept);
       mydiv.attachEvent("onmouseout", hideNasept);
       el.attachEvent("onmouseout", hideNasept);
       }
       else
       {
       mydiv.addEventListener("mouseover", ukazNasept, false);
       mydiv.addEventListener("mouseout", hideNasept, false);
       el=ev.target;
       //if(el.tagName!='SUP' && el.tagName!='IMG')return false;
       el.addEventListener("mouseout", hideNasept, false);
       myy=ev.pageY;
       myx=ev.pageX;
       }
       
       
       myx=myx+10;
       if(el.tagName=='IMG')
       {
       hval=parseInt(mydiv.style.height);
       wval=parseInt(mydiv.style.width);
       myy=myy-Math.round(hval/2);
       if(myx>660)myx=parseInt(myx-(wval-50));
       }
       mydiv.style.left=myx+'px';
       
       mydiv.style.top=myy+'px';
       mydiv.style.display='block';
       mydiv.style.zIndex='1000';
       return true;
  }
function hideNasept()
{
BoolNasept=false
}  
function ukazNasept()
  {
	BoolNasept=true
	}
function ZrusNasept()
{
 if(myInterval)
   {
	 window.clearTimeout(myInterval)
	 }
 if(!BoolNasept)
 {
 mydiv=document.getElementById('nasept')
 mydiv.style.display='none';
 return true
 }
 myInterval= window.setTimeout("ZrusNasept()",1000); // načasuje akci
return false; 
}
function setNasept(result)
{
document.getElementById('nasept').innerHTML=result;
return false;
}
function goThumbs(ev,myid)
{
myNasept=document.getElementById('nasept');
if(!myNasept)
   {
	 myNasept=document.createElement('div');
	 myNasept.setAttribute('id','nasept');
	 document.getElementsByTagName('body')[0].appendChild(myNasept);
	 }
myNasept.style.width='280px';
myNasept.style.height='250px';
var	path='/img_w.php?sz=250&ID='+myid
inner='<iframe src="'+path+'" id="frm1" style="width:280px;height:250px" frameborder="0" ></iframe>';
ShowY(ev);
setNasept(inner);
return false;
}
function DocLocation(loc)
{
document.location.href=loc;
}
function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? ";expires=01 Jan 2050 00:00:00 GMT" : ("; expires=" + expire.toGMTString()))
   + ";site="+ location.hostname+";path=/;";
  
}
