document.write('<iframe id=CalFrame name=CalFrame frameborder=0 src=js/calendar.htm style=display:none;position:absolute;z-index:10000></iframe>');
//document.onclick=hideCalendar;


$(document).ready(function(){
	//移动footer到box的后面
	//alert("成功运行！");
	$("#box").after($("#footer"));
	jQuery.noConflict()
});


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("The controlled object is not exist！");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("The control for reference is not exist！");return;}
		if(fld2.tagName!="INPUT"||fld2.type!="text"){alert("Incorrect type of control for reference！");return;}
	}
	if(!wcf.bCalLoaded){alert("Fail to load the calendar. Please refresh the webpage！");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=parseInt((document.body.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height)+"px";
	cf.style.left=parseInt((document.body.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.img=oImg;
	wcf.callback=sCallback;
	wcf.initCalendar();
	
}
function hideCalendar()
{
	var cf=document.getElementById("CalFrame");
	cf.style.display="none";
}
