// ********************************************************
// CalendarBox 2.0 for Asp.Net
// Designed by Faib Studio.
// Copyright 2008
// Email faib920@126.com or QQ 55570729
// ********************************************************
function CalendarBoxs()
{
this.items = [];
this.length = this.items.length;
this.current = null;
};
CalendarBoxs.prototype.add = function(o)
{
this.items.push (o);
this.length = this.items.length;
};
var __CBOXs = new CalendarBoxs();
function CalendarBox(box)
{
this.id = box.id + "_box";
this.name = box.id + "_box";
if(document.getElementById(box.id + "_drop"))
{
document.getElementById(box.id + "_drop").style.height = box.offsetHeight;
};
this.parent = box;
box.calendar = this;
box.isDate = true;
box.onblur = function()
{
this.calendar.initDate();
var error = document.getElementById(this.calendar.calendar + "_error");
if(this.calendar.error)
{
error.style.top = this.calendar.getPosOffset("top") + this.clientHeight + 4;
error.style.left = this.calendar.getPosOffset("left");
error.style.display = "";
};
else error.style.display = "none";
};
box._onchanged = function ()
{
if(this.onchanged)
if(typeof this.onchanged == "string")eval(this.onchanged); else this.onchanged();
};
this.CopyRight = "&#13; 日期选择控件 for Asp.Net 2.0&#13; 版本: 2.0&#13; 作者: 黄旭东&#13; 版权: 飞步工作室(Faib Studio) &#13;";
this.Weekdays = new Array('日', '一', '二', '三', '四', '五', '六');
this.Weekdays1 = new Array('SUN','MON','TUE','WED','THU','FRI','SAT');
this.Months = new Array('一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月');
this.Months1 = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
this.Daydata = new Array(31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
this.calendar = this.id + "_layer";
this.iframe = this.id + "_iframe";
this.PanelColor = box.PanelColor ? box.PanelColor : "#ffffff";
this.WeekColor = box.WeekColor ? box.WeekColor : "#ffffff";
this.WeekBackColor = box.WeekBackColor ? box.WeekBackColor : "#1A4B88";
this.WeekLineColor = box.WeekLineColor ? box.WeekLineColor : "#0C223C";
this.DayColor = box.DayColor ? box.DayColor : "#000000";
this.TodayColor = box.TodayColor ? box.TodayColor : "#000000";
this.TodayBackColor = box.TodayBackColor ? box.TodayBackColor : "#FFECD3";
this.TodayBorderColor = box.TodayBorderColor ? box.TodayBorderColor : "#B4813F";
this.ClickColor = box.ClickColor ? box.ClickColor : "#000000";
this.ClickBackColor = box.ClickBackColor ? box.ClickBackColor : "#888888";
this.ClickBorderColor = box.ClickBorderColor ? box.ClickBorderColor : "#000000";
this.HoverColor = box.HoverColor ? box.HoverColor : "#ff0000";
this.HoverBackColor = box.HoverBackColor ? box.HoverBackColor : "#BBEBFF";
this.HoverBorderColor = box.HoverBorderColor ? box.HoverBorderColor : "#23398B";
this.ButtonColor = box.ButtonColor ? box.ButtonColor : "#000000";
this.ButtonBackColor = box.ButtonBackColor ? box.ButtonBackColor : "#eeeeee";
this.ButtonBorderColor = box.ButtonBorderColor ? box.ButtonBorderColor : "#aaaaaa";
this.CurrentDayColor = box.CurrentDayColor ? box.CurrentDayColor : "#000000";
this.CurrentDayBackColor = box.CurrentDayBackColor ? box.CurrentDayBackColor : "#00ff00";
this.CurrentDayBorderColor = box.CurrentDayBorderColor ? box.CurrentDayBorderColor : "#008800";
this.TitleColor = box.TitleColor ? box.TitleColor : "#000000";
this.DateSeparator = box.DateSeparator ? box.DateSeparator : "-";
this.DateFormat = box.DateFormat ? box.DateFormat : "ymd";
this.TitleCssStyle = box.TitleCssStyle ? box.TitleCssStyle : "";
this.WeekCssStyle = box.WeekCssStyle ? box.WeekCssStyle : "";
this.WeekLineCssStyle = box.WeekLineCssStyle ? box.WeekLineCssStyle : "";
this.DayCssStyle = box.DayCssStyle ? box.DayCssStyle : "";
this.TodayCssStyle = box.TodayCssStyle ? box.TodayCssStyle : "";
this.HoverCssStyle = box.HoverCssStyle ? box.HoverCssStyle : "";
this.ButtonCssStyle = box.ButtonCssStyle ? box.ButtonCssStyle : "";
this.ClickCssStyle = box.ClickCssStyle ? box.ClickCssStyle : "";
this.CurrentDayCssStyle = box.CurrentDayCssStyle ? box.CurrentDayCssStyle : "";
this.UpDownButtonCssStyle = box.UpDownButtonCssStyle ? box.UpDownButtonCssStyle : "";
this.ErrorMessage = box.ErrorMessage ? box.ErrorMessage : "日期格式不正确";
this.CustomTextBox = box.CustomTextBox;
this.error = false;
this.cYear = null;
this.cMonth = null;
this.cDay = null;
this.initDate();
this.init();
this.setCurrentDate();
this.Date = this.returnDate();
};
CalendarBox.prototype.isDate = function()
{
var obj = this.CustomTextBox ? document.getElementById(this.CustomTextBox) : this.parent;
if(obj == null)return;
var pp = obj.value.split(this.DateSeparator);
var y = pp[this.DateFormat.indexOf("y")];
var m = pp[this.DateFormat.indexOf("m")];
var d = pp[this.DateFormat.indexOf("d")];
var str = y + "-" + m + "-" + d;
var reg=/^(\d{0,4})-(\d{1,2})-(\d{1,2})/;
var r=reg.exec(str);
if(r==null)	return false;
else
{
r[3] = str.split("-")[2];
var d=new Date(r[1],r[2]-1,r[3]);
if(d.getFullYear()==r[1]&&(d.getMonth()+1)==r[2]&&d.getDate()==r[3])
{
this.Year = d.getFullYear();
this.Month = d.getMonth() + 1;
this.Day = d.getDate();
return true;
};
else return false;
};
};
CalendarBox.prototype.setCurrentDate = function()
{
this.cYear = this.Year;
this.cMonth = this.Month;
this.cDay = this.Day;
};
CalendarBox.prototype.initDate = function()
{
this.error = !this.isDate();
var obj = this.CustomTextBox ? document.getElementById(this.CustomTextBox) : this.parent;
if(obj == null)return;
if(obj.value == "" || this.error)
{
if(obj.value == "")this.error = false;
this.Year = new Date().getFullYear();
this.Month = new Date().getMonth() + 1;
this.Day = new Date().getDate();
};
this.parent.isDate = !this.error;
};
CalendarBox.prototype.init = function()
{
var ow = new Writer();
var error_text = this.ErrorMessage + "(格式:";
switch(this.DateFormat)
{
case "ymd":
error_text += "年" + this.DateSeparator + "月" + this.DateSeparator + "日";
break;
case "dmy":
error_text += "日" + this.DateSeparator + "月" + this.DateSeparator + "年";
break;
case "mdy":
error_text += "月" + this.DateSeparator + "日" + this.DateSeparator + "年";
break;
};
error_text += ")!";
ow.into("<div id='", this.calendar, "_error' style='padding:2px;position: absolute; z-index: 6666; width: 200; height: 20; display: none;border: 1px solid #000000;background-color:white;FILTER: alpha(opacity=90);cursor:hand' onclick=\"this.style.display='none';document.getElementById('" + this.parent.id + "').focus()\"><font style='font-size:9pt;color:red'>" + error_text + "</font></div>");
ow.into("<div id='", this.calendar, "' style='position: absolute; z-index: 9999; width: 210px; height:265px; display: none;'>");
ow.into("<iframe name='", this.iframe, "' id='", this.iframe, "' scrolling=no frameborder=0 width=100% height=100%>此浏览器不支持浮动框架。</iframe>");
ow.into("</div>");
document.write(ow.out());
ow.clear();
ow.into("<html><head><style>");
ow.into("*{font-size: 9pt; font-family: 宋体};");
ow.into("body{border:1px solid #0000};");
if(this.TitleCssStyle == "")ow.into(".Title{color:" + this.TitleColor + ";};");
else ow.into(".Title{" + this.TitleCssStyle + "};");
if(this.WeekCssStyle == "")ow.into(".Week{height:20px;width:30px;color:" + this.WeekColor + ";background-color:" + this.WeekBackColor +";text-align:center};");
else ow.into(".Week{" + this.WeekCssStyle + ";height:20px;width:30px;text-align:center;};");
if(this.DayCssStyle == "")ow.into(".Day{height:30px;width:30px;color:" + this.DayColor + ";border:1px solid " + this.PanelColor + ";text-align:center;cursor:default};");
else ow.into(".Day{" + this.DayCssStyle + ";height:30px;width:30px;text-align:center;cursor:default;};");
if(this.TodayCssStyle == "")ow.into(".Today{height:30px;width:30px;color:" + this.TodayColor + ";background-color:" + this.TodayBackColor +";border:1px solid " + this.TodayBorderColor + ";text-align:center;cursor:default};");
else ow.into(".Today{" + this.TodayCssStyle + ";height:30px;width:30px;text-align:center;cursor:default;};");
if(this.HoverCssStyle == "")ow.into(".Hover{height:30px;width:30px;color:" + this.HoverColor + ";background-color:" + this.HoverBackColor +";border:1px solid " + this.HoverBorderColor + ";text-align:center;cursor:default};");
else ow.into(".Hover{" + this.HoverCssStyle + ";height:30px;width:30px;text-align:center;cursor:default;};");
if(this.ButtonCssStyle == "")ow.into(".Button{height:20px;color:" + this.ButtonColor + ";background-color:" + this.ButtonBackColor +";border:1px solid " + this.ButtonBorderColor + ";text-align:center};");
else ow.into(".Button{" + this.ButtonCssStyle + ";height:20px;text-align:center;};");
if(this.CurrentDayCssStyle == "")ow.into(".Current{height:20px;color:" + this.CurrentDayColor + ";background-color:" + this.CurrentDayBackColor +";border:1px solid " + this.CurrentDayBorderColor + ";text-align:center};");
else ow.into(".Current{" + this.CurrentDayCssStyle + ";height:20px;text-align:center;};");
if(this.ClickCssStyle == "")ow.into(".Click{height:30px;width:30px;color:" + this.ClickColor + ";background-color:" + this.ClickBackColor +";border:1px solid " + this.ClickBorderColor + ";text-align:center;cursor:default};");
else ow.into(".Click{" + this.ClickCssStyle + ";height:20px;text-align:center;};");
if(this.UpDownButtonCssStyle == "")ow.into(".UpDownButton{height:20px;color:" + this.ButtonColor + ";background-color:" + this.ButtonBackColor +";border:1px solid " + this.ButtonBorderColor + ";text-align:center;width:20px;font-family: Marlett;};");
else ow.into(".UpDownButton{" + this.UpDownButtonCssStyle + ";height:20px;width:20px;};");
ow.into("</style></head>");
ow.into("<body bgcolor='" + this.PanelColor + "' onselectstart='return false' style='margin: 1px' oncontextmenu='return false'><form name=form1>");
ow.into("<table class='Panel' width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td colspan=7>");
ow.into("<table border=0 cellpadding=0 cellspacing=0 width=100%><tr title='日期选择控件 for Asp.Net 2.0&#13;快捷键说明:&#13;上一年[←] 下一年[→] 上一月[↑] 下一月[↓]&#13;前10年[PageUp] 后10年[PageDown] 关闭[Esc]'>");
ow.into("<td width=60><input type=button class='UpDownButton' onclick='parent." + this.id + ".prevYear();' value='3' title='上一年 ←'><input type=button class='UpDownButton' onclick='parent." + this.id + ".nextYear();' value='4' title='下一年 →'><input type=button class='UpDownButton' onclick='parent." + this.id + ".showYearList()' value='6' title=单击选择年份></td>");
ow.into("<td align=left style='padding-left:6px;border:1px solid " + this.PanelColor + ";cursor:hand' width=52 onclick='parent." + this.id + ".showYearList()'><span id='_tyear' class='Title'></span></td>");
ow.into("<td align=right style='padding-right:6px;border:1px solid " + this.PanelColor + ";cursor:hand' width=38 onclick='parent." + this.id + ".showMonthList()'><span id='_tmonth' class='Title'></span></td>");
ow.into("<td width=60><input type=button class='UpDownButton' onclick='parent." + this.id + ".showMonthList()' value='6' title=单击选择月份><input type=button class='UpDownButton' onclick='parent." + this.id + ".prevMonth();' value='3' title='上一月 ↑'><input type=button class='UpDownButton' onclick='parent." + this.id + ".nextMonth();' value='4' title='下一月 ↓'></td>");
ow.into("</tr></table></td></tr><tr><td colspan=7 height=1></td></tr><tr><td colspan=7 height=1 bgcolor=" + this.WeekLineColor + "></td></tr><tr><td colspan=7 height=1></td></tr><tr height=20 title='" + this.CopyRight + "'>");
for(var i = 0; i < 7; i++)
ow.into("<td class='Week'>" + this.Weekdays[i] + "</td>");
ow.into("</tr><tr><td colspan=7 height=1></td></tr><tr><td colspan=7 height=1 bgcolor=" + this.WeekLineColor + "></td></tr><tr><td colspan=7 style='padding:1px;' height=26><table width=100% height=100% border=0 cellpadding=0 cellspacing=1 id='_days'>");
for(var i = 0; i < 6; i++)
{
ow.into("<tr>");
for(var j = 0; j < 7; j++)
ow.into("<td class=Day oldclass=Day onmouseover=\"if(this.innerText != '')this.className='Hover'\" onmouseout=\"if(this.innerText != '')this.className=this.oldclass\" onmousedown=\"if(this.innerText != '')this.className='Click'\" onclick=\"if(this.innerText != '')parent." + this.id + ".setDate(this.innerText);\"></td>");
ow.into("</tr>");
};
ow.into("</table></td></tr><tr><td colspan=7 height=1></td></tr><tr><td colspan=7 height=1 bgcolor=" + this.WeekLineColor + "></td></tr><tr><td colspan=7 height=1></td></tr><tr><td colspan=7 align=center height=24><input type='button' class='Button' value='今天' style='width:62px' onclick='parent." + this.id + ".setToday()'> <input type='button' class='Button' value='清除' style='width:62px'onclick='parent." + this.id + ".clear()'> <input type='button' class='Button' value='关闭' title='快捷键Esc' style='width:62px'onclick='parent." + this.id + ".close()'></td></tr></table>");
ow.into("<div id=yearlist  style='border:1px solid #000000;width:50px;background-color:white;position:absolute;display:none;top:20px;left:61px;'></div>");
ow.into("<div id=monthlist style='border:1px solid #000000;width:36px;background-color:white;position:absolute;display:none;top:20px;left:111px;'></div>");
ow.into("<script>");
ow.into("document.onkeydown = function (){");
ow.into("switch(event.keyCode){");
ow.into("case 37: parent." + this.id + ".prevYear();event.returnValue = 0;break;");
ow.into("case 38: parent." + this.id + ".prevMonth();event.returnValue = 0;break;");
ow.into("case 39: parent." + this.id + ".nextYear();event.returnValue = 0;break;");
ow.into("case 40: parent." + this.id + ".nextMonth();event.returnValue = 0;break;");
ow.into("case 27: parent." + this.id + ".close();event.returnValue = 0;break;");
ow.into("case 33: parent." + this.id + ".prevYear(10);event.returnValue = 0;break;");
ow.into("case 34: parent." + this.id + ".nextYear(10);event.returnValue = 0;break;");
ow.into("};}</script>");
ow.into("</form></body></html>");
with(document.frames[this.iframe])
{
document.open();
document.writeln(ow.out());
document.close();
};
};
CalendarBox.prototype.prevYear = function (step)
{
var step1 = step == undefined ? 1 : step;
if(this.Year - step1 <= 1000)return;
this.Year -= step1;
this.Date = this.returnDate();
this.writeDate();
};
CalendarBox.prototype.nextYear = function (step)
{
var step1 = step == undefined ? 1 : step;
if(this.Year + step1 >= 9999)return;
this.Year += step1;
this.Date = this.returnDate();
this.writeDate();
};
CalendarBox.prototype.prevMonth = function ()
{
this.Month --;
if(this.Month <= 0)
{
this.Month = 12;
this.Year -- ;
};
this.Date = this.returnDate();
this.writeDate();
};
CalendarBox.prototype.nextMonth = function ()
{
this.Month ++;
if(this.Month >= 13)
{
this.Month = 1;
this.Year ++ ;
};
this.Date = this.returnDate();
this.writeDate();
};
CalendarBox.prototype.selectYear = function (year)
{
this.Year = parseInt(year);
this.Date = this.returnDate();
this.writeDate();
};
CalendarBox.prototype.selectMonth = function (month)
{
this.Month = parseInt(month);
this.Date = this.returnDate();
this.writeDate();
};
CalendarBox.prototype.setDate = function (d)
{
this.Day = d;
this.Date = this.returnDate();
this.setCurrentDate();
this.parent.date = this.Date;
if(this.CustomTextBox)
{
var d = document.getElementById(this.CustomTextBox);
d.value = this.Date;
d.focus();
this.parent._onchanged();
};
else
{
this.parent.value = this.Date;
this.parent.focus();
};
this.close();
if(this.parent.autopostback)
__doPostBack(this.parent.id, "");
};
CalendarBox.prototype.setToday = function ()
{
this.Year = new Date().getFullYear();
this.Month = new Date().getMonth() + 1;
this.Day = new Date().getDate();
this.Date = this.returnDate();
this.setCurrentDate();
if(this.CustomTextBox)
{
var d = document.getElementById(this.CustomTextBox);
d.value = this.Date;
d.focus();
};
else
{
this.parent.value = this.Date;
this.parent.focus();
};
this.close();
if(this.parent.autopostback)
__doPostBack(this.parent.id, "");
};
CalendarBox.prototype.showYearList = function ()
{
var list = document.frames[this.iframe].document.getElementById('yearlist');
var span = document.frames[this.iframe].document.getElementById('_tyear').parentElement;
if(list.style.display = 'none');
{
list.style.display = "";
list.childNodes[0].focus();
span.style.border = "1px solid #000000";
span.style.backgroundColor = "#ffffff";
};
};
CalendarBox.prototype.showMonthList = function ()
{
var list = document.frames[this.iframe].document.getElementById('monthlist');
var span = document.frames[this.iframe].document.getElementById('_tmonth').parentElement;
if(list.style.display = 'none');
{
list.style.display = "";
list.childNodes[0].focus();
span.style.border = "1px solid #000000";
span.style.backgroundColor = "#ffffff";
};
};
CalendarBox.prototype.fillYear = function ()
{
var list = document.frames[this.iframe].document.getElementById('yearlist');
var tyear = document.frames[this.iframe].document.getElementById('_tyear');
var y = parseInt(tyear.innerText.substr(0, tyear.innerText.length - 1));
while(list.childNodes.length > 0)
list.removeChild(list.childNodes[0])
var s1 = y - 6; if(s1 < 1000)s1 = 1000;
var e1 = y + 5; if(e1 > 9999)e1 = 9999;
for(var i = s1; i < e1; i++)
{
var item = document.frames[this.iframe].document.createElement('div');
item.innerText = (i + 1) + "年";
item.style.height = '16px';
item.style.padding = '2px';
item.style.paddingLeft = '6px';
item.style.textAlign = 'left';
item.style.cursor = 'default';
item.calendar = this.id;
item.onmouseover = function ()
{
this.style.backgroundColor = "#206DEB";
this.style.color = "#ffffff";
};
item.onmouseout = function ()
{
this.style.backgroundColor = "";
this.style.color = "";
};
item.onblur = function()
{
this.parentElement.style.display = "none";
var span = this.parentElement.parentElement.all('_tyear').parentElement;
span.style.border = "1px solid " + eval(this.calendar).PanelColor;
span.style.backgroundColor = "";
};
item.onmousedown = function ()
{
item.parentElement.style.display = "none";
var span = this.parentElement.parentElement.all('_tyear').parentElement;
span.style.border = "1px solid " + eval(this.calendar).PanelColor;
span.style.backgroundColor = "";
eval(this.calendar).selectYear(this.innerText.substr(0, this.innerText.length - 1));
};
list.appendChild(item);
};
};
CalendarBox.prototype.fillMonth = function ()
{
var list = document.frames[this.iframe].document.getElementById('monthlist');
var tmonth = document.frames[this.iframe].document.getElementById('_tmonth');
if(list.childNodes.length == 0)
{
for(var i = 0; i < 12; i++)
{
var item = document.frames[this.iframe].document.createElement('div');
item.innerText = (i + 1) + "月";
item.style.height = '16px';
item.style.padding = '2px';
item.style.paddingRight = '6px';
item.style.textAlign = 'right';
item.style.cursor = 'default';
item.calendar = this.id;
item.onmouseover = function ()
{
this.style.backgroundColor = "#206DEB";
this.style.color = "#ffffff";
};
item.onmouseout = function ()
{
this.style.backgroundColor = "";
this.style.color = "";
};
item.onblur = function()
{
this.parentElement.style.display = "none";
var span = this.parentElement.parentElement.all('_tmonth').parentElement;
span.style.border = "1px solid " + eval(this.calendar).PanelColor;
span.style.backgroundColor = "";
};
item.onmousedown = function ()
{
item.parentElement.style.display = "none";
var span = this.parentElement.parentElement.all('_tmonth').parentElement;
span.style.border = "1px solid " + eval(this.calendar).PanelColor;
span.style.backgroundColor = "";
eval(this.calendar).selectMonth(this.innerText.substr(0, this.innerText.length - 1));
};
list.appendChild(item);
};
};
};
CalendarBox.prototype.clear = function ()
{
if(this.CustomTextBox)
{
var d = document.getElementById(this.CustomTextBox);
d.value = "";
d.focus();
};
else
{
this.parent.value = "";
this.parent.focus();
};
this.close();
};
CalendarBox.prototype.close = function ()
{
document.getElementById(this.calendar).style.display = "none";
};
CalendarBox.prototype.writeDate = function()
{
var iframe = document.frames[this.iframe];
iframe._tyear.innerText = this.Year + "年";
iframe._tmonth.innerText = this.Month + "月";
this.fillYear();
this.fillMonth();
var x = 0, y = new Date(this.Year, this.Month - 1, 1).getDay();
var endday = 0;
if(this.Month == 2)endday = (0 == this.Year % 4 && (this.Year % 100 != 0 || this.Year % 400==0)) ? 29 : 28;
else endday = this.Daydata[this.Month - 1];
for(var i = 0; i < 6; i++)
{
for(var j = 0; j < 7; j++)
{
iframe._days.rows[i].cells[j].innerText = "";
iframe._days.rows[i].cells[j].className = "Day";
iframe._days.rows[i].cells[j].oldclass = "Day";
};
};
for(var i = 1; i <= endday; i++)
{
iframe._days.rows[x].cells[y].innerText = i;
if(this.Year == new Date().getFullYear() && this.Month == new Date().getMonth() + 1)
{
if(i == this.Day)
{
iframe._days.rows[x].cells[y].className = "Current";
iframe._days.rows[x].cells[y].oldclass = "Current";
};
else if(i == new Date().getDate())
{
iframe._days.rows[x].cells[y].className = "Today";
iframe._days.rows[x].cells[y].oldclass = "Today";
};
};
y ++;
if(y > 6)
{
y = 0; x ++;
};
};
};
CalendarBox.prototype.returnDate = function()
{
switch(this.DateFormat)
{
case "ymd":
return this.Year + this.DateSeparator + this.Month + this.DateSeparator + this.Day;
break;
case "dmy":
return this.Day + this.DateSeparator + this.Month + this.DateSeparator + this.Year;
break;
case "mdy":
return this.Month + this.DateSeparator + this.Day + this.DateSeparator + this.Year;
break;
};
};
CalendarBox.prototype.showPicker = function()
{
if(document.getElementById(this.calendar).style.display == "none")
{
var obj = this.CustomTextBox ? document.getElementById(this.CustomTextBox) : this.parent;
if(!obj){alert('没有关联到文本框');return;}
for(var i = 0; i < __CBOXs.length; i++)
if(__CBOXs.items[i].id != this.id)__CBOXs.items[i].close();
this.initDate();
this.writeDate();
var div = document.getElementById(this.calendar);
var x = this.getPosOffset("left");
var y = this.getPosOffset("top") + obj.offsetHeight;
if(x + div.offsetWidth > document.body.clientWidth + document.body.scrollLeft)x = document.body.clientWidth + document.body.scrollLeft - div.offsetWidth;
if(y + div.offsetHeight > document.body.clientHeight + document.body.scrollTop)y = document.body.clientHeight + document.body.scrollTop - div.offsetHeight;
div.style.left = x;
div.style.top = y;
div.style.display = "";
document.frames[this.iframe].document.body.focus();
__CBOXs.current = this.id;
};
else this.hidePicker();
};
CalendarBox.prototype.hidePicker = function ()
{
document.frames[this.iframe].document.getElementById('yearlist').style.display = "none";
document.frames[this.iframe].document.getElementById('monthlist').style.display = "none";
document.getElementById(this.calendar).style.display = "none";
};
CalendarBox.prototype.getPosOffset = function(offsettype, par)
{
var tolOfset=0;
var obj = this.CustomTextBox ? document.getElementById(this.CustomTextBox) : this.parent;
switch(offsettype)
{
case "left":
tolOfset = obj.offsetLeft;
break;
case "top":
tolOfset = obj.offsetTop;
break;
case "width":
tolOfset = obj.offsetWidth;
break;
case "height":
tolOfset = obj.offsetHeight;
break;
};
var parElt = obj.offsetParent;
while (parElt != null && parElt.tagName != "BODY"){
if(par == parElt)break;
switch(offsettype)
{
case "left":
tolOfset = tolOfset + parElt.offsetLeft;
break;
case "top":
tolOfset = tolOfset + parElt.offsetTop;
break;
};
parElt = parElt.offsetParent;
};
return tolOfset;
};
if(!Writer)
{
function Writer() {
this.buffArray = [];
this.into = function () {
var n = arguments.length;
for (var nI = 0; nI < n; nI++)
this.buffArray[this.buffArray.length] = arguments[nI];
};
this.out = function () {
return this.buffArray.join('');
};
this.clear = function () {
this.buffArray = [];
};
};
};

