Código PHP:
function calHeader() {
return "<head>\n<title>"+currentCal.title+"</title>\n<style type='text/css'>\n"+spanx("title",titleFontColor)+spanx("days",daysFontColor)+spanx("foot",footColor)+spanx("day",dayFontColor)+spanx("currentDay",currentDayFontColor)+ax("titlea",titleFontColor)+ax("daya",dayFontColor)+ax("currenta",currentDayFontColor)+ax("foota",footFontColor)+"</style>\n</head>\n<body>\n<table align='center' border='0' bgcolor='"+borderColor+"' cellspacing='0' cellpadding='1'><tr><td>\n<table cellspacing='1' cellpadding='3' border='0'>";
}
function calFooter() {
return "<tr bgcolor='"+footColor+"'><td colspan='7' align='center'>"+span1("foot")+"<b>"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.hideCal) window.opener.hideCal()'>"+yxLinks[0]+"</a> "+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.clearDate) window.opener.clearDate()'>"+yxLinks[1]+"</a></b>"+span2+"</td></tr></table>\n</td></tr></table>\n</body>";
}
function calBody(d,day) {
var s="", dayCount=1, fd=firstDay(d), ld=lastDay(d);
if (weekDay > 0 && fd == 0) {
fd = 7;
}
for (var i=0; i<6; i++) {
s+="<tr align='center' bgcolor='"+bodyColor+"'>";
for (var j=weekDay; j<weekDay+7; j++) {
if (i*7+j<fd || dayCount>ld) {
s+="<td>"+span1("day")+" "+span2+"</td>";
}
else {
var bgColor=dayColor;
var fgTag="day";
var fgTagA="daya";
if (dayCount==day) {
bgColor=currentDayColor;
fgTag="currentDay";
fgTagA="currenta";
}
s+="<td bgcolor='"+bgColor+"'>"+span1(fgTag)+a1(fgTagA)+"'javascript: if (window.opener && !window.opener.closed && window.opener.pickDate) window.opener.pickDate("+dayCount+")'>"+(dayCount++)+"</a>"+span2+"</td>";
}
}
s+="</tr>";
}
return s;
}
function moveYear(dy) {
cY+=dy;
var nd=new Date(cY,cM,1);
changeCal(nd);
}
function prepMonth(m) {
cM=m-1;
if (cM<0) { cM=11; cY--; }
var nd=new Date(cY,cM,1);
changeCal(nd);
}
function nextMonth(m) {
cM=m+1;
if (cM>11) { cM=0; cY++;}
var nd=new Date(cY,cM,1);
changeCal(nd);
}
function changeCal(d) {
var dd = 0;
if (currentCal != null) {
var calRE = getFormat();
if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
var cd = getDateNumbers(currentCal.form[currentCal.field].value);
if (cd[0] == d.getFullYear() && cd[1] == d.getMonth()) {
dd=cd[2];
}
}
else {
var cd = new Date();
if (cd.getFullYear() == d.getFullYear() && cd.getMonth() == d.getMonth()) {
dd=cd.getDate();
}
}
}
var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();
calWin.document.open();
calWin.document.write(calendar);
calWin.document.close();
}
function markClick(e) {
if (isIE || isOpera6) {
winX=event.screenX;
winY=event.screenY;
}
else if (isN4 || isN6) {
winX=e.screenX;
winY=e.screenY;
document.routeEvent(e);
}
if (isN4 || isN6) {
document.routeEvent(e);
}
else {
event.cancelBubble=false;
}
return true;
}
function showCal(name) {
var lastCal=currentCal;
var d=new Date(), hasCal=false;
currentCal = findCalendar(name);
if (currentCal != null && currentCal.form != null && currentCal.form[currentCal.field]) {
var calRE = getFormat();
if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
var cd = getDateNumbers(currentCal.form[currentCal.field].value);
d=new Date(cd[0],cd[1],cd[2]);
cY=cd[0];
cM=cd[1];
dd=cd[2];
}
else {
cY=d.getFullYear();
cM=d.getMonth();
dd=d.getDate();
}
var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();
if (calWin != null && !calWin.closed) {
hasCal=true;
calWin.moveTo(winX+calOffsetX,winY+calOffsetY);
}
if (!hasCal) {
if (isIE || isOpera6) { calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",left="+(winX+calOffsetX)+",top="+(winY+calOffsetY));
}
else { calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",screenx="+(winX+calOffsetX)+",screeny="+(winY+calOffsetY));
}
}
calWin.document.open();
calWin.document.write(calendar);
calWin.document.close();
calWin.focus();
}
else {
if (currentCal == null) {
window.status = "Calendar ["+name+"] not found.";
}
else if (!currentCal.form) {
window.status = "Form ["+currentCal.formName+"] not found.";
}
else if (!currentCal.form[currentCal.field]) {
window.status = "Form Field ["+currentCal.formName+"."+currentCal.field+"] not found.";
}
if (lastCal != null) {
currentCal = lastCal;
}
}
}
function get2Digits(n) {
return ((n<10)?"0":"")+n;
}
function clearDate() {
currentCal.form[currentCal.field].value="";
hideCal();
}
function pickDate(d) {
hideCal();
window.focus();
var date=calFormat;
date = date.replace(/yyyy/i, cY);
date = date.replace(/mm/i, get2Digits(cM+1));
date = date.replace(/MON/, yxMonths[cM].substring(0,3).toUpperCase());
date = date.replace(/Mon/i, yxMonths[cM].substring(0,3));
date = date.replace(/dd/i, get2Digits(d));
date = date.replace(/DAY/, getDayName(cY,cM,d).toUpperCase());
date = date.replace(/day/i, getDayName(cY,cM,d));
currentCal.form[currentCal.field].value=date;
currentCal.form[currentCal.field].focus();
}
function checkDate(name) {
var thisCal = findCalendar(name);
if (thisCal != null && thisCal.form != null && thisCal.form[thisCal.field]) {
var calRE = getFormat();
if (calRE.test(thisCal.form[thisCal.field].value)) {
return 0;
}
else {
return 1;
}
}
else {
return 2;
}
}
function getCurrentDate() {
var date=calFormat, d = new Date();
date = date.replace(/yyyy/i, d.getFullYear());
date = date.replace(/mm/i, get2Digits(d.getMonth()+1));
date = date.replace(/dd/i, get2Digits(d.getDate()));
return date;
}
function compareDates(date1, date2) {
var calRE = getFormat();
var d1, d2;
if (calRE.test(date1)) {
d1 = getNumbers(date1);
}
else {
d1 = getNumbers(getCurrentDate());
}
if (calRE.test(date2)) {
d2 = getNumbers(date2);
}
else {
d2 = getNumbers(getCurrentDate());
}
var dStr1 = d1[0] + "" + d1[1] + "" + d1[2];
var dStr2 = d2[0] + "" + d2[1] + "" + d2[2];
if (dStr1 == dStr2) {
return 0;
}
else if (dStr1 > dStr2) {
return 1;
}
else {
return -1;
}
}
function getNumbers(date) {
var calRE = getFormat();
var y, m, d;
if (calRE.test(date)) {
var yIdx = calFormat.search(/yyyy/i);
var mIdx = calFormat.search(/mm/i);
var m3Idx = calFormat.search(/mon/i);
var dIdx = calFormat.search(/dd/i);
y=date.substring(yIdx,yIdx+4);
if (mIdx != -1) {
m=date.substring(mIdx,mIdx+2);
}
else {
var mm=getMonthFromName(date.substring(m3Idx,m3Idx+3))+1;
m=(mm<10)?("0"+mm):(""+mm);
}
d=date.substring(dIdx,dIdx+2);
return new Array(y,m,d);
}
else {
return new Array("", "", "");
}
}
if (isN4 || isN6) {
document.captureEvents(Event.CLICK);
}
document.onclick=markClick;