//<script>
var shwInfo
var objTarget=false
/*
*/
amsgs=new Array();
amsgs[0]='tento termín již není možné objednat';
amsgs[1]='Tento termín je již obsazen!';
amsgs[2]="Tento termín je již obsazen!\n\nPřejete si zařadit mezi náhradníky?";
amsgs[3]="Vybrané e-maily byly vloženy do schránky,\npoužít je můžete pomocí CTRL+V\n\nPro hromadné e-maily používejte POUZE ve skrytou kopiji!!!";
amsgs[4]="Vzhledem k velkému množství vybraných e-mailu je nutné rozdělit zprávu do [POCET] e-mailů!";
amsgs[5]="Vyberte osoby!";
amsgs[6]="Pro rezervaci je nutné povolení provozovatele!\nPřejete si zažádat o přístup?";

ttl=new Array();
function HandleMove(e) 
	{
	
	xprop=(document.all?window.event.clientX:e.pageX)
	yprop=(document.all?window.event.clientY:e.pageY)
	
	stl=document.getElementById('detail')
	stl.style.top=yprop+10
	stl.style.left=xprop+5
	}

function hilite(e)
	{
	evnt=(window.event?window.event:e)
	if (!evnt) {return}
	curobj=(document.all?evnt.srcElement:evnt.target)
	
	if (  curobj.tagName=="TD"  ) 
		{
		pos=curobj.id.split("_");
		if (   evnt.type=="mouseover" && ttl[curobj.id] ) 
			{
			document.getElementById('detail').innerHTML="<strong>"+ttl[curobj.id][0]+"</strong><br>"+ttl[curobj.id][1]+"<br>"+ttl[curobj.id][2]
			shwInfo=setTimeout("document.getElementById('detail').style.display='block'",300)
			curobj.parentNode.childNodes.item(1).style.backgroundColor="#aed7ff"
			document.getElementById('cl'+pos[1]).style.backgroundColor="#aed7ff"
			document.getElementById('ql'+(Math.floor(Number(pos[1])/partnr)*partnr)).style.backgroundColor="#aed7ff"
			curobj.style.backgroundColor="#ffcc99"
			};
		if (   evnt.type=="mouseout" ) 
			{
			clearTimeout(shwInfo)
			document.getElementById('detail').style.display="none"
			document.getElementById('cl'+pos[1]).style.backgroundColor=""
			document.getElementById('ql'+(Math.floor(Number(pos[1])/partnr)*partnr)).style.backgroundColor=""
			curobj.parentNode.childNodes.item(1).style.backgroundColor=""
			curobj.style.backgroundColor=""
			};
		if (   evnt.type=="click" ) 
			{
			if (  !objTarget  ) 
				{
				if (  curobj.disabled ) 
					{alert(amsgs[0])}
				else if (  ttl[curobj.id][4] ) 
					{if (confirm(amsgs[6])){self.location.href="?askentry=1&tid="+curobj.id+"&obj="+objid+"&NEW_datum_OD="+cur_datum_OD}}
				else if (  Number(curobj.innerHTML)> 0 ) 
					{self.location.href="?tid="+curobj.id+"&obj="+objid+"&NEW_datum_OD="+cur_datum_OD}
				else if (  ttl[curobj.id][3]> 0 ) 
					{alert(amsgs[1])}
				else
					{
					if (confirm(amsgs[2]))
						{
						gourl="nahradnik.php?nahr=1&tid="+curobj.id+"&obj="+objid+"&NEW_datum_OD="+cur_datum_OD;
						//gourl=prompt('url',gourl)
						self.location.href=gourl
						}
					}
				}
			else
				{
				self.location.href=objTarget+"?trm="+curobj.id
				};
			};
		};
	}

function MENUover(e)
	{
	evnt=(window.event?window.event:e)
	if (!evnt) {return}
	curobj=(document.all?evnt.srcElement:evnt.target)
	
	if (  curobj.tagName=="A"  ) 
		{
		if (   evnt.type=="mouseover" ) 
			{
			if (  !curobj.curcolor  ) {curobj.curcolor=curobj.style.borderColor};
			curobj.style.borderColor="#A5A5A5"
			curobj.style.backgroundColor="white"
			};
		if (   evnt.type=="mouseout" ) 
			{
			curobj.style.borderColor=( ( !curobj.curcolor ) ? ("#F2F2F2") : ( curobj.curcolor ) )
			curobj.style.backgroundColor=""
			curobj.curcolor=false
			};
		};
	}
