'
+''
+'';
if (typeof IS_MOBILE != "undefined" && IS_MOBILE) {
openLayer(this.ox_jsCalendarTpl,"center");
setWindowMask(8999);
}else{
openLayer(this.ox_jsCalendarTpl,(e || window.event || "center"));
}
this.elmId = elmId;
this.cType = 1;
}
oxc_calendar.prototype.showCalendarTime = function(elmId,d,e) {
this.showCalendar(elmId,d,e);
this.resetTime();
this.cType = 2;
}
oxc_calendar.prototype.resetTime = function() {
getById(this.vn+"_timeFrame").style.display = "block";
getById(this.vn+"_timeFrame").innerHTML = this.msg["select"];
}
oxc_calendar.prototype.hideCalendar = function(onChoice) {
if (this.ox_jsCalendarTpl) {
closeLayer(this.ox_jsCalendarTpl);
if (onChoice) {
var elm = getById(this.elmId);
if (elm) elm.focus();
}
}
}
oxc_calendar.prototype.getCalendarHtml = function() {
var y = this.year,
m = this.month;
var py = y, pm = m - 1,
ny = y, nm = m + 1;
if (pm < 1) {pm = 12; py--;}
if (nm > 12) {nm = 1; ny++;}
var days = this.lastDay(y,m),
pDays = this.lastDay(py,pm);
var firstDay = new Date(y,m-1,1).getDay(),
lastDay = new Date(y,m-1,days).getDay();
var beginDay = (6 - firstDay == 6)? 1 : 1 - firstDay,
finishDay = (6 - lastDay == 0)? days : days + (6 - lastDay);
var o = this.getTodayInfo();
var i = beginDay, j = 0, d, css, func, idStr;
var c = ["sun","mon","tue","wed","thu","fri","sat"];
var html = '
'+this.msg["calendar"]+'
'
+'
'+this.msg["days"][0]+'
'
+'
'+this.msg["days"][1]+'
'
+'
'+this.msg["days"][2]+'
'
+'
'+this.msg["days"][3]+'
'
+'
'+this.msg["days"][4]+'
'
+'
'+this.msg["days"][5]+'
'
+'
'+this.msg["days"][6]+'
';
while (i <= finishDay) {
if (j == 0) html += "
";
if (i < 1 || i > days) {
d = (i < 1)? i + pDays : i - days;
css = "side";
func = "onChangeDate";
idStr = "";
}else{
d = i;
css = c[j];
if (y == o[0] && m == o[1] && d == o[2]) css += " today";
func = "getDate";
idStr = 'id="'+this.vn+'_date_'+y+'_'+m+'_'+d+'"';
}
html += '
';
i++;
if (j == 6) {html += "
"; j = 0;}
else j++;
}
html += "
";
return html;
}
oxc_calendar.prototype.showYear = function() {
if (this.sType == 1) {
this.hideList();
return;
}
var o = this.getTodayInfo(), now = 0, html = '
';
var y = o[0] - 100,
n = o[0] + 40;
for (var i=0,c; y<=n; y++,i++) {
if (y == this.year) {
c = ' class="on"';
now = i;
}else c = '';
html += '';
}
var elm = getById(this.vn+"_listFrame");
elm.innerHTML = html+'
';
elm.style.display = "block";
getById(this.vn+"_dateFrame").style.display = "none";
getById(this.vn+"_dateBtn"+now).focus();
this.sType = 1;
this.onList();
}
oxc_calendar.prototype.showMonth = function() {
if (this.sType == 2) {
this.hideList();
return;
}
var now = 0, html = '
';
for (var m=1,i=0,c; m<=12; m++,i++) {
if (m == this.month) {
c = ' class="on"';
now = i;
}else c = '';
html += '';
}
var elm = getById(this.vn+"_listFrame");
elm.innerHTML = html+'
';
elm.style.display = "block";
getById(this.vn+"_dateFrame").style.display = "none";
getById(this.vn+"_dateBtn"+now).focus();
this.sType = 2;
this.onList();
}
oxc_calendar.prototype.showHour = function() {
if (this.sType == 3) {
this.hideList();
return;
}
var now = 0, html = '
';
for (var h=0,i=0,c; h<=23; h++,i++) {
if (h == 12) html += '
';
if (h == this.hour) {
c = ' class="on"';
now = h;
}else c = '';
html += '';
if (h == 12) i = 0;
}
var elm = getById(this.vn+"_listFrame");
elm.innerHTML = html+'
';
elm.style.display = "block";
if (now < 12) {
addClass(removeClass(elm,"pm"),"am");
}else{
addClass(removeClass(elm,"am"),"pm");
}
getById(this.vn+"_dateFrame").style.display = "none";
getById(this.vn+"_dateBtn"+now).focus();
this.sType = 3;
this.onList();
}
oxc_calendar.prototype.showMinute = function() {
if (this.sType == 4) {
this.hideList();
return;
}
var now = 0, html = '
';
for (var n=0,i=0,c; n<=55; n+=5,i++) {
if (n == this.min) {
c = ' class="on"';
now = i;
}else c = '';
html += '';
}
var elm = getById(this.vn+"_listFrame");
elm.innerHTML = html+'
';
elm.style.display = "block";
getById(this.vn+"_dateFrame").style.display = "none";
getById(this.vn+"_dateBtn"+now).focus();
this.sType = 4;
this.onList();
}
oxc_calendar.prototype.hideList = function() {
getById(this.vn+"_dateFrame").style.display = "block";
getById(this.vn+"_listFrame").style.display = "none";
this.sType = 0;
this.onList();
}
oxc_calendar.prototype.onList = function() {
var f = [null,removeClass,removeClass,removeClass,removeClass], btn;
f[this.sType] = addClass;
if (btn = getById(this.vn+"_yearElm")) f[1](btn,"on");
if (btn = getById(this.vn+"_monthElm")) f[2](btn,"on");
if (btn = getById(this.vn+"_hourElm")) f[3](btn,"on");
if (btn = getById(this.vn+"_minElm")) f[4](btn,"on");
}
oxc_calendar.prototype.onChangeYear = function(y) {
this.year = y;
this.hideList();
this.changeYM();
getById(this.vn+"_yearElm").focus();
}
oxc_calendar.prototype.onChangeMonth = function(m) {
this.month = m;
this.hideList();
this.changeYM();
getById(this.vn+"_monthElm").focus();
}
oxc_calendar.prototype.onChangeHour = function(h) {
this.hour = h;
this.hideList();
this.changeHM();
getById(this.vn+"_hourElm").focus();
}
oxc_calendar.prototype.onChangeMinute = function(n) {
this.min = n;
this.hideList();
this.changeHM();
getById(this.vn+"_minElm").focus();
}
oxc_calendar.prototype.onChangeDate = function(y,m,d) {
this.hideList();
var o = this.checkYMD(y,m,d);
this.year = o.y;
this.month = o.m;
this.changeYM();
if (m >= 1 && m <= 12) {
var days = this.lastDay(y,m);
if (d < 1 || d > days) {
getById(this.vn+"_date_"+o.y+"_"+o.m+"_"+o.d).focus();
}
}
}
oxc_calendar.prototype.changeYM = function() {
getById(this.vn+"_yearElm").innerHTML = this.year;
getById(this.vn+"_monthElm").innerHTML = this.msg["months"][this.month];
getById(this.vn+"_dateFrame").innerHTML = this.getCalendarHtml();
if (this.cType == 2) this.resetTime();
}
oxc_calendar.prototype.changeHM = function() {
getById(this.vn+"_hourElm").innerHTML = zerofill(this.hour,2);
getById(this.vn+"_minElm").innerHTML = zerofill(this.min,2);
}
oxc_calendar.prototype.getDate = function(y,m,d) {
var btn = getById(this.vn+"_date_"+this.year+"_"+this.month+"_"+this.day);
if (btn) removeClass(btn,"on");
this.year = y;
this.month = m;
this.day = d;
if (this.cType == 1) {
var elm = getById(this.elmId);
if (elm) elm.value = this.getStrDate("Y-m-d",y,m,d);
this.hideCalendar(true);
if (typeof this.userFunc == "function") this.userFunc(this.year,this.month,this.day);
}else{
var o = new Date();
var h = o.getHours();
var n = Math.round(o.getMinutes() / 10) * 10;
if (n == 60) {
n = 0; h++;
if (h > 23) h = 0;
}
this.hour = h;
this.min = n;
getById(this.vn+"_timeFrame").innerHTML = '
'+this.getStrDate(this.msg["ymd"],y,m,d)+'
'
+':'
+''
+'';
btn = getById(this.vn+"_date_"+y+"_"+m+"_"+d);
if (btn) addClass(btn,"on");
}
}
oxc_calendar.prototype.getTime = function() {
var elm = getById(this.elmId);
if (elm) elm.value = this.getStrDate("Y-m-d H:I:S",this.year,this.month,this.day,this.hour,this.min,0);
this.hideCalendar(true);
if (typeof this.userFunc == "function") this.userFunc(this.year,this.month,this.day,this.hour,this.min,0);
}
oxc_calendar.prototype.isDate = function(elm) {
if (!date_confirm(elm)) elm.value = "";
}
function setToday(elmId) {
var o = new Date();
((typeof elmId == "string")? getById(elmId) : elmId).value = o.getFullYear()+"-"+zerofill(o.getMonth()+1,2)+"-"+zerofill(o.getDate(),2);
}
function setTodayTime(elmId) {
var o = new Date();
((typeof elmId == "string")? getById(elmId) : elmId).value = o.getFullYear()+"-"+zerofill(o.getMonth()+1,2)+"-"+zerofill(o.getDate(),2)+" "+zerofill(o.getHours(),2)+":"+zerofill(o.getMinutes(),2)+":"+zerofill(o.getSeconds(),2);
}