var activeColor="rgb(129, 140, 157)"; //pro pohyb myši "#dc143c"
var wi;
var wie;
var switchPath=location.protocol+'//'+location.hostname+"/"
var activeOWN=0;
var activeAdr=0;
var mainAMenu;
var oldClass='';
//------------------------------------------------------------------
function activTR(nr,el)
{
 if(nr==1)
   {
   oldClass=el.className;
	 el.className='actTr';
	 }
	 else
	 {
	 el.className=oldClass;
	 }
}
//------------------------------------------------------------------
function activeDiv(nr,el)
{
//el=event.srcElement
if (el.tagName!="DIV")
	{
	if (el.tagName=="A")
		{
		el=el.parentElement
		}
	else
		{
		if (el.tagName=="IMG")
			{
			el=el.parentElement.parentElement
			}
		else
			{
			return false;
			}
		}
	}
	if (!nr)
		{
		el.style.backgroundColor=activeColor
        el.style.cursor="pointer"
		//el.title=el.children[0].title
		}
	else
		{
		el.style.backgroundColor=""
         el.style.cursor="default"
		}
}
//------------------------------------------------------------
function activMe(nr,el)
{
//el=event.srcElement
if (el.tagName!="TD" && el.tagName!="P")
    {
	if (el.tagName=="A")
		{
		el=el.parentElement
		}
	else
		{
		if (el.tagName=="IMG")
			{
			el=el.parentElement.parentElement
			}
		else
			{
			return false;
			}
		}
	}

	if (nr)
		{
		//el.style.backgroundColor=activeColor
       // el.style.cursor="pointer"
		//el.title=el.children[0].title
		el.className="aabutton";
		}
	else
		{
		el.className="abutton";
		//el.style.backgroundColor=""
       //  el.style.cursor="default"
		}
	
}
function activP(nr,el)
{
//el=event.srcElement
if (el.tagName!="TD" && el.tagName!="P")
    {
	if (el.tagName=="A")
		{
		el=el.parentElement
		}
	else
		{
		if (el.tagName=="IMG")
			{
			el=el.parentElement.parentElement
			}
		else
			{
			return false;
			}
		}
	}
	if (nr)
		{
		el.className="PAbutton"
        el.style.cursor="pointer"
		//el.title=el.children[0].title
		}
	else
		{
        
		el.className="pbutton"
         el.style.cursor="default"
		}
	
}
function goDiv(el)
{
//el=event.srcElement
if (el.tagName=="DIV" && el.tagName!="A" )
    {
    myref=el.getElementsByTagName("A")[0].href
    window.location.href=myref;
    }
}
function goMe(el)
{
if ((el.tagName=="TD"||el.tagName=="P") && el.tagName!="A")
    {
    myref=el.getElementsByTagName("A")[0].href
    window.location.href=myref;
    }
}
function myPhone(myurl)
{
if(navigator.appName !="Microsoft Internet Explorer")
{
window.open(myurl,"w2","height=400,width=450,dependent=1,screenX=200,screenY=200,resizable=1");
return false;
}
window.showModalDialog(myurl,"","dialogWidth=400px")
/*ok=window.open(myurl,"wkalendar","location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=0,dependent=yes,width=400,height=150");*/
return false
}
function myPhone2(myid)
{
myurl="kontakts/compview.php?ID="+myid;
if(navigator.appName !="Microsoft Internet Explorer")
{
window.open(myurl,"Spolecnost","height=400,width=450,dependent=1,screenX=200,screenY=200,resizable=1");
return false;
}
window.showModalDialog(myurl,"","dialogWidth=400px")
/*ok=window.open(myurl,"wkalendar","location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=0,dependent=yes,width=400,height=150");*/
return
}

function visitka(myurl)
{
if(navigator.appName !="Microsoft Internet Explorer")
{
window.open(myurl,"Spolecnost","height=400,width=450,dependent=1,screenX=200,screenY=200,resizable=1");
return false;
}
var miE=window.showModalDialog(myurl,"","dialogWidth=400px")
/*ok=window.open(myurl,"wkalendar","location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=0,dependent=yes,width=400,height=150");*/
return miE
}

function helpme(hlpid)
{
if(document.location.hostname=="www.tzu.cz")
{
cesta=document.location.protocol+"//"+document.location.hostname+"/help/hlp.php?hlpid="+hlpid
}
else
{
cesta=document.location.protocol+"//"+document.location.hostname+"/tzu/help/hlp.php?hlpid="+hlpid
}
//cesta=path+hlpid
//alert(cesta)
//return;
var hlp=window.open(cesta,"help","location=0,directories=0,toolbar=0,menubar=0,status=1,scrollbars=1,height=600,width=800,resizable=1");
if(hlp)hlp.focus();
return false;
}

function startAlpha(el)
{
if (wi) window.clearInterval(wi)
wi=0
el.filters['alpha'].opacity=100
}

function mineAlpha()
{
if(wie.filters['alpha'].opacity<=30)
    {
    window.clearInterval(wi)
    wi=0;
    return true
    }
  wie.filters['alpha'].opacity=(wie.filters['alpha'].opacity-5) 
}

function endAlpha(el)
{
wie=el
wi=window.setInterval("mineAlpha()",1)
}

function myConfirm(typ)
{
if(!typ)typ='smazat';
var myStr="Vybral jste příkaz "+typ+"!";
    myStr+="\n Mám pokračovat?"
    myVal= window.confirm(myStr)
    return myVal;
}
function openChild(childPath)
{
var hlp=window.open(childPath,"help","location=0,directories=0,toolbar=0,menubar=0,status=1,scrollbars=1,height=500,width=400,resizable=1");
return false;
}
function myAlpha(el,nr)
{
if(navigator.appName !="Microsoft Internet Explorer")return
el.filters['alpha'].opacity=nr
}
function myPhone3(el)
{
if(el.tagName=="A")
    {
    myurl=el.getAttribute("href");
    }
else
    {
    return false
    }
if(navigator.appName !="Microsoft Internet Explorer")
{
window.open(myurl,"w2","height=300,width=500,dependent=1,screenX=200,screenY=200,resizable=1");
return false;
}
window.showModalDialog(myurl,"","dialogWidth=400px")
/*ok=window.open(myurl,"wkalendar","location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=0,dependent=yes,width=400,height=150");*/
return false
}
function SHMAP()
{
if(document.getElementById('mapawebu').style.display=='none')
{
document.getElementById('mapawebu').style.display='';
document.getElementById('promapu').className='stisknuto';
}
else
{
document.getElementById('mapawebu').style.display='none';
document.getElementById('promapu').className='abutton';;
}
}
var oldMapClass='';
function toMap(el,nr)
{
ClassArray=new Array()
if(nr==1)
    {
    oldMapClass=el.style.color
    el.style.color='#0000ff'
    }
    else
    {
     el.style.color=oldMapClass
    }
}
function delme(myurl)
{
if(myConfirm("smazat dokument"))
    {
        location.href=myurl
    }
}
function getImage(nr)
{
 myurl="http://www.tzu.cz/svet-textilu/image_view.php?ID="+nr
 mw=window.open(myurl,"Obrázek","location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=0,height=50,width=50,dependent=1,screenX=5,screenY=5,resizable=1");
 
 return !mw;
 
}

var reactNR
function reaktiv(nr)
{
var switchPath="http://"+location.hostname+"/"
var toPath=new Array('','index.php','redakce/index.php','redakce/gallery.php','admin/index.php','redakce/kurzy/index.php');
if(nr==reactNR)
{
  location.href=switchPath+toPath[nr]
 return false; 
}
reactNR=nr
myBody=document.getElementById('menubody');
myCollect=myBody.getElementsByTagName("TR");
for (i=0;i<myCollect.length;i++)
    {
    myCollect[i].className='trhidden';
    }
document.getElementById('menutr'+nr).className='trvisibled';
myBody=document.getElementById('forcel');
myCollect=myBody.getElementsByTagName("TD");
for (i=1;i<(myCollect.length-1);i++)
    {
    myCollect[i].className='neaktivni';
     }
myCollect[nr].className='superaktivni';
}
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"
   imgn='URL(/img/closed2.gif)';
	 el.style.listStyleImage=imgn;
   return;
   }
if(el.className=="closed")
   {
   el.className="open"
   imgn='URL(/img/opened.gif)';
	 el.style.listStyleImage=imgn;
   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 hidelevel(elid,myimg)
{
var myEl=document.getElementById(elid);
myHidden=myEl.style.display;
if(myHidden!='block')
  {
	  myEl.style.display="block";
	  myimg.src="/new_ico/file_add2.gif";
	}
  else
  {
		myEl.style.display="none";
		myimg.src="/new_ico/file_add1.gif";
	}
}
function revriteMail(el)
{
  mystr=el.href
 mystrA=mystr.split('(a)');
 el.href=mystrA[0]+'@'+mystrA[1];
 return true
 
}

////////////////////////
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();
}
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 MakeCU()
{
 pth='http://www.tzu.cz/redakce/colorutil.php';
 w=450
 h=500
 
 myM=window.open(pth,"barvy","left=50,top=50,location=0,directories=0,toolbar=0,menubar=0,status=0,scrollbars=1,height=" + h + ",width=" + w +",resizable=1,dependent=0");
 if(myM)myM.focus();
 myM=!myM
return myM
}
 function setC(s)
    {
    document.cookie="l2="+s.value+";expires=01 Jan 2050 00:00:00 GMT;"
    document.location.href="doku.php";
    }
function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      } 
   }
   
}
function checkAllul(el)
{
if(document.All)
  {
	mul=el.parentElement
	}
  else
  {
	mul=el.parentNode
	}
	if(mul.tagName!='LI')return false;
	myCol=mul.getElementsByTagName('INPUT');
	for(i=1;i<myCol.length;i++)
	  {
		myCol[i].checked=myCol[0].checked;
		}
}
function checkImageInA(imgName,nr,el)
{
 if(el.tagName!='A')return false
 myEl=el.getElementsByTagName('img');
 //alert(myEl.length)
 myEl[0].src= switchPath + 'new_ico/' + imgName + nr + '.gif';
 /*if(nr==2 && el.parentNode.tagName=='P')
   {
   el.parentNode.style.backgroundColor='rgb(76,76,76)';
   el.style.color='rgb(255,255,255)';
   }
   else
   {
   el.parentNode.style.backgroundColor='';
   el.style.color='rgb(0,0,0)';
   }*/
}
function ChImgTDin(e,tname)
{
if(document.all)
  {
	el=event.srcElement;
	}
	else
	{
	el=e.target;
	}
 if(!tname)tname='TD';
 
 if(el.tagName!=tname)el=getParentNode(el,tname);
 myEl=el.getElementsByTagName('img')[0];
 imgName=myEl.src
 imgNameLen=imgName.length-5;
 oldSrc=imgName.substr(0,imgNameLen);
 myEl.src=  oldSrc  + '2.gif';
}
function ChImgTDout(e,tname)
{
if(document.all)
  {
	el=event.srcElement;
	}
	else
	{
	el=e.target;
	}
 if(!tname)tname='TD';
  if(el.tagName!=tname)el=getParentNode(el,tname);
 myEl=el.getElementsByTagName('img')[0];
 imgName=myEl.src
 imgNameLen=imgName.length-5;
 oldSrc=imgName.substr(0,imgNameLen);
 myEl.src=  oldSrc  + '1.gif';
}
function checkImageInTd(nr,el)
{
 if(el.tagName!='TD')return false
 myEl=el.getElementsByTagName('img')[0];
 imgName=myEl.src
 imgNameLen=imgName.length-5;
 oldSrc=imgName.substr(0,imgNameLen);
 myEl.src=  oldSrc + nr + '.gif';
}
function MakeWin2(pth,w,h,mname)
{
if(mname=='')mname='nahledy'
 myM=window.open(pth,mname,"left=50,top=50,location=0,directories=0,toolbar=0,menubar=0,status=1,scrollbars=1,height=" + h + ",width=" + w +",resizable=1,dependent=0");
 if(myM)myM.focus();
 myM=!myM
return myM
}
function getExlink(tid)
{
  if(!document.getElementById('prolinkobl'))
  {
	myObj=document.createElement('div');
	myObj.setAttribute('id','prolinkobl');
	myDivDr=document.createElement('div');
	myDivDr.className='divdir';
	myImg=document.createElement('img');
	myImg.setAttribute('src','/svet-textilu/images/close.gif');
	myImg.setAttribute('height','18');
	myImg.setAttribute('width','18');
	myImg.setAttribute('align','right');
	myNode=document.createTextNode('výrobky');
	myDivPR=document.createElement('div');
	myDivPR.setAttribute('id','projs');
	myDivPR.style.position='relative';
	myDivPR.style.height='450px';
	myDivPR.style.overflow='auto';
	
	if (window.addEventListener)
    {
    myDivDr.addEventListener("click", HideProbl, false); 
    
    }
  else
    {
    myDivDr.attachEvent("onclick",HideProbl); 
   
    }
    myDivDr.appendChild(myImg);
    myDivDr.appendChild(myNode);
    myObj.appendChild(myDivDr);
    myObj.appendChild(myDivPR);
    document.getElementsByTagName('body')[0].appendChild(myObj);
	}
	else
	{
	myObj=document.getElementById('prolinkobl');
	}
  var oScript = document.createElement('script');
	oScript.setAttribute('type','text/javascript');
	oScript.setAttribute('src','/redakce/tools/js_obltool.php?ID='+tid);
	myObj.appendChild(oScript);
	if(document.all)
	{
	mycol=document.getElementsByTagName('select')
	for(i=0;i<mycol.length;i++)
	  {
		mycol[i].style.display='none';
		}
	 }
	myObj.style.display="block";
}
function HideProbl()
{
document.getElementById('prolinkobl').style.display='none';
if(document.all)
	{
mycol=document.getElementsByTagName('select')
	for(i=0;i<mycol.length;i++)
	  {
		mycol[i].style.display='';
		}
	 }
}
function clClass(el,nr)
{
if(el.className=='closed')
   {
	 imgn='URL(img/closed'+nr+'.gif)';
	 el.style.listStyleImage=imgn;
	 }
}
function getDict(e,nr)
 {
 mscript=document.createElement("script");
 mscript.setAttribute('src','/lbr/get_dict.php?ID='+nr);
 document.getElementsByTagName("body")[0].appendChild( mscript);
 if(!document.getElementById("prodict"))
   {
	 sdiv=document.createElement("DIV")
	 sdiv.setAttribute("ID","prodict")
	 document.getElementsByTagName("BODY")[0].appendChild(sdiv);
	 }
	 adiv=document.getElementById("prodict");
	 adiv.style.display="block";
   if(document.all)
  {
			e=window.event;
			el=event.srcElement;	
		  
		 	event.cancelBubble=true
		 	if (document.documentElement && document.documentElement.scrollTop) 
						{
						
						adiv.style.left  = (event.clientX + document.documentElement.scrollLeft);
						adiv.style.top = (event.clientY + document.documentElement.scrollTop)-75;
						
						}
						else if (document.body) // all other Explorers
						{
						
						adiv.style.left  = (event.clientX + document.body.scrollLeft);
						adiv.style.top= (event.clientY + document.body.scrollTop)-75;
						
						} 
			adiv.attachEvent("onclick",removeDict); 
			}
			else
			{
			el=e.target;
			e.stopPropagation();
			adiv.style.left = e.pageX+'px';
		  adiv.style.top  = (e.pageY-75)+'px';
			adiv.addEventListener("click", removeDict, false);
			}
 }
 function removeDict()
 {
  if(!document.getElementById("prodict"))return;
	adiv=document.getElementById("prodict");
  adiv.style.display="none";
 }
 function DocMenu(e,nr,own)
{
hidemAM();
mainAMenu= document.getElementById('DocMenu');
 activeOWN=own;
 activeAdr=nr;
 if(document.all)
  {
	e=window.event;
	el=event.srcElement;
	if (document.documentElement && document.documentElement.scrollTop) 
				{
				oldLeft=event.clientX + document.documentElement.scrollLeft;
				oldTop=event.clientY + document.documentElement.scrollTop;
				mainAMenu.style.left =oldLeft;
				mainAMenu.style.top = oldTop;
				
				}
				else if (document.body) // all other Explorers
				{
				oldLeft=event.clientX + document.body.scrollLeft;
				oldTop=event.clientY + document.body.scrollTop;
				mainAMenu.style.left  = oldLeft;
				mainAMenu.style.top=oldTop;
				
				} 
 
 	e.cancelBubble=true;
 	event.cancelBubble=true
  document.getElementsByTagName('body')[0].attachEvent("onclick", hidemAM);
	}
	else
	{
	el=e.target;
	
	e.stopPropagation();
	//oldLeft=(e.clientX+document.body.scrollLeft);
	//oldTop= (e.clientY+document.body.scrollTop );
	oldLeft=e.pageX	;
	oldTop=e.pageY;
	mainAMenu.style.left =oldLeft +'px';
  mainAMenu.style.top  =oldTop+'px';
  document.getElementsByTagName('body')[0].addEventListener("click", hidemAM, false);
	}
	oldClass=el;
	oldClass.style.backgroundColor='lightsteelblue';
 
  mainAMenu.style.display = 'block';
  return false;
}
function hidemAM()
{
if(!mainAMenu)return false;
mainAMenu.style.display = 'none';
oldClass.style.backgroundColor='';
} 
function AddSubAdr()
{
//http://www.tzu.cz/redakce/kat_add1.php?KAT_OWN=1&KAT_L=69&KAT_LINKED=69
document.location.href='/redakce/kat_add1.php?KAT_OWN='+activeOWN+'&KAT_L='+activeAdr+'&KAT_LINKED='+activeAdr;
}
function addDoc()
{
document.location.href='/redakce/text_form1.php?adr='+activeAdr+'&own='+activeOWN;
}
function EditAdr()
{
document.location.href='/redakce/kat_edit2.php?KAT_ID='+activeAdr+'&KAT_OWN='+activeOWN;
}
function GoDocs()
{
document.location.href='/redakce/doku.php?adr='+activeAdr;
}
