1 function MM_swapImgRestore() { //v3.0
2 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
5 function MM_displayStatusMsg(msgStr) { //v1.0
7 document.MM_returnValue = true;
10 function MM_preloadImages() { //v3.0
11 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
12 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
13 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
16 function MM_findObj(n, d) { //v3.0
17 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
18 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
19 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
20 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
23 function MM_swapImage() { //v3.0
24 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
25 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
28 function MM_nbGroup(event, grpName) { //v3.0
29 var i,img,nbArr,args=MM_nbGroup.arguments;
30 if (event == "init" && args.length > 2) {
31 if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
32 img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
33 if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
34 nbArr[nbArr.length] = img;
35 for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
36 if (!img.MM_up) img.MM_up = img.src;
37 img.src = img.MM_dn = args[i+1];
38 nbArr[nbArr.length] = img;
40 } else if (event == "over") {
41 document.MM_nbOver = nbArr = new Array();
42 for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
43 if (!img.MM_up) img.MM_up = img.src;
44 img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
45 nbArr[nbArr.length] = img;
47 } else if (event == "out" ) {
48 for (i=0; i < document.MM_nbOver.length; i++) {
49 img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
50 } else if (event == "down") {
51 if ((nbArr = document[grpName]) != null)
52 for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
53 document[grpName] = nbArr = new Array();
54 for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
55 if (!img.MM_up) img.MM_up = img.src;
56 img.src = img.MM_dn = args[i+1];
57 nbArr[nbArr.length] = img;
64 var weekendColor = "#DDEEFF";
65 var fontface = "Arial, Helvetica, sans-serif";
68 var gNow = new Date();
70 isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
71 isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
73 Calendar.Months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
74 "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
76 Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
77 Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
79 function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
80 if ((p_month == null) && (p_year == null)) return;
83 this.gWinCal = ggWinCal;
85 this.gWinCal = p_WinCal;
87 if (p_month == null) {
88 this.gMonthName = null;
92 this.gMonthName = Calendar.get_month(p_month);
93 this.gMonth = new Number(p_month);
98 this.gFormat = p_format;
99 this.gBGColor = "white";
100 this.gFGColor = "black";
101 this.gTextColor = "black";
102 this.gHeaderColor = "black";
103 this.gReturnItem = p_item;
106 Calendar.get_month = Calendar_get_month;
107 Calendar.get_daysofmonth = Calendar_get_daysofmonth;
108 Calendar.calc_month_year = Calendar_calc_month_year;
109 Calendar.print = Calendar_print;
111 function Calendar_get_month(monthNo) {
112 return Calendar.Months[monthNo];
115 function Calendar_get_daysofmonth(monthNo, p_year) {
117 Check for leap year ..
118 1.Years evenly divisible by four are normally leap years, except for...
119 2.Years also evenly divisible by 100 are not leap years, except for...
120 3.Years also evenly divisible by 400 are leap years.
122 if ((p_year % 4) == 0) {
123 if ((p_year % 100) == 0 && (p_year % 400) != 0)
124 return Calendar.DOMonth[monthNo];
126 return Calendar.lDOMonth[monthNo];
128 return Calendar.DOMonth[monthNo];
131 function Calendar_calc_month_year(p_Month, p_Year, incr) {
133 Will return an 1-D array with 1st element being the calculated month
134 and second being the calculated year
135 after applying the month increment/decrement as specified by 'incr' parameter.
136 'incr' will normally have 1/-1 to navigate thru the months.
138 var ret_arr = new Array();
144 ret_arr[1] = parseInt(p_Year) - 1;
147 ret_arr[0] = parseInt(p_Month) - 1;
148 ret_arr[1] = parseInt(p_Year);
150 } else if (incr == 1) {
154 ret_arr[1] = parseInt(p_Year) + 1;
157 ret_arr[0] = parseInt(p_Month) + 1;
158 ret_arr[1] = parseInt(p_Year);
165 function Calendar_print() {
169 function Calendar_calc_month_year(p_Month, p_Year, incr) {
171 Will return an 1-D array with 1st element being the calculated month
172 and second being the calculated year
173 after applying the month increment/decrement as specified by 'incr' parameter.
174 'incr' will normally have 1/-1 to navigate thru the months.
176 var ret_arr = new Array();
182 ret_arr[1] = parseInt(p_Year) - 1;
185 ret_arr[0] = parseInt(p_Month) - 1;
186 ret_arr[1] = parseInt(p_Year);
188 } else if (incr == 1) {
192 ret_arr[1] = parseInt(p_Year) + 1;
195 ret_arr[0] = parseInt(p_Month) + 1;
196 ret_arr[1] = parseInt(p_Year);
203 // This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
206 Calendar.prototype.getMonthlyCalendarCode = function() {
208 var vHeader_Code = "";
211 // Begin Table Drawing code here..
212 vCode = vCode + "<TABLE CELLSPACING=0 CELPADDING=0 BORDER=0 BGCOLOR=#336699 WIDTH=100% ALIGN=center><TR><TD><TABLE ALIGN=CENTER BORDER=0 CELLSPACING=2 CELPADDING=0 WIDTH=100%>";
214 vHeader_Code = this.cal_header();
215 vData_Code = this.cal_data();
216 vCode = vCode + vHeader_Code + vData_Code;
218 vCode = vCode + "</TABLE></TR></TD></TABLE>";
223 Calendar.prototype.show = function() {
226 this.gWinCal.document.open();
229 this.wwrite("<html>");
230 this.wwrite("<head><title>Calendario</title>");
231 this.wwrite("</head><style type=text/css>.sin_subrayar { text-decoration: none}</style>");
233 this.wwrite("<body " +
234 "link=\"" + this.gLinkColor + "\" " +
235 "bgcolor=\"" + this.gBackGroundColor + "\" " +
236 "vlink=\"" + this.gLinkColor + "\" " +
237 "alink=\"" + this.gLinkColor + "\" " +
238 "text=\"" + this.gTextColor + "\">");
240 // Show navigation buttons
241 var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
242 var prevMM = prevMMYYYY[0];
243 var prevYYYY = prevMMYYYY[1];
245 var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
246 var nextMM = nextMMYYYY[0];
247 var nextYYYY = nextMMYYYY[1];
249 this.wwrite("<BR><TABLE WIDTH=100% ALIGN=center BORDER=0 BGCOLOR=#336699 CELLPADDING=0 CELLSPACING=0><TR><TD><TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0 ALIGN=center width=100%><TR><TD ALIGN=center BGCOLOR=#DDEEFF>");
250 this.wwrite("<font face='"+fontface+"' size=2><B><A class=sin_subrayar HREF=\"" +
251 "javascript:window.opener.Build(" +
252 "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
254 "\"><<</B><\/A></font></TD><TD ALIGN=center BGCOLOR=#DDEEFF>");
255 this.wwrite("<font face='"+fontface+"' size=2><B><A class=sin_subrayar HREF=\"" +
256 "javascript:window.opener.Build(" +
257 "'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
259 "\"><<\/A></B></font></TD><TD ALIGN=center BGCOLOR=#DDEEFF>");
260 this.wwrite("<font face='"+fontface+"' size=2>");
262 this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2 color=#336699><B>");
263 this.wwriteA(this.gMonthName + " " + this.gYear);
264 this.wwriteA("</B>");
266 this.wwrite("</font></TD><TD ALIGN=center BGCOLOR=#DDEEFF>");
267 this.wwrite("<font face='"+fontface+"' size=2><B><A class=sin_subrayar HREF=\"" +
268 "javascript:window.opener.Build(" +
269 "'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
271 "\">><\/A></B></font></TD><TD ALIGN=center BGCOLOR=#DDEEFF>");
272 this.wwrite("<font face='"+fontface+"' size=2><B><A class=sin_subrayar HREF=\"" +
273 "javascript:window.opener.Build(" +
274 "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
276 "\">>><\/A></B></font></TD></TR></TABLE></TD></TR></TABLE><BR>");
278 // Get the complete calendar code for the month..
279 vCode = this.getMonthlyCalendarCode();
282 this.wwrite("</font></body></html>");
283 this.gWinCal.document.close();
286 Calendar.prototype.showY = function() {
289 var vr, vc, vx, vy; // Row, Column, X-coord, Y-coord
290 var vxf = 285; // X-Factor
291 var vyf = 200; // Y-Factor
292 var vxm = 10; // X-margin
295 else if (isNav) vym = 25;
297 this.gWinCal.document.open();
299 this.wwrite("<html>");
300 this.wwrite("<head><title>Calendar</title>");
301 this.wwrite("<style type='text/css'>\n<!--");
302 for (i=0; i<12; i++) {
304 if (i>=0 && i<= 2) vr = 0;
305 if (i>=3 && i<= 5) vr = 1;
306 if (i>=6 && i<= 8) vr = 2;
307 if (i>=9 && i<= 11) vr = 3;
309 vx = parseInt(vxf * vc) + vxm;
310 vy = parseInt(vyf * vr) + vym;
312 this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
314 this.wwrite("-->\n</style>");
315 this.wwrite("</head>");
317 this.wwrite("<body " +
318 "link=\"" + this.gLinkColor + "\" " +
319 "vlink=\"" + this.gLinkColor + "\" " +
320 "alink=\"" + this.gLinkColor + "\" " +
321 "text=\"" + this.gTextColor + "\">");
322 this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
323 this.wwrite("Year : " + this.gYear);
324 this.wwrite("</B><BR>");
326 // Show navigation buttons
327 var prevYYYY = parseInt(this.gYear) - 1;
328 var nextYYYY = parseInt(this.gYear) + 1;
330 this.wwrite("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
331 this.wwrite("[<A HREF=\"" +
332 "javascript:window.opener.Build(" +
333 "'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
335 "\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
336 this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
337 this.wwrite("[<A HREF=\"" +
338 "javascript:window.opener.Build(" +
339 "'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
341 "\">>><\/A>]</TD></TR></TABLE><BR>");
343 // Get the complete calendar code for each month..
345 for (i=11; i>=0; i--) {
347 this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
349 this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
352 this.gMonthName = Calendar.get_month(this.gMonth);
353 vCode = this.getMonthlyCalendarCode();
354 this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
358 this.wwrite("</DIV>");
360 this.wwrite("</LAYER>");
363 this.wwrite("</font><BR></body></html>");
364 this.gWinCal.document.close();
367 Calendar.prototype.wwrite = function(wtext) {
368 this.gWinCal.document.writeln(wtext);
371 Calendar.prototype.wwriteA = function(wtext) {
372 this.gWinCal.document.write(wtext);
375 Calendar.prototype.cal_header = function() {
378 vCode = vCode + "<TR>";
379 vCode = vCode + "<TD ALIGN=center WIDTH='14%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Dom</B></FONT></TD>";
380 vCode = vCode + "<TD ALIGN=center WIDTH='14%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Lun</B></FONT></TD>";
381 vCode = vCode + "<TD ALIGN=center WIDTH='14%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mar</B></FONT></TD>";
382 vCode = vCode + "<TD ALIGN=center WIDTH='14%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mie</B></FONT></TD>";
383 vCode = vCode + "<TD ALIGN=center WIDTH='14%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Jue</B></FONT></TD>";
384 vCode = vCode + "<TD ALIGN=center WIDTH='14%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Vie</B></FONT></TD>";
385 vCode = vCode + "<TD ALIGN=center WIDTH='16%' BGCOLOR='#336699'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sab</B></FONT></TD>";
386 vCode = vCode + "</TR>";
391 Calendar.prototype.cal_data = function() {
392 var vDate = new Date();
394 vDate.setMonth(this.gMonth);
395 vDate.setFullYear(this.gYear);
397 var vFirstDay=vDate.getDay();
399 var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
404 Get day for the 1st of the requested month/year..
405 Place as many blank cells before the 1st day of the month as necessary.
408 vCode = vCode + "<TR>";
409 for (i=0; i<vFirstDay; i++) {
410 vCode = vCode + "<TD ALIGN=center BGCOLOR=#FFFFFF WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
413 // Write rest of the 1st week
414 for (j=vFirstDay; j<7; j++) {
415 vCode = vCode + "<TD ALIGN=center WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
417 "onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
418 this.format_data(vDay) +
419 "';self.opener.document." + this.gReturnItem + "H.value='"+this.format_data(vDay)+"';window.close();\">" +
420 this.format_day(vDay) +
425 vCode = vCode + "</TR>";
427 // Write the rest of the weeks
428 for (k=2; k<7; k++) {
429 vCode = vCode + "<TR>";
431 for (j=0; j<7; j++) {
432 vCode = vCode + "<TD ALIGN=center WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
434 "onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
435 this.format_data(vDay) +
436 "';self.opener.document." + this.gReturnItem + "H.value='"+this.format_data(vDay)+"';window.close();\">" +
437 this.format_day(vDay) +
442 if (vDay > vLastDay) {
449 vCode = vCode + "</TR>";
454 // Fill up the rest of last week with proper blanks, so that we get proper square blocks
455 for (m=1; m<(7-j); m++) {
457 vCode = vCode + "<TD ALIGN=center WIDTH='14%'" + this.write_weekend_string(j+m) +
458 "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
460 vCode = vCode + "<TD ALIGN=center WIDTH='14%'" + this.write_weekend_string(j+m) +
461 "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
467 Calendar.prototype.format_day = function(vday) {
468 var vNowDay = gNow.getDate();
469 var vNowMonth = gNow.getMonth();
470 var vNowYear = gNow.getFullYear();
472 if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
473 return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
478 Calendar.prototype.write_weekend_string = function(vday) {
481 // Return special formatting for the weekend day.
482 for (i=0; i<weekend.length; i++) {
483 if (vday == weekend[i])
484 return (" BGCOLOR=\"" + weekendColor + "\"");
487 return (" BGCOLOR='#FFFFFF'");
490 Calendar.prototype.format_data = function(p_day) {
492 var vMonth = 1 + this.gMonth;
493 vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
494 var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
495 var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
496 var vY4 = new String(this.gYear);
497 var vY2 = new String(this.gYear.substr(2,2));
498 var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
500 switch (this.gFormat) {
501 case "MM\/DD\/YYYY" :
502 vData = vMonth + "\/" + vDD + "\/" + vY4;
505 vData = vMonth + "\/" + vDD + "\/" + vY2;
508 vData = vMonth + "-" + vDD + "-" + vY4;
511 vData = vMonth + "-" + vDD + "-" + vY2;
514 case "DD\/MON\/YYYY" :
515 vData = vDD + "\/" + vMon + "\/" + vY4;
518 vData = vDD + "\/" + vMon + "\/" + vY2;
521 vData = vDD + "-" + vMon + "-" + vY4;
524 vData = vDD + "-" + vMon + "-" + vY2;
527 case "DD\/MONTH\/YYYY" :
528 vData = vDD + "\/" + vFMon + "\/" + vY4;
530 case "DD\/MONTH\/YY" :
531 vData = vDD + "\/" + vFMon + "\/" + vY2;
533 case "DD-MONTH-YYYY" :
534 vData = vDD + "-" + vFMon + "-" + vY4;
537 vData = vDD + "-" + vFMon + "-" + vY2;
540 case "DD\/MM\/YYYY" :
541 vData = vDD + "\/" + vMonth + "\/" + vY4;
544 vData = vDD + "\/" + vMonth + "\/" + vY2;
547 vData = vDD + "-" + vMonth + "-" + vY4;
550 vData = vDD + "-" + vMonth + "-" + vY2;
554 vData = vMonth + "\/" + vDD + "\/" + vY4;
560 function Build(p_item, p_month, p_year, p_format) {
561 var p_WinCal = ggWinCal;
562 gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);
564 // Customize your Calendar here..
565 gCal.gBGColor="white";
566 gCal.gBackGroundColor="white";
567 gCal.gLinkColor="black";
568 gCal.gTextColor="black";
569 gCal.gHeaderColor="#FFFFFF";
571 // Choose appropriate show function
572 if (gCal.gYearly) gCal.showY();
576 function show_calendar() {
578 p_month : 0-11 for Jan-Dec; 12 for All Months.
579 p_year : 4-digit year
580 p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
581 p_item : Return Item.
584 p_item = arguments[0];
585 if (arguments[1] == null)
586 p_month = new String(gNow.getMonth());
588 p_month = arguments[1];
589 if (arguments[2] == "" || arguments[2] == null)
590 p_year = new String(gNow.getFullYear().toString());
592 p_year = arguments[2];
593 if (arguments[3] == null)
594 p_format = "DD/MM/YYYY";
596 p_format = arguments[3];
598 vWinCal = window.open("", "Calendar",
599 "width=250,height=250,status=no,resizable=no,top=200,left=200");
600 vWinCal.opener = self;
603 Build(p_item, p_month, p_year, p_format);
606 Yearly Calendar Code Starts here
608 function show_yearly_calendar(p_item, p_year, p_format) {
609 // Load the defaults..
610 if (p_year == null || p_year == "")
611 p_year = new String(gNow.getFullYear().toString());
612 if (p_format == null || p_format == "")
613 p_format = "MM/DD/YYYY";
615 var vWinCal = window.open("", "Calendar", "scrollbars=yes");
616 vWinCal.opener = self;
619 Build(p_item, null, p_year, p_format);