document.write('<iframe id=CalFrame name=CalFrame frameborder=0 src="calendar.htm" style=display:none;position:absolute;z-index:100></iframe>');
document.onclick=hideCalendar;
function showCalendar(sImg,bOpenBound,sFld1,sFld2,sCallback)
{window.document.body.onbeforeunload = null;
	var fld1,fld2;
	var cf=document.getElementById("CalFrame");
	var wcf=window.frames.CalFrame;
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("1");return;}
	if(!sFld1){alert("2");return;}
	fld1=document.getElementById(sFld1);
	if(!fld1){alert("3");return;}
	if(fld1.tagName!="INPUT"){alert("4");return;}
	if(sFld2)
	{
		fld2=document.getElementById(sFld2);
		if(!fld2){alert("5");return;}
		if(fld2.tagName!="INPUT"||fld2.type!="text"){alert("6");return;}
	}
	if(!wcf.bCalLoaded){alert("7ŁĄ");return;}
	if(cf.style.display=="block"){cf.style.display="none";return;}
	
	var eT=0,eL=0,p=oImg;
	var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	var eH=oImg.height,eW=oImg.width;
	while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
	cf.style.top=(document.body.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height;
	cf.style.left=(document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width;
	cf.style.display="block";
	
	wcf.openbound=bOpenBound;
	wcf.fld1=fld1;
	wcf.fld2=fld2;
	wcf.callback=sCallback;
	wcf.initCalendar();
}        
function hideCalendar()
{
	var cf=document.getElementById("CalFrame");
	cf.style.display="none";
	
	if(document.getElementById("back_date")) {
		if (document.searchForm.back_date.value != '') {
			if(document.getElementById("type") && document.getElementById("tid")) {
				if (document.searchForm.tmpDate.value=="go1") {
					document.searchForm.DDatePeriod1.value = document.searchForm.back_date.value;
					document.searchForm.type.value="1";
					checkInput();
				}			
				if (document.searchForm.tmpDate.value=="go2") {
					document.searchForm.DDatePeriod1.value = document.searchForm.back_date.value;
					document.searchForm.type.value="2";
					checkInput();
				}					
				
			}else if ((!document.getElementById("Home")) || (document.getElementById("Tran"))) {
				var tmp = document.searchForm.Home.value;
				document.searchForm.Home.value = document.searchForm.Dest.value;
				document.searchForm.Dest.value = tmp;
				document.searchForm.DDatePeriod1.value = document.searchForm.back_date.value;
				checkInput();
			} else {
				var tmp = document.searchForm.Home.value;
				document.searchForm.Home.value = document.searchForm.Dest.value;
				document.searchForm.Dest.value = tmp;
				document.searchForm.DDatePeriod1.value = document.searchForm.back_date.value;
				checkInput();
			}
		
		}	

	}
}

