﻿document.write('<iframe id=CalFrame name=CalFrame frameborder=0 src=/Calendar/calendar.htm style=display:none;position:absolute;z-index:100></iframe>');
//////////////////////////////////////////////
function document.onclick() //任意点击时关闭该控件
{ 
 if (window.event.srcElement.tagName != "INPUT" && window.event.srcElement.tagName != "IMG" && window.event.srcElement.getAttribute("Author")==null){hideCalendar();}
 if (window.event.srcElement.tagName != "INPUT" && window.event.srcElement.tagName != "IMG" && document.getElementById("myarea")!==null){document.getElementById("myarea").style.display='none';}
}　

///////////////////////////////////////////
function showCalendar(sImg,bOpenBound,sFld1,sFld2,sCallback)
{
	var fld1,fld2;
	var cf=document.getElementById("CalFrame");
	var wcf=window.frames.CalFrame;
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
	if(!sFld1){alert("输入控件未指定！");return;}
	fld1=document.getElementById(sFld1);
	if(!fld1){alert("输入控件不存在！");return;}
	if(fld1.tagName!="INPUT"||fld1.type!="text"){alert("输入控件类型错误！");return;}
	if(sFld2)
	{
		fld2=document.getElementById(sFld2);
		if(!fld2){alert("参考控件不存在！");return;}
		if(fld2.tagName!="INPUT"||fld2.type!="text"){alert("参考控件类型错误！");return;}
	}
	if(!wcf.bCalLoaded){alert("日历未成功装载！请刷新页面！");return;}
	if(cf.style.display=="block"){cf.style.display="none";return;}
	var eT=0,eL=0,p=oImg;
	if(document.body.scrollTop!=0 || (document.documentElement.scrollTop==0 && document.documentElement.clientHeight==0))
	{

		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) + "px";
		cf.style.left=((document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width) + "px";
			
	}
	else
	{
		var sT=document.documentElement.scrollTop,sL=document.documentElement.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.documentElement.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height) + "px";
		cf.style.left=((document.documentElement.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width) + "px";	
	}	
	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";
}

/////////////////////////////////////////
  function setCheckInDate(d)
{
	document.getElementById("hdate1").value=d;
	if(document.getElementById("hdate2").value.length==0)
	{
		showCalendar('dimg2',false,'hdate2','hdate1');
	}
}



/////////////////////////////////////
function doIt(cur_Obj,chkother)
{
	cur_Obj = eval(cur_Obj);
	oObj = document.getElementsByTagName("tr");
	for(i = 0;i < oObj.length;i++)
	{
		oObj_I = oObj[i];
		if(oObj_I.id.indexOf(chkother) != -1 && oObj_I.style.display != "none" && oObj_I.id != cur_Obj.id)
		{
			oObj_I.style.display = "none";
		}
	}
	cur_Obj.style.display = (cur_Obj.style.display =="none"?"":"none");
}
//-->

/////////////////////////
<!--
	function open_me(url,width,height)
	{
		var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
	}
//-->
