
//	written	by Tan Ling	Wee	on 2 Dec 2001
//	last updated 10 Apr 2002
//	email :	fuushikaden@yahoo.com
	var noveOknoCesta="/admin/js/kalendar/kalendarokno.html"
	var	fixedX = -1 // x position (-1 if to appear below control)
	var	fixedY = -1 // y position (-1 if to appear below control)
	var onClk=""
	var posunX=0
	var posunY=0
	var startAt = 1 // 0 - sunday ; 1 - monday
	var showWeekNumber = 0	// 0 - don't show; 1 - show
	var showToday = 1		// 0 - don't show; 1 - show
	var pevnaVyskaTabulky = 1		// 1 - vzdy 6 radek
	var sirSloupce=16	//14 minimalne
	var imgDir = "/gfx/kalendar/"	// directory for images ... e.g. var imgDir="/img/"
	var stdFormat="d.m.yyyy"	
	var gotoString = "Aktuální měsíc"
	var todayString = "" // "Dnes je"
	var weekString = "Týden"
	var scrollLeftMessage = "Předešlý měsíc. Držení tlačítka myši roluje automaticky."
	var scrollRightMessage ="Následující měsíc. Držení tlačítka myši roluje automaticky."
	var selectMonthMessage = "Vyber měsíc."
	var selectYearMessage = "Vyber rok."
	var selectDateMessage = "Vyber [date] ve tvaru data." // do not replace [date], it will be replaced by date.
	var closeTxt="Zavři kalendář"
	var	crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear

	var	bPageLoaded=false
	if (!newWindow){var	newWindow=false}
	var	ie=document.all
	var	dom=document.getElementById

	var	ns4=document.layers
	var	today =	new	Date()
	var	dateNow	 = today.getDate()
	var	monthNow = today.getMonth()
	var	yearNow	 = today.getYear()
	var	imgsrc = new Array("drop1.gif","drop2.gif","left1.gif","left2.gif","right1.gif","right2.gif")
	var	img	= new Array()
	
	var bShow = false;

	var HolidaysCounter = 0
	var Holidays = new Array()
	var skrytSelect=null
	var SkrytRet=""
	var winHeight=160
	var winWidth=(showWeekNumber==1)?239:194
	addHoliday(24,12,0, "Štědrý den")
	addHoliday(25,12,0, "1. svátek vánoční")
	addHoliday(26,12,0, "2. svátek vánoční")
	addHoliday(1,1,0, "Nový rok, Den obnovy samostatného českého státu")
	addHoliday(12,3,0, "Vstup ČR do NATO",1)
	addHoliday(21,4,2003, "Pondělí velikonoční")
	addHoliday(1,5,0, "Svátek práce")
	addHoliday(5,5,0, "Květnové povstání českého lidu",1)
	addHoliday(8,5,0, "Den osvobození")
	addHoliday(5,6,0, "Cyrila a Metoděje")
	addHoliday(6,6,0, "Upálení mistra Jana Husa")
	addHoliday(28,9,0, "Den české státnosti")
	addHoliday(28,10,0, "Den vzniku samostatného československého státu")
	addHoliday(17,11,0, "Den boje za svobodu a demokracii")

	function HolidayRec (d, m, y, desc,typ)
	{
		this.d = d
		this.m = m
		this.y = y
		this.desc = desc
		this.typ = typ
	}

	function addHoliday (d, m, y, desc,typ)
	{
		Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc,typ )
	}


	if (dom)
	{/*
		for	(i=0;i<imgsrc.length;i++)
		{
			img[i] = new Image
			img[i].src= imgDir + imgsrc[i]
		}*/
		
		

					 
					 
					 
		document.write ("<div onclick='bShow=true' id='calendar' class='div-style' >")
						document.write ("<table cellpadding='0' cellspacing='0' border='0' style='background-color:#F6F6F6;margin-bottom:5px;'>")
						document.write ("<tr><td><img src='../system/image_tables.php?img=corner_tl_gif' border='0' height='5' width='5' /></td>")
						document.write ("<td><img src='../system/image_tables.php?img=bar_t_gif' border='0' height='5' width='100%' /></td>")
						document.write ("<td><img src='../system/image_tables.php?img=corner_tr_gif' border='0' height='5' width='5' /></td>")
						document.write ("</tr><tr>")
						document.write ("<td width='5' height='100%'><img src='../system/image_tables.php?img=bar_l_gif' border='0' height='100%' width='5' /></td>")
						document.write ("<td>")
						document.write ("<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>")
						document.write ("<tr><td valign=top>")

		
		document.write ("<table class='table-style'  cellspacing=1 cellpadding=0 border=0><tr class='title-background-style' ><td><table   align=center ><tr><td class='title-style'><B><span id='caption'></span></B></td></tr></table></td>")
		// stin
		//document.write ("<td rowspan='"+(2+showToday)+"' class=bg><img src='/pic/blank.gif'  width=8></td>")
		document.write ("</tr><tr><td class='body-style'><span id='content'></span></td></tr>")
			
		if (showToday==1)
		{
			document.write ("<tr class='today-style'><td align=center class='today-style'><table cellspacing=0 cellpadding=0 border=0 class='today-style' width=100%><tr><td  class='today-style'  align=center><span id='lblToday'></span></td>")
			if (!newWindow){
			document.write ("<td align=center valign=middle width=16><a href='javascript:hideCalendar()'>&nbsp;X&nbsp;</a></td>")}
			document.write 	("</tr></table></td></tr>")
		}
			//stin
			//document.write ("<tr><td class=bg><img src='/pic/blank.gif'  height=6></td><td class=bg></td></tr>")
		document.write ("</table>")
		
						document.write ("</td></tr>")
						document.write ("</table></td>")
						document.write ("<td width='5' height='100%'><img src='../system/image_tables.php?img=bar_r_gif' border='0' height='100%' width='5' /></td>")
						document.write ("</tr><tr>")
						document.write ("<td><img src='../system/image_tables.php?img=corner_bl_gif' border='0' height='5' width='5' /></td>")
						document.write ("<td><img src='../system/image_tables.php?img=bar_b_gif' border='0' height='5' width='100%' /></td>")
						document.write ("<td><img src='../system/image_tables.php?img=corner_br_gif' border='0' height='5' width='5' /></td>")
						document.write ("</tr></table>")
		
		document.write ("</div><div id='selectMonth' class='div-style'></div><div id='selectYear' class='div-style'></div>");
		



	}

	var	monthName =	new	Array("Leden","Únor","Březen","Duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec")
	var	monthNameCZ =	new	Array("ledna","února","březena","dubna","května","června","července","srpna","září","října","listopadu","prosince")
	if (startAt==0)
	{
		dayName = new Array	("Ne","Po","Út","St","Čt","Pá","So")
		dayNameCZ = new Array	("Neděle","Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota")
	}
	else
	{
		dayName = new Array	("Po","Út","St","Čt","Pá","So","Ne")
		dayNameCZ = new Array	("Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota","Neděle")
	}

	function swapImage(srcImg, destImg){
		if (ie)	{ document.getElementById(srcImg).setAttribute("src",imgDir + destImg) }
	}

	function init()	{ //alert("tady")
		if (!ns4)
		{
			if (!ie) { yearNow += 1900	}

			crossobj=(dom)?document.getElementById("calendar").style : ie? document.all.calendar : document.calendar
			hideCalendar()

			crossMonthObj=(dom)?document.getElementById("selectMonth").style : ie? document.all.selectMonth	: document.selectMonth

			crossYearObj=(dom)?document.getElementById("selectYear").style : ie? document.all.selectYear : document.selectYear

			monthConstructed=false;
			yearConstructed=false;

			if (showToday==1)
			{
				//document.getElementById("lblToday").innerHTML =	todayString + " <a class='today-style' onmousemove='window.status=\""+gotoString+"\"' onmouseout='window.status=\"\"' title='"+gotoString+"' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>"+dayName[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+", " + dateNow + " " + monthName[monthNow].substring(0,3)	+ "	" +	yearNow	+ "</a>"
				// nový text dole
				document.getElementById("lblToday").innerHTML =	todayString + " <a class='today-style' onmousemove='window.status=\""+gotoString+"\"' onmouseout='window.status=\"\"' title='"+gotoString+"' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>"+dayNameCZ[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+", " + dateNow + ". " + monthNameCZ[monthNow]	+ "	" +	yearNow	+ "</a>"
			}

			/*sHTML1= "<span id='spanLeft'  class='title-control-normal-style' onmouseover='swapImage(\"changeLeft\",\"left2.gif\");this.className=\"title-control-select-style\";window.status=\""+scrollLeftMessage+"\"' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);swapImage(\"changeLeft\",\"left1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartDecMonth()\",500)'	onmouseup='constructCalendar();clearTimeout(timeoutID1);clearInterval(intervalID1)'><IMG id='changeLeft' SRC='"+imgDir+"left1.gif' width=10 height=11 BORDER=0 hspace=2></span>"*/
			sHTML1= "<span id='spanLeft'  class='title-control-normal-style' onmouseover=';this.className=\"title-control-select-style\";window.status=\""+scrollLeftMessage+"\"' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);this.className=\"title-control-normal-style\";window.status=\"\"' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartDecMonth()\",500)'	onmouseup='constructCalendar();clearTimeout(timeoutID1);clearInterval(intervalID1)'> << </span>"
			
			sHTML1+="<span id='spanMonth' class='title-select' onmouseover='window.status=\""+selectMonthMessage+"\"' onmouseout='window.status=\"\"' xonclick='popUpMonth()'></span>"

			/*sHTML1+="<span id='spanRight' class='title-control-normal-style' onmouseover='swapImage(\"changeRight\",\"right2.gif\");this.className=\"title-control-select-style\";window.status=\""+scrollRightMessage+"\"' onmouseout='clearInterval(intervalID1);swapImage(\"changeRight\",\"right1.gif\");this.className=\"title-control-normal-style\";window.status=\"\"' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartIncMonth()\",500)'	onmouseup='constructCalendar();clearTimeout(timeoutID1);clearInterval(intervalID1)'><IMG id='changeRight' SRC='"+imgDir+"right1.gif'	width=10 height=11 BORDER=0 hspace=2></span>"*/

			sHTML1+="<span id='spanRight' class='title-control-normal-style' onmouseover='this.className=\"title-control-select-style\";window.status=\""+scrollRightMessage+"\"' onmouseout='clearInterval(intervalID1);this.className=\"title-control-normal-style\";window.status=\"\"' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartIncMonth()\",500)'	onmouseup='constructCalendar();clearTimeout(timeoutID1);clearInterval(intervalID1)'>&nbsp;>> </span>"

			sHTML1+="<span id='spanYear'  class='title-select' onmouseover='window.status=\""+selectYearMessage+"\"'	onmouseout='window.status=\"\"'	xonclick='popUpYear()'></span>"
			
			document.getElementById("caption").innerHTML  =	sHTML1

			bPageLoaded=true
				//alert(newWindow+"uuu")
					
			if (newWindow){popUpCalendar(datumPole, stdFormat ,0,0,"")} 
		}
	}

	function hideCalendar()	{
		crossobj.visibility="hidden"
		//if (document.all.calendar){alert(document.all.calendar.clientHeight+"*"+document.all.calendar.clientWidth)}

		if (crossMonthObj != null){crossMonthObj.visibility="hidden"}
		if (crossYearObj !=	null){crossYearObj.visibility="hidden"}
	
		if (ie&&skrytSelect){
			for (var i=0;i<skrytSelect.length ;i++ ){ if (eval ("document.all."+ skrytSelect[i])){	eval ("document.all."+ skrytSelect[i]+".style.visibility='visible'")}}}
			
	}

	function padZero(num) {
		return (num	< 10)? '0' + num : num ;
	}

	function constructDate(d,m,y)
	{
		sTmp = dateFormat
		sTmp = sTmp.replace	("dd","<e>")
		sTmp = sTmp.replace	("d","<d>")
		sTmp = sTmp.replace	("<e>",padZero(d))
		sTmp = sTmp.replace	("<d>",d)
		sTmp = sTmp.replace	("mmm","<o>")
		sTmp = sTmp.replace	("mm","<n>")
		sTmp = sTmp.replace	("m","<m>")
		sTmp = sTmp.replace	("<m>",m+1)
		sTmp = sTmp.replace	("<n>",padZero(m+1))
		sTmp = sTmp.replace	("<o>",monthName[m])
		sTmp= sTmp.replace ("yyyy",y)
		var pom=y % 100
			pom="00"+pom
			pom=pom.substr(pom.length-2)
		return sTmp.replace ("yy",pom)
	}

	function closeCalendar() {
		var	sTmp

		hideCalendar();
		ctlToPlaceValue.value =	constructDate(dateSelected,monthSelected,yearSelected)
		if (onClk>"" )	{eval(onClk)}
		if (newWindow){bPageLoaded=false
			window.close()}
	}

	/*** Month Pulldown	***/

	function StartDecMonth()
	{ 
		intervalID1=setInterval("decMonth()",80)
	}

	function StartIncMonth()
	{
		intervalID1=setInterval("incMonth()",80)
	}

	function incMonth () {
		//alert(monthSelected)
		monthSelected++
		if (monthSelected>11) {
			monthSelected=0
			yearSelected++
		}
		constructCalendar()
	}

	function decMonth () {
		//alert(monthSelected)
		monthSelected--
		if (monthSelected<0) {
			monthSelected=11
			yearSelected--
		}
		constructCalendar()
	}


	
	/*** calendar ***/

	function WeekNbr(today)
    {
		Year = takeYear(today);
		Month = today.getMonth();
		Day = today.getDate();
		now = Date.UTC(Year,Month,Day+1,0,0,0);
		var Firstday = new Date();
		Firstday.setYear(Year);
		Firstday.setMonth(0);
		Firstday.setDate(1);
		then = Date.UTC(Year,0,1,0,0,0);
		var Compensation = Firstday.getDay();
		if (Compensation > 3) Compensation -= 4;
		else Compensation += 3;
		NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
		return NumberOfWeek;
	}

	function takeYear(theDate)
	{
		x = theDate.getYear();
		var y = x % 100;
		y += (y < 38) ? 2000 : 1900;
		return y;
	}

	function constructCalendar () {
		var dateMessage
		var	startDate =	new	Date (yearSelected,monthSelected,1)
		var	endDate	= new Date (yearSelected,monthSelected+1,1);
		var typd
		endDate	= new Date (endDate	- (24*60*60*1000));
		numDaysInMonth = endDate.getDate()

		datePointer	= 0
		dayPointer = startDate.getDay() - startAt
		
		if (dayPointer<0)
		{
			dayPointer = 6
		}

		sHTML =	"<table	border=0 cellspacing=0 cellpadding=1 class='body-style' align=center><tr  >"

		for	(i=0; i<7; i++)	{
			sHTML += "<td width='"+sirSloupce+"' align='right' class='body-style' ><B>"+ dayName[i]+"</B></td>"
		}
		sHTML +="</tr><tr  >"
	
		if (showWeekNumber==1)
		{
			sHTML += "<td align=right class=weeknumber-div-style>" + WeekNbr(startDate) + "</td>"
		}
		var rad=1
		var sloupcu=0
		for	( var i=1; i<=dayPointer;i++ )
		{	sloupcu+=1
			sHTML += "<td class=normal-day-style>&nbsp;</td>"
		}
	
		for	( datePointer=1; datePointer<=numDaysInMonth; datePointer++ )
		{	sloupcu+=1
			dayPointer++;

			sHTML += "<td align=right class=normal-day-style>"

			var sStyle="normal-day-style"; //regular day

			if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow)) //today
			{ sStyle = "current-day-style"; } 
			else if	(dayPointer % 7 == (startAt * -1) +1) //end-of-the-week day
			{ sStyle = "end-of-weekday-style"; }

			//selected day
			if ((datePointer==odateSelected) &&	(monthSelected==omonthSelected)	&& (yearSelected==oyearSelected))
			{ sStyle += " selected-day-style"; }

			sHint = ""
			for (k=0;k<HolidaysCounter;k++)
			{
				if ((parseInt(Holidays[k].d)==datePointer)&&(parseInt(Holidays[k].m)==(monthSelected+1)))
				{
					if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelected)&&(parseInt(Holidays[k].y)!=0)))
					{if(Holidays[k].typ){typd=Holidays[k].typ} else typd=""
						sStyle += " holiday-style"+typd;
						sHint+=sHint==""?Holidays[k].desc:"\n"+Holidays[k].desc
					}
				}
			}

			var regexp= /\"/g
			sHint=sHint.replace(regexp,"&quot;")

			dateMessage = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointer,monthSelected,yearSelected))+"\"' onmouseout='window.status=\"\"' "

			sHTML += "<a class='"+sStyle+"' "+dateMessage+" title=\"" + sHint + "\" href='javascript:dateSelected="+datePointer+";closeCalendar();'>" + datePointer + "</a>"

			sHTML += ""
			if ((dayPointer+startAt) % 7 == startAt) { if(datePointer<numDaysInMonth){rad=rad+1; sloupcu=0;sHTML += "</tr><tr >"}
				 
				if ((showWeekNumber==1)&&(datePointer<numDaysInMonth))
				{
					sHTML += "<td align=right class=weeknumber-div-style>" + (WeekNbr(new Date(yearSelected,monthSelected,datePointer+1))) + "</td>"
				}
			}
		}
		var slp=(showWeekNumber ==1)?9:8;
		if (sloupcu!=7)	{for (var i=sloupcu;i<7 ;i++ ){	sHTML += "<td class=normal-day-style>&nbsp;</td>"	}	
		sHTML += "</tr>"
		}
		if (pevnaVyskaTabulky==1&&rad==5)	{
			
			sHTML+='<tr><td colspan='+slp+' class=normal-day-style>&nbsp;</td></tr>'}
		if (!(showToday||newWindow))	{sHTML+="<tr><td align=right colspan="+slp+" class=normal-day-style><a href='javascript:hideCalendar()'>&nbsp;X&nbsp;</a></td></tr>"		}
		document.getElementById("content").innerHTML   = sHTML
			//alert(sHTML)
		constructMonth(monthSelected)
		
		constructYear(yearSelected)
	}


	

