// +------------------------------------------------------------+
// | Popup Calendar(Window) |
// +------------------------------------------------------------+
// | Last Modified: 03-Oct-2003 |
// | Web Site: http://www.yxscripts.com |
// | EMail: m_yangxin@hotmail.com |
// +------------------------------------------------------------+
// | Copyright 2002 Xin Yang All Rights Reserved. |
// | This version featured on Dynamic Drive |
// | (http://www.dynamicdrive.com) |
// +------------------------------------------------------------+
// default settings
var fontFace="verdana";
var fontSize=12;
var titleWidth=90;
var titleMode=1;
var dayWidth=24;
var dayDigits=1;
var titleColor="#cccccc";
var daysColor="#cccccc";
var bodyColor="#ffffff";
var dayColor="#ffffff";
var currentDayColor="#333333";
var footColor="#cccccc";
var borderColor="#333333";
var titleFontColor = "#333333";
var daysFontColor = "#333333";
var dayFontColor = "#333333";
var currentDayFontColor = "#ffffff";
var footFontColor = "#333333";
var calFormat = "yyyy-mm-dd";
var weekDay = 0;
// ------
// codes
var calWidth=200, calHeight=220, calOffsetX=-200, calOffsetY=16;
var calWin=null;
var winX=0, winY=0;
var cal="cal";
var cals=new Array();
var currentCal=null;
var yxMonths=new Array("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月");
var yxDays=new Array("日", "一", "二", "三", "四", "五", "六", "日");
var yxLinks=new Array("[关闭]", "[清空]");
var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;
var isOpera5=(navigator.appVersion.indexOf("MSIE 5")!=-1 && navigator.userAgent.indexOf("Opera 5")!=-1)?true:false;
var isOpera6=(navigator.appVersion.indexOf("MSIE 5")!=-1 && navigator.userAgent.indexOf("Opera 6")!=-1)?true:false;
var isN6=(navigator.userAgent.indexOf("Gecko")!=-1);
var isN4=(document.layers)?true:false;
var isMac=(navigator.userAgent.indexOf("Mac")!=-1);
var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;
if (isN4) {
fontSize+=2;
}
var span2="</span>";
function span1(tag) {
return "<span class='"+tag+"'>";
}
function spanx(tag, color) {
return "."+tag+" { font-family:"+fontFace+"; font-size:"+fontSize+"px; color:"+color+"; }\n";
}
function a1(tag) {
return "<a class='"+tag+"' href=";
}
function ax(tag, color) {
return "."+tag+" { text-decoration:none; color:"+color+"; }\n";
}
function calOBJ(name, title, field, form) {
this.name = name;
this.title = title;
this.field = field;
this.formName = form;
this.form = null
}
function setFont(font, size) {
if (font != "") {
fontFace=font;
}
if (size > 0) {
fontSize=size;
if (isN4) {
fontSize+=2;
}
}
}
function setWidth(tWidth, tMode, dWidth, dDigits) {
if (tWidth > 0) {
titleWidth=tWidth;
}
if (tMode == 1 || tMode == 2) {
titleMode=tMode;
}
if (dWidth > 0) {
dayWidth=dWidth;
}
if (dDigits > 0) {
dayDigits=dDigits;
}
}
function setColor(tColor, dsColor, bColor, dColor, cdColor, fColor, bdColor) {
if (tColor != "") {
titleColor=tColor;
}
if (dsColor != "") {
daysColor=dsColor;
}
if (bColor != "") {
bodyColor=bColor;
}
if (dColor != "") {
dayColor=dColor;
}
if (cdColor != "") {
currentDayColor=cdColor;
}
if (fColor != "") {
footColor=fColor;
}
if (bdColor != "") {
borderColor=bdColor;
}
}
function setFontColor(tColorFont, dsColorFont, dColorFont, cdColorFont, fColorFont) {
if (tColorFont != "") {
titleFontColor=tColorFont;
}
if (dsColorFont != "") {
daysFontColor=dsColorFont;
}
if (dColorFont != "") {
dayFontColor=dColorFont;
}
if (cdColorFont != "") {
currentDayFontColor=cdColorFont;
}
if (fColorFont != "") {
footFontColor=fColorFont;
}
}
function setFormat(format) {
calFormat = format;
}
function setSize(width, height, ox, oy) {
if (width > 0) {
calWidth=width;
}
if (height > 0) {
calHeight=height;
}
calOffsetX=ox;
calOffsetY=oy;
}
function setWeekDay(wDay) {
if (wDay == 0 || wDay == 1) {
weekDay = wDay;
}
}
function setMonthNames(janName, febName, marName, aprName, mayName, junName, julName, augName, sepName, octName, novName, decName) {
if (janName != "") {
yxMonths[0] = janName;
}
if (febName != "") {
yxMonths[1] = febName;
}
if (marName != "") {
yxMonths[2] = marName;
}
if (aprName != "") {
yxMonths[3] = aprName;
}
if (mayName != "") {
yxMonths[4] = mayName;
}
if (junName != "") {
yxMonths[5] = junName;
}
if (julName != "") {
yxMonths[6] = julName;
}
if (augName != "") {
yxMonths[7] = augName;
}
if (sepName != "") {
yxMonths[8] = sepName;
}
if (octName != "") {
yxMonths[9] = octName;
}
if (novName != "") {
yxMonths[10] = novName;
}
if (decName != "") {
yxMonths[11] = decName;
}
}
function setDayNames(sunName, monName, tueName, wedName, thuName, friName, satName) {
if (sunName != "") {
yxDays[0] = sunName;
yxDays[7] = sunName;
}
if (monName != "") {
yxDays[1] = monName;
}
if (tueName != "") {
yxDays[2] = tueName;
}
if (wedName != "") {
yxDays[3] = wedName;
}
if (thuName != "") {
yxDays[4] = thuName;
}
if (friName != "") {
yxDays[5] = friName;
}
if (satName != "") {
yxDays[6] = satName;
}
}
function setLinkNames(closeLink, clearLink) {
if (closeLink != "") {
yxLinks[0] = closeLink;
}
if (clearLink != "") {
yxLinks[1] = clearLink;
}
}
function addCalendar(name, title, field, form) {
cals[cals.length] = new calOBJ(name, title, field, form);
}
function findCalendar(name) {
for (var i = 0; i < cals.length; i++) {
if (cals[i].name == name) {
if (cals[i].form == null) {
if (cals[i].formName == "") {
if (document.forms[0]) {
cals[i].form = document.forms[0];
}
}
else if (document.forms[cals[i].formName]) {
cals[i].form = document.forms[cals[i].formName];
}
}
return cals[i];
}
}
return null;
}
function getDayName(y,m,d) {
var wd=new Date(y,m,d);
return yxDays[wd.getDay()].substring(0,3);
}
function getMonthFromName(m3) {
for (var i = 0; i < yxMonths.length; i++) {
if (yxMonths[i].toLowerCase().substring(0,3) == m3.toLowerCase()) {
return i;
}
}
return 0;
}
function getFormat() {
var calF = calFormat;
calF = calF.replace(/\\/g, '\\\\');
calF = calF.replace(/\//g, '\\\/');
calF = calF.replace(/\[/g, '\\\[');
calF = calF.replace(/\]/g, '\\\]');
calF = calF.replace(/\(/g, '\\\(');
calF = calF.replace(/\)/g, '\\\)');
calF = calF.replace(/\{/g, '\\\{');
calF = calF.replace(/\}/g, '\\\}');
calF = calF.replace(/\</g, '\\\<');
calF = calF.replace(/\>/g, '\\\>');
calF = calF.replace(/\|/g, '\\\|');
calF = calF.replace(/\*/g, '\\\*');
calF = calF.replace(/\?/g, '\\\?');
calF = calF.replace(/\+/g, '\\\+');
calF = calF.replace(/\^/g, '\\\^');
calF = calF.replace(/\$/g, '\\\$');
calF = calF.replace(/dd/i, '\\d\\d');
calF = calF.replace(/mm/i, '\\d\\d');
calF = calF.replace(/yyyy/i, '\\d\\d\\d\\d');
calF = calF.replace(/day/i, '\\w\\w\\w');
calF = calF.replace(/mon/i, '\\w\\w\\w');
return new RegExp(calF);
}
function getDateNumbers(date) {
var y, m, d;
var yIdx = calFormat.search(/yyyy/i);
var mIdx = calFormat.search(/mm/i);
var m3Idx = calFormat
评论0