function RWSover()
	{
	evnt=window.event
	curobj=evnt.srcElement
	if (  curobj.tagName=="TD"  ) 
		{
		if (   evnt.type=="mouseover" ) 
			{
			curobj.className="rwover"
			};
		if (   evnt.type=="mouseout" ) 
			{
			curobj.className=""
			};
		};
	}


function shwOkr(okrs)
	{
	if (  typeof tmpOkr == 'undefined'  ) {tmpOkr=false;};
	if (document.getElementById('kaj_'+tmpOkr)) {document.getElementById('kaj_'+tmpOkr).style.display='none'}
	tmpOkr=okrs
	if (document.getElementById('kaj_'+tmpOkr)) {document.getElementById('kaj_'+tmpOkr).style.display='block'}
	}

function selectAllChbx(srchfrm)
	{
	if (  !srchfrm  ) {srchfrm=window.event.srcElement};
	while (srchfrm.tagName!="FORM" && srchfrm.tagName!="BODY" && srchfrm.tagName!="HTML")
		{
		srchfrm=srchfrm.parentElement
		}
	if (  srchfrm.tagName!="FORM"  ) {return};
	allchecked=srchfrm.allchecked
	for (fi=0; fi<srchfrm.length ; fi++) 
		{
		if (  srchfrm[fi].type=="checkbox" && srchfrm[fi].name.indexOf('[') > 0 && !srchfrm[fi].disabled ) 
			{
			srchfrm[fi].checked=!allchecked;
			};
		};
	srchfrm.allchecked=!allchecked
	}

/////////fce pro ziskani indexu podle hodnoty/////////
function getIndexByVal(Sobj,Sval)
	{
	for (Si=0; Si<Sobj.length ; Si++) 
		{
		if ( Sobj.options[Si].value==Sval   ) 
			{
			return Si
			};
		};
	return false
	}


//s pouzitim on KeyPress nenecha zapsat jine hodnoty nez 0-9
function NumbOnly() 
	{ // 0-9
	if (((event.keyCode<48)||(event.keyCode>57))&&(event.keyCode!=13) ) {event.returnValue=false; }
	}
//s pouzitim on KeyPress nenecha zapsat jine hodnoty nez 0-9 A-Z a-z=>A-Z
function DICOnly() 
	{ // 0-9
	if ((event.keyCode>=97)&&(event.keyCode<=122)) {event.keyCode=event.keyCode-32};
	if (!(((event.keyCode>=48)&&(event.keyCode<=57))||(event.keyCode==13)||((event.keyCode>=64)&&(event.keyCode<=90))) ) {event.returnValue=false; }
	}
//s pouzitim on KeyPress nenecha zapsat jine hodnoty nez 0-9
function DateOnly() 
	{ // 0-9 . ' '
	if (((event.keyCode<48 && (event.keyCode!=46) && (event.keyCode!=32))||(event.keyCode>58))&&(event.keyCode!=13) ) {event.returnValue=false; }
	}

function PSCOnly() 
	{ // 0-9 +" "
	if (((event.keyCode<48)||(event.keyCode>57))&&(event.keyCode!=13)&&(event.keyCode!=32) ) {event.returnValue=false; }
	} 
 
//fce vyparsuje ze stringu pouze cisla
function stripNaNs(t)
	{
	r=''
	for (i=0; i<t.length ; i++) 
		{
		if (  !isNaN(t.charAt(i))  ) {r+=t.charAt(i);};
		};
	return r;
	}

//validace e-mailu
function checkEmail(mail) 
	{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))
		{
		return (true)
		}
	return (false)
	}

function goQuest(q,qurl)
	{
	if (confirm(q)) {document.location.href=qurl}
	}

function hidisp(obj)
	{
	if (document.getElementById(obj))
		{
		obj=document.getElementById(obj)
		obj.style.display=( ( obj.style.display=="none" ) ? ("") : ("none") )
		}
	}
	