function constructMonth(n)
{
	var HTML=""
	HTML+='<select class=title-select onchange="monthSelected=parseInt(this.value, 10);constructCalendar() " >'
	for (var i=0;i<12 ;i++ )
				{ HTML+="<option  value='"+i+"' "
				if (i==n){HTML+=" selected "}
				HTML+=">"+monthName[i] 
			}
	HTML+='</select>'
	//alert(HTML)
	document.getElementById("spanMonth").innerHTML = HTML
}

	function constructYear(n)
	{	var HTML=""
		HTML+= "<select name=rok class='title-select'  onchange='yearSelected=parseInt(this.value, 10);constructCalendar()' >"
		for (var i=n-5;i<n+5 ;i++ )
			{ HTML+="<option value='"+i+"'"
			if (i==n){HTML+=" selected "}
			HTML+=">"+i 
		}
			HTML+="</select>"
		document.getElementById("spanYear").innerHTML = HTML
	}



	function popUpCalendar(ctl2, format,x,y,skryt) {

		skrytRet=skryt
		posunX=x
		posunY=y
		var	leftpos=0
		var	toppos=0
			var fformatChar
			//alert( bPageLoaded+"uuu")
		if (bPageLoaded)
		{ 
			if ( crossobj.visibility ==	"hidden" ) {
				ctlToPlaceValue	= ctl2
				dateFormat=format;

				if (MySearch(dateFormat," ")>=0) {formatChar = " "}
				if (MySearch(dateFormat,"/")>=0) {formatChar = "/"}
				if (MySearch(dateFormat,"-")>=0) {formatChar = "-"}
				if (MySearch(dateFormat,".")>=0) {formatChar = "."}
				aFormat	= dateFormat.split(formatChar)
				
				fformatChar=""
				if (MySearch(ctl2.value," ")>=0) {fformatChar = " "}
				if (MySearch(ctl2.value,"/")>=0) {fformatChar = "/"}
				if (MySearch(ctl2.value,"-")>=0) {fformatChar = "-"}
				if (MySearch(ctl2.value,".")>=0) {fformatChar = "."}
				if ( fformatChar	!= "" )
				{	
					// use user's date
					aData =	ctl2.value.split(formatChar)
					var pom=aData.length
					dateSelected = parseInt(aData[0], 10)
					if	(pom>1)	{monthSelected =	parseInt(aData[1], 10) - 1} else {monthSelected=monthNow}
					if (pom>2)	{yearSelected = parseInt(aData[2], 10)
						//alert (yearSelected+"*")
						if (yearSelected<100){
							yearSelected= yearSelected % 100;
							yearSelected += (yearSelected < 38) ? 2000 : 1900;} 
						//alert (yearSelected+"**")
					} else {yearSelected=yearNow}
						
				}
			//alert(tokensChanged)
				if (fformatChar=="")
				{
					dateSelected = dateNow
					monthSelected =	monthNow
					yearSelected = yearNow
				}
				//alert( dateSelected+" "+monthSelected+" "+yearSelected)
				odateSelected=dateSelected
				omonthSelected=monthSelected
				oyearSelected=yearSelected

				aTag = ctl2
				if (!newWindow){
				
					do {
						aTag = aTag.offsetParent;
						leftpos	+= aTag.offsetLeft;
						toppos += aTag.offsetTop;
					} while(aTag.tagName!="BODY");

					crossobj.left =	fixedX==-1 ? ctl2.offsetLeft	+ leftpos + posunX+2 :	fixedX
					crossobj.top = fixedY==-1 ?	ctl2.offsetTop +	toppos +posunY+ ctl2.offsetHeight +	2 :	fixedY
				}
				constructCalendar (1, monthSelected, yearSelected);
				// chyba exploreru, select box ignoruje z-index !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				if (ie&&skryt!=""&&!newWindow){
					skrytSelect=skryt.split(";")
					var pom= skrytSelect.length
					for (var i=0;i<pom ;i++ ){if (eval ("document.all."+ skrytSelect[i])){	eval ("document.all."+ skrytSelect[i]+".style.visibility='hidden'")}}
				}
				crossobj.visibility=(dom||ie)? "visible" : "show"
				//alert(crossobj.visibility+"fff")
	
				bShow = true;
			}
		}
		else
		{
			init()

		}
	}
	document.onkeypress = function hidecal1 () { 
		if (event.keyCode==27) 
		{
			hideCalendar()
		}
	}
	document.onclick = function hidecal2 () { 	
		//alert(bShow+" "+bPageLoaded)
		if (!bShow&&bPageLoaded)
		{
			hideCalendar()
		}
		bShow = false
	}

	//window.onload=init()

