var mydiv,mhlpid;
var oScript;
var BoolNasept = false;
var myInterval;
var Pocitadlo=1
var AllTop;
var myNasept;
var myx,myy,el;
function setAkci(e,n)
{
myElement=e;
myid=e.value
path='/alff/lbr_tools/js_akce.php?ID='+myid+'&nname='+n;
var oScript = document.createElement('script');
  oScript.setAttribute('type','text/javascript');
  oScript.setAttribute('src',path);
  document.getElementsByTagName("BODY")[0].appendChild(oScript);
}
function goMe(el)
{

if (el.tagName!="TD" && el.tagName!="P")return;
mycol=el.getElementsByTagName('A');
if(mycol.length==0)return;
myUrl=mycol[0].getAttribute("href");
if(myUrl!='')window.location.href=myUrl;
}
function confirmSendOrd(el,kurz)
{
  //PR,KS
  ks=parseInt(document.getElementById('KS').value);
  //alert(ks);
  cn=parseFloat(document.getElementById('PR').value);
  rp=parseFloat(document.getElementById('RP').value);
  vysl=(ks*(cn+rp))/kurz;
  vysledek=(Math.round(vysl*100))/100;
  document.getElementById('toid').value=vysledek;
  if(ks>1)
    {
		dodatek='\nNa více než 1 položku zboží nelze získat úvěr';
		}
    else
    {
		dodatek='';
		}
  myF=confirm('Chci objednat - '+ ks +' ks zboží o celkové ceně ' +  vysledek + '!')
  if(!myF)return false;
  el.form.submit();
  return true;
}
function ReCountFl(pol,el,toid,kurz)
{
 pocet=parseInt(el.value)
 rp=parseInt(document.getElementById("RP").value);
 pr=parseFloat(document.getElementById("PR").value);
 ks=parseInt(document.getElementById("KS").value);
 //alert(cena);
 vysledek=((rp+pr)*ks)/kurz;
 vysledek=(Math.round(vysledek*100))/100;
 document.getElementById('toid').value=vysledek;  
}
function myConfirm(zprava)
{
var myStr="Vybral jste příkaz \n"+zprava+"!";
    myStr+="\n Mám pohračovat?"
    myVal= window.confirm(myStr)
    return myVal;
}
function GoOBR2(el)
{
myPATH= el.href
var testH=screen.availHeight-50;
var testW=screen.availWidth-50;
setCookie("CAW",testW);
//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 myM
}
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=/;";
  /*  var ckname= name + "=" +value 
   + ((expire == null) ? ";expires=01 Jan 2050 00:00:00 GMT;" : ("; expires=" + expire.toGMTString()))
   + "path=/;";
   document.cookie = escape(ckname);*/
}
function setHlist()
{
if(!document.getElementById('hlist'))
  {
  return false
  
  }
  else
  {
  var myH2=document.getElementsByTagName('H2')
  var 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.innerHTML=' zpět';
    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(){
if(!document.getElementById('obsah'))return false;
setHlist();
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 MakeWin(pth,w,h)
{
var myM=new Object(window.open(pth,"nahled","left=50,top=50,location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=1,height=" + h + ",width=" + w +",resizable=1,dependent=0"));
myM.focus();

return false;
}
function swD(ev,nr)
{
document.getElementById("myForm").style.display="block";
if(!window.addEventListener)
       {
       el=event.srcElement
       //if(el.tagName!='SUP' && el.tagName!='IMG')return false
               
       myy=document.documentElement.scrollTop;
       myx=event.clientX;
       
       }
       else
       {
       
       myy=document.documentElement.scrollTop
       myx=ev.pageX;
       }
 document.getElementById("myForm").style.top=myy+"px";      
}