//text do schranky
function ClipBoard(text) 
	{
	cop=document.getElementById('clip')
	cop.innerText = text;
	return cop.createTextRange().execCommand("Copy");
	}

//hromadna prace s maily
function xsndMails(clp)
	{
	frm=document.Uedit
	usemails=new Array()
	cntmails=new Array()
	for (i=0; i<frm.length ; i++) 
		{
		if ( frm[i].type=="checkbox" && frm[i].checked &&  frm[i].name.indexOf("dtlst[")==0 )
			{
			if (  !cntmails[allmails[frm[i].value]]  ) 
				{
				usemails[usemails.length]=allmails[frm[i].value];
				cntmails[allmails[frm[i].value]]=true;
				};
			}
		};
	if (usemails.length>0) 
		{
		if (  clp  ) {if (  ClipBoard(usemails.join("; "))  ) {alert(amsgs[3]);};return;};
		baseURL="mailto:?bcc="
		mailpart= new Array("")
		cur=0
		for (i=0; i<usemails.length ; i++) 
			{
			if ( mailpart[cur].length==0   ) {mailpart[cur]=usemails[i];}
			else 
				{
				if (  (mailpart[cur]+"; "+usemails[i]).length >= 2000  ) {cur++;mailpart[cur]=baseURL+usemails[i];}
				else {mailpart[cur]+="; "+usemails[i];}
				};
			};
		if (  mailpart.length>1  ) {alert(amsgs[4].split("[POCET]").join(mailpart.length))};
		for (i=0; i<mailpart.length ; i++) 
			{
			//alert(mailpart[i].substring (0,100))
			document.location.href=baseURL+mailpart[i]
			};
		
		}
	else {alert(amsgs[5])};
	}

//////////fce pro naplneni SELECT novymi hodnotami doplni / umaze celkovy pocet OPTIONS
function fillCombo(pole,combo)
	{
	if (  combo && pole  ) 
		{
		lng=combo.options.length
		if (  combo.options[0]  ) {combo.options[0].selected=1};
		for (i=0; (i<pole.length || i<lng) ; i++) 
			{
			if (  lng>i && pole[i]  ) {combo.options[i].value=(pole[i][0]?pole[i][0]:pole[i]);combo.options[i].text=(pole[i][1]?pole[i][1]:pole[i]);};
			if (  lng>i && !pole[i]  ) {combo.options[(combo.options.length-1)]=null; };
			if (  lng<=i && pole[i]  ) {combo.options[combo.options.length]=new Option((pole[i][1]?pole[i][1]:pole[i]),(pole[i][0]?pole[i][0]:pole[i]))};
			};
		}
	if (  combo && !pole  ) 
		{
		lng=combo.options.length
		for (i=1; i<lng ; i++) 
			{
			combo.options[(combo.options.length-1)]=null;
			}
		}
	}

window.onload = function() 
	{
	cOCJ=document.getElementById("KalendarBody")
	if (  cOCJ  ) 
		{
		ctmp= cOCJ.getElementsByTagName("TD") 
		//onmousemove="HandleMove()" onmouseover="hilite()" onclick="hilite()" onmouseout="hilite()"
		if (  cOCJ.addEventListener  ) 
			{
			for (ci=0; ci<ctmp.length ; ci++) 
				{
				ctmp[ci].addEventListener ('mousemove', HandleMove, false);
				ctmp[ci].addEventListener ('mouseover', hilite, false);
				ctmp[ci].addEventListener ('mouseout',  hilite, false);
				if (ctmp[ci].className.indexOf('active')==0)
					{
					ctmp[ci].addEventListener ('click',  ( ( typeof Localhilite == 'function') ? (Localhilite) : (hilite) ), false);
					}
				};
			}
		else
			{
			for (ci=0; ci<ctmp.length ; ci++) 
				{
				ctmp[ci].attachEvent ('onmousemove', HandleMove);
				ctmp[ci].attachEvent ('onmouseover', hilite);
				ctmp[ci].attachEvent ('onmouseout', hilite);
				if (ctmp[ci].className.indexOf('active')==0)
					{
					ctmp[ci].attachEvent ('onclick', ( ( typeof Localhilite == 'function') ? (Localhilite) : (hilite) ));
					};
				};
			};
		};
	};