function MySearch(s,s1){
   var r, re;                   //Declare variables.
   re = eval('/'+s1+'/i');            //Create regular expression pattern.
   r = s.search(re);            //Search the string.
   return(r);                   //Return the Boolean result.
}

function showPopUpCalendar(ctl2, format,x,y,skryt,nW,onC)
{	//alert("***")
	var shovej=false
	onClk=onC
	if (crossobj){
		//alert(crossObj.visibility)
		if (crossobj.visibility!="hidden"){shovej=true	}	}
	if (shovej) {
		hideCalendar()} else{
			
			if (nW){
							var l,t
							var aTag = ctl2
							var	leftpos=0
							var	toppos=0
							if (window.dialogLeft){	leftpos=parseInt(window.dialogLeft)+20
								toppos=parseInt(window.dialogTop)+4}
							else{// alert (window.screenLeft)
								leftpos=parseInt(window.screenLeft)+3
								toppos=parseInt(window.screenTop)}
						
							do {
								aTag = aTag.offsetParent;
								leftpos	+= aTag.offsetLeft;
								toppos += aTag.offsetTop;
							} while(aTag.tagName!="BODY");

							l =	fixedX==-1 ? ctl2.offsetLeft	+ leftpos + posunX :	fixedX
							t = fixedY==-1 ?	ctl2.offsetTop +	toppos +posunY+ ctl2.offsetHeight +	2 :	fixedY

			nWindow = window.open(noveOknoCesta+"?n="+ctl2.form.name+ctl2.name,'Kalendář','height='+winHeight+',width='+winWidth+',top='+t+',left='+l+',toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=no')
				nWindow.focus()
		}
		else {
			if (!bPageLoaded){init()	}
			popUpCalendar(ctl2, format,x,y,skryt)}
	}
}