/* ************************************************************************ Softricks Popup Date Picker Calendar Author : Kedar R. Bhave # ************************************************************************* # COPYRIGHT NOTICE # Copyright (c) 2000-2001 Softricks.com, All rights reserved. # This script may be used and modified free of charge for Non-profit purposes # by anyone as long as this copyright notice and the comments above are kept # in their original form. By using this script, you agree to the disclaimer # notices as on the softricks.com site. # # Selling the code for this script, without prior written consent of the # author, is not allowed. Redistributing this script over the internet or # in any medium should be done only with author's written permission. # # IN ALL CASES COPYRIGHT AND HEADERS MUST REMAIN INTACT. # # If you plan to use the script on a commercial site/application, you should # notify the author and verify the licensing terms. # # Distributed under the GNU Lesser General Public License (GNU LGPL). # For more information visit: http://www.gnu.org/copyleft/lesser.html # # Visit the website for more information on Softricks.com's Copyright, # Privacy, Disclaimer and Terms of use policies. ************************************************************************ */ function name_values(instring) { // Assumption: ';' is a restricted character in a value. // Returns an array of variable names set by this function. var vars = new Array(); rc = "\235"; instring = instring.replace(/\\\;/g, rc); var pattern = /[a-zA-Z0-9]+\=[\/:#a-zA-Z0-9\-\+\. \235]+/gi; var y = instring.match(pattern); for (i=0; i 5) return dateAdd(td, m[4], m[3]); else if (m[1].toUpperCase() == "TODAY") return td; } else return vInputData; } // Custom parameters set by the 6th argument to show_calendar function. // CUSTOM STRING var v_CloseOnSelect, v_AppendOrReplace, v_AppendChar, v_ReturnData; var v_InlineX, v_InlineY, v_Title, v_CurrentDate, v_AllowWeekends; var v_Resizable, v_Width, v_Height, v_SelectAfter, v_NSHierarchy; var v_SelectBefore, v_CallFunction, v_PopupX, v_PopupY; var v_Nav, v_SmartNav, v_Fix; var weekend = [0,6]; var weekendColor = "#e0e0e0"; var fontface = "Arial,helvetica,Courier New"; var fontsize = 2; var gNow = new Date(); var ggWinCal; // Really global variable pointing to the calendar window // Drag-n-Drop Variables var theLayer; var theLayerStyle; // Style used for positioning in IE. var currX, currY; var cx, cy; // Client co-ords var x, y; // Co-ords of the point at first click var incrX, incrY; var mDown, mUp; // ----------- VARIABLE DECLARATIONS END ----------- // Browser Detection isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false; isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false; isDOM = (document.getElementById) ? true : false; // Month names in YOUR Language (French/Spanish..) Calendar.EMonths = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]; // Month names in English Calendar.EMonths = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]; // Non-Leap year Month days.. Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // Leap year Month days.. Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; Calendar.DOW = ["S", "M", "D", "M", "D", "F", "S"]; Calendar.count = 0; // For inline calendar, the default contents of the layer. (v1.3) Calendar.gInitText = "Softricks.com Calendar"; function Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type) { // Argument p_type defines if the calendar is popup or inline // If p_type is INLINE, // you must pass p_inline parameter which specifies the name of the layer // which displays the calendar inline. // ---> if ((p_month == null) && (p_year == null)) return; if (p_WinCal == null) this.gWinCal = ggWinCal; else this.gWinCal = p_WinCal; if (p_month == null) { this.gMonthName = null; this.gMonth = null; this.gYearly = true; } else { this.gMonthName = Calendar.get_month(p_month); this.gMonth = new Number(p_month); this.gYearly = false; } if (p_type == null) this.gType = "POPUP"; // Default is popup else this.gType = p_type; if (this.gType == "INLINE") { this.WHO = ""; this.INLINE = "Calendar"; // Inline Calendar Layer name this.codeINLINE = ""; // Calendar code will be constructed in this var } else this.WHO = "window.opener."; this.gYear = p_year; this.gFormat = p_format; this.gBGColor = "white"; this.gFGColor = "black"; this.gTextColor = "black"; this.gHeaderColor = "black"; this.gReturnItem = p_item; this.gTitle = "Softricks.com Calendar"; } Calendar.get_month = Calendar_get_month; Calendar.get_daysofmonth = Calendar_get_daysofmonth; Calendar.get_dow = Calendar_get_dow; Calendar.calc_month_year = Calendar_calc_month_year; Calendar.print = Calendar_print; Calendar.CreateCalendarLayer = Calendar_CreateCalendarLayer; Calendar.Close = Calendar_Close; Calendar.Lwwrite = Calendar_Lwwrite; Calendar.MoveTo = Calendar_MoveTo; Calendar.isWeekend = Calendar_isWeekend; function Calendar_get_month(monthNo, pLanguage) { if (!pLanguage || pLanguage=="E") return Calendar.EMonths[monthNo]; else return Calendar.Months[monthNo]; } function Calendar_get_dow(dayNo) { return Calendar.DOW[dayNo]; } function Calendar_get_daysofmonth(monthNo, p_year) { /* Check for leap year .. 1.Years evenly divisible by four are normally leap years, except for... 2.Years also evenly divisible by 100 are not leap years, except for... 3.Years also evenly divisible by 400 are leap years. */ if ((p_year % 4) == 0) { if ((p_year % 100) == 0 && (p_year % 400) != 0) return Calendar.DOMonth[monthNo]; return Calendar.lDOMonth[monthNo]; } else return Calendar.DOMonth[monthNo]; } function Calendar_calc_month_year(p_Month, p_Year, incr) { /* Will return an 1-D array with 1st element being the calculated month and second being the calculated year after applying the month increment/decrement as specified by 'incr' parameter. 'incr' will normally have 1/-1 to navigate thru the months. */ var ret_arr = new Array(); if (incr == -1) { // B A C K W A R D if (p_Month == 0) { ret_arr[0] = 11; ret_arr[1] = parseInt(p_Year) - 1; } else { ret_arr[0] = parseInt(p_Month) - 1; ret_arr[1] = parseInt(p_Year); } } else if (incr == 1) { // F O R W A R D if (p_Month == 11) { ret_arr[0] = 0; ret_arr[1] = parseInt(p_Year) + 1; } else { ret_arr[0] = parseInt(p_Month) + 1; ret_arr[1] = parseInt(p_Year); } } return ret_arr; } function Calendar_print() { ggWinCal.print(); } function Calendar_isWeekend(pday) { var i; for (i=0; i"; vHeader_Code = this.cal_header(); vData_Code = this.cal_data(); vCode = vCode + vHeader_Code + vData_Code; vCode = vCode + ""; return vCode; } Calendar.prototype.onclickfn = function() { // This should return the code string for the onclickfn in the calendar document. // This is the reference to the return object // window.opener.document. / window.document. ... .value var whois = this.WHO + ((this.gType == "POPUP") ? "document." + v_NSHierarchy : "window.document." + v_NSHierarchy) + this.gReturnItem + ".value"; // apchar will turn out to be either " = " or " += ''" or " += ';'" var apchar = (this.returnMode == "Replace") ? " = " : " += "; var retCode = "apchar = ''" + ((this.returnMode == "Replace") ? ";" : " + ") + "((" + whois + " == '') ? '' : '" + this.appendChar + "');\n" + whois + apchar + "apchar + pday;\n"; return retCode; } Calendar.prototype.showSmartNavBar = function() { var selcalendar = "
"; selcalendar += "
"; this.wwrite(selcalendar); } Calendar.prototype.show = function() { var vCode = ""; if (this.gType == "POPUP") this.gWinCal.document.open(); // Setup the page... this.wwrite(""); this.wwrite("Calendar"); if (this.gType == "POPUP") this.wwrite("