function stOP(ev)
{

if(!document.all)
 {
 ev.stopPropagation();
 obr=ev.target
 el=obr.parentNode.parentNode.getElementsByTagName('TD')[1];

 }
 else
 {
 event.cancelBubble=true;
 obr=event.srcElement;
 el=obr.parentElement.parentElement.getElementsByTagName('TD')[1];

 }
if(el.className=="open")
   {
   el.className="closed";
   el.getElementsByTagName("TABLE")[0].style.display="none";
   obr.src='/ico/tree/plus1.gif';
   return false;
   }
if(el.className=="closed")
   {
   el.className="open";
   el.getElementsByTagName("TABLE")[0].style.display="";
   obr.src='/ico/tree/minus1.gif';
   return false;
   }

}
function setSbal()
{
myDiv=document.getElementById("sbmenu")
if(!myDiv)return true;
var myLis=myDiv.getElementsByTagName('IMG');

for(i=0;i<myLis.length;i++)
 {
   
   obr=myLis[i];
   
   if(obr.className=='active')
   {
	 if (window.addEventListener)
	    {
	     obr.addEventListener("click", stOP, false); 
			     
	    }
	else
	    {
	    obr.attachEvent("onclick",stOP); 	    
	    }
	   
	 }
	 if(obr.className=='bactive')
   {
	 if (window.addEventListener)
	    {
	     obr.addEventListener("click", PstOP, false); 
			     
	    }
	else
	    {
	    obr.attachEvent("onclick",PstOP); 	    
	    }
	 }
 }
ho=document.getElementById('obsah').offsetHeight;
hl=document.getElementById('lmenu').offsetHeight;
h=hl>ho?hl:ho;

document.getElementById('lmenu').style.height=h+'px';

}
function PstOP(ev)
{
if(!document.all)
 {
 ev.stopPropagation();
 obr=ev.target
 el=obr.parentNode.parentNode.getElementsByTagName('TD')[1];

 }
 else
 {
 event.cancelBubble=true;
 obr=event.srcElement;
 el=obr.parentElement.parentElement.getElementsByTagName('TD')[1];

 }
if(el.className=="proopen")
   {
   el.className="proclosed";
   el.getElementsByTagName("TABLE")[0].style.display="none";
   obr.src='/ico/tree/plus2.gif';
   return false;
   }
if(el.className=="proclosed")
   {
   el.className="proopen";
   el.getElementsByTagName("TABLE")[0].style.display="";
   obr.src='/ico/tree/minus2.gif'
   return false;
   }

}
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;
}
function clickDiv(el)
{
 if(el.tagName!='DIV')return false;
 myA= el.getElementsByTagName('A') 
 if(myA.length<1)return false;
 myPth=myA[0].href;
 location.href=myPth;
}
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 myM
}
function OpenWin(el)
{
myPATH= el.href
//alert(myPATH)
//return false
self.name="togot";
feath="resizable=1,width=500,height=400,location=0,directories=0,toolbar=0,menubar=0,status=0,dependent=1,scrollbars=1"
myM=window.open(myPATH,"DETWIN",feath)
if(myM)myM.focus();
myM=!myM
return myM
}
function svTM(el,nr)
{
 if(nr==1)
  {
   el.className='tablemenuA';
   
  }
else
  {
   el.className='tablemenu';
   
  }
 
}
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();
  
}

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;
      }
  
  }
}
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('Skutečně chcete smazat 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';
}
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="";
  }
 
}
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 prosím!')
  return false;
  }
mytelo=document.getElementById('telo').value
  if(mytelo=='')
  {
  alert('Něco napiš než to pošleš')
  return false;
  }
frm.submit();
}
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='';
  }
}
function myConfirm(zprava)
{
var myStr="Vybral jste příkaz "+zprava+"!";
    myStr+="\n Mám pokračovat?"
    myVal= window.confirm(myStr)
    return myVal;
}
function goNasept(ev,myid)
{
var oScript = document.createElement('script');
oScript.setAttribute('type','text/javascript');
oScript.setAttribute('src','my_lbr/desc_add.php?DID='+myid);
document.getElementById('nasept').appendChild(oScript);
ShowY(ev);
}

  function ShowY(ev)
  {
    
    if(!window.addEventListener)
       {
       el=event.srcElement
       if(el.tagName!='SPAN')return false
       myy=event.clientY
       myx=event.clientX
       }
       else
       {
       el=ev.target
       if(el.tagName!='SPAN')return false
       myy=ev.pageY
       myx=ev.pageX
       }
       
       
       myx=myx+30;
       myy=myy-100;
       if(myx<0)myx=10
       mydiv=document.getElementById('nasept')
       mydiv.style.left=myx+'px';
       mydiv.style.top=myy+'px';
       mydiv.style.display='block';
  }
function hideNasept()
{
 mydiv=document.getElementById('nasept')
 mydiv.style.display='none';
}
function setNasept(result)
{
document.getElementById('nst').innerHTML=result;
}
function SortTable()
{
setSbal();
//setOkr();
el=document.getElementById('propopis');
if(!el)return;
myTrs=el.getElementsByTagName('TR');
cn='sudy';
for(i=0;i<myTrs.length;i++)
  {
	  cn=(cn!='lichy')?'lichy':'sudy';
	  myTrs[i].className=cn;
	}

}
function setOkr()
   {
   
   
    if(!document.all)
    {
    bW=document.width;
    bH=document.body.offsetHeight;
    }
    else
    {
    bW=document.body.offsetWidth;
    bH=document.body.offsetHeight;
    }
    if(bW<800)bW=600;
   
    //document.getElementById('pravy').style.left=(bW-205)+'px';
    document.getElementById('obsah').style.width=(bW-450)+'px';
    document.getElementById('pravy').style.left=(bW-230)+'px';
    document.getElementById('topRight').style.left=(bW-390)+'px';
  /* grps= document.getElementById('obsah').getElementsByTagName('COLGROUP');
   for(i=0;i<grps.length;i++)
       {
			 grps[i].style.width=((bW-210))/2+'px';
			 }*/
    window.onresize=setOkr;
}
