document.write('<iframe id=CalFrame name=CalFrame frameborder=0 src=/cal/cal.htm style=display:none;position:absolute;z-index:110></iframe>');
document.onclick=hideCalendar;

function showCalendar(sImg,bOpenBound,sFld1,sNextP,sNextD,sStartD,sEndD,sVD,sOE,sVDE,sOT,s3F,sFld2,sCallback,sNextVDE){
	var fld1,fld2;
	var cf=document.getElementById("CalFrame");
	var wcf=window.frames.CalFrame;
	var oImg=document.getElementById(sImg);
	fld1=document.getElementById(sFld1);
	if(sFld2) fld2=document.getElementById(sFld2);
	if(!wcf.bCalLoaded){alert("Error, refresh page again.");return;}
	wcf.n_position=sNextP;
	wcf.n_textdate=sNextD;
	wcf.startdate=sStartD;
	wcf.enddate=sEndD;
	wcf.vailidday=sVD;
	wcf.oddeven=sOE;
	wcf.vailiddate=sVDE;
	wcf.nextvailiddate = sNextVDE;
	wcf.objecttype=sOT;
	wcf.thirdfocus=s3F;
	if(cf.style.display=="block"){cf.style.display="none";return;}

	var eT=0,eL=0,p=oImg;
	var sT=(document.body.scrollTop > document.documentElement.scrollTop)? document.body.scrollTop:document.documentElement.scrollTop;
	var sL=(document.body.scrollLeft > document.documentElement.scrollLeft )? document.body.scrollLeft:document.documentElement.scrollLeft;
	var h1 = document.body.clientHeight;
	var h2 = document.documentElement.clientHeight;
	var isXhtml = (h2<=h1&&h2!=0)?true:false;
	var myClient = getClient();
	var myScroll = getScroll();

	var eH=oImg.height,eW=oImg.width;
	while(p&&p.tagName.toLowerCase() != "body"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
	var bottomSpace = myClient.clientHeight - eT - myScroll.sTop;
	eH=5;
	if(sOT=="text"){
		cf.style.top= (eT+eH+20).toString() + "px";
	} else {
		cf.style.top= (eT+eH+20).toString() + "px";
	}

	cf.style.left= ((isXhtml?document.documentElement.clientWidth:document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width).toString() + "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 getScroll(){
	var sTop = 0, sLeft = 0, sWidth = 0, sHeight = 0;

	sTop = (document.body.scrollTop > document.documentElement.scrollTop)? document.body.scrollTop:document.documentElement.scrollTop;
	if( isNaN(sTop) || sTop <0 ){ sTop = 0 ;}

	sLeft = (document.body.scrollLeft > document.documentElement.scrollLeft )? document.body.scrollLeft:document.documentElement.scrollLeft;
	if( isNaN(sLeft) || sLeft <0 ){ sLeft = 0 ;}

	return { sTop:sTop, sLeft: sLeft, sWidth: sWidth, sHeight: sHeight };
}

function getClient(){
	var h1 = document.body.clientHeight;
	var h2 = document.documentElement.clientHeight;
	var isXhtml = (h2<=h1&&h2!=0)?true:false;

	this.clientHeight = isXhtml?document.documentElement.clientHeight:document.body.clientHeight;
	this.clientWidth  = isXhtml?document.documentElement.clientWidth:document.body.clientWidth;

	return {clientHeight:this.clientHeight,clientWidth:this.clientWidth};
}

function NextToEnd(){
	showCalendar('b',false,'dtEnd','','','','','','','','','');
}

function opendtStart(){
	showCalendar('a',false,'dtStart','b','dtEnd','','','','','','','');
}

function opendtEnd(){
	showCalendar('b',false,'dtEnd','','','','','','','',null,'','dtStart');
}