1/* XXXXXXXXXXXXXXXXXXXXXXXX 2 3CalendarPopup.js requiert les fichiers suivants inline, � la fin de cette source: 4 5 6XXXXXXXXXXXXXXXXXXXXXXXXX*/ 7 8// =================================================================== 9// Author: Matt Kruse <[email protected]> 10// WWW: http://www.mattkruse.com/ 11// 12// NOTICE: You may use this code for any purpose, commercial or 13// private, without any further permission from the author. You may 14// remove this notice from your final code if you wish, however it is 15// appreciated by the author if at least my web site address is kept. 16// 17// You may *NOT* re-distribute this code in any way except through its 18// use. That means, you can include it in your product, or your web 19// site, or any other form where the code is actually being used. You 20// may not put the plain javascript up on your site for download or 21// include it in your javascript libraries for download. 22// If you wish to share this code with others, please just point them 23// to the URL instead. 24// Please DO NOT link directly to my .js files from your site. Copy 25// the files to your server and use them there. Thank you. 26// =================================================================== 27 28// HISTORY 29// ------------------------------------------------------------------ 30// March 29, 2004: Added check in select() method for the form field 31// being disabled. If it is, just return and don't do anything. 32// March 24, 2004: Fixed bug - when month name and abbreviations were 33// changed, date format still used original values.
34// January 26, 2004: Added support for drop-down month and year 35// navigation (Thanks to Chris Reid for the idea) 36// September 22, 2003: Fixed a minor problem in YEAR calendar with 37// CSS prefix. 38// August 19, 2003: Renamed the function to get styles, and made it 39// work correctly without an object reference 40// August 18, 2003: Changed showYearNavigation and 41// showYearNavigationInput to optionally take an argument of 42// true or false 43// July 31, 2003: Added text input option for year navigation. 44// Added a per-calendar CSS prefix option to optionally use 45// different styles for different calendars. 46// July 29, 2003: Fixed bug causing the Today link to be clickable 47// even though today falls in a disabled date range. 48// Changed formatting to use pure CSS, allowing greater control 49// over look-and-feel options. 50// June 11, 2003: Fixed bug causing the Today link to be unselectable 51// under certain cases when some days of week are disabled 52// March 14, 2003: Added ability to disable individual dates or date 53// ranges, display as light gray and strike-through 54// March 14, 2003: Removed dependency on graypixel.gif and instead 55/// use table border coloring 56// March 12, 2003: Modified showCalendar() function to allow optional 57// start-date parameter 58// March 11, 2003: Modified select() function to allow optional 59// start-date parameter 60/* 61DESCRIPTION: This object implements a popup calendar to allow the user to 62select a date, month, quarter, or year. 63 64COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small 65positioning errors - usually with Window positioning - occur on the 66Macintosh platform. 67The calendar can be modified to work for any location in the world by 68changing which weekday is displayed as the first column, changing the month 69names, and changing the column headers for each day. 70 71USAGE: 72// Create a new CalendarPopup object of type WINDOW 73var cal = new CalendarPopup(); 74 75// Create a new CalendarPopup object of type DIV using the DIV named 'mydiv' 76var cal = new CalendarPopup('mydiv'); 77 78// Easy method to link the popup calendar with an input box. 79cal.select(inputObject, anchorname, dateFormat); 80// Same method, but passing a default date other than the field's current value 81cal.select(inputObject, anchorname, dateFormat, '01/02/2000'); 82// This is an example call to the popup calendar from a link to populate an 83// input box. Note that to use this, date.js must also be included!! 84<A HREF="#" onClick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A> 85 86// Set the type of date select to be used. By default it is 'date'. 87cal.setDisplayType(type); 88 89// When a date, month, quarter, or year is clicked, a function is called and 90// passed the details. You must write this function, and tell the calendar 91// popup what the function name is. 92// Function to be called for 'date' select receives y, m, d 93cal.setReturnFunction(functionname); 94// Function to be called for 'month' select receives y, m 95cal.setReturnMonthFunction(functionname); 96// Function to be called for 'quarter' select receives y, q 97cal.setReturnQuarterFunction(functionname); 98// Function to be called for 'year' select receives y 99cal.setReturnYearFunction(functionname); 100 101// Show the calendar relative to a given anchor 102cal.showCalendar(anchorname); 103 104// Hide the calendar. The calendar is set to autoHide automatically 105cal.hideCalendar(); 106 107// Set the month names to be used. Default are English month names 108cal.setMonthNames("January","February","March",...); 109 110// Set the month abbreviations to be used. Default are English month abbreviations 111cal.setMonthAbbreviations("Jan","Feb","Mar",...); 112 113// Show navigation for changing by the year, not just one month at a time 114cal.showYearNavigation(); 115 116// Show month and year dropdowns, for quicker selection of month of dates 117cal.showNavigationDropdowns(); 118 119// Set the text to be used above each day column. The days start with 120// sunday regardless of the value of WeekStartDay 121cal.setDayHeaders("S","M","T",...); 122 123// Set the day for the first column in the calendar grid. By default this 124// is Sunday (0) but it may be changed to fit the conventions of other 125// countries. 126cal.setWeekStartDay(1); // week is Monday - Saturday 127 128// Set the weekdays which should be disabled in the 'date' select popup. You can 129// then allow someone to only select week end dates, or Tuedays, for example 130cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week 131 132// Selectively disable individual days or date ranges. Disabled days will not 133// be clickable, and show as strike-through text on current browsers. 134// Date format is any format recognized by parseDate() in date.js 135// Pass a single date to disable: 136cal.addDisabledDates("2003-01-01"); 137// Pass null as the first parameter to mean "anything up to and including" the 138// passed date: 139cal.addDisabledDates(null, "01/02/03"); 140// Pass null as the second parameter to mean "including the passed date and 141// anything after it: 142cal.addDisabledDates("Jan 01, 2003", null); 143// Pass two dates to disable all dates inbetween and including the two 144cal.addDisabledDates("January 01, 2003", "Dec 31, 2003"); 145 146// When the 'year' select is displayed, set the number of years back from the 147// current year to start listing years. Default is 2. 148// This is also used for year drop-down, to decide how many years +/- to display 149cal.setYearSelectStartOffset(2); 150 151// Text for the word "Today" appearing on the calendar 152cal.setTodayText("Today"); 153 154// The calendar uses CSS classes for formatting. If you want your calendar to 155// have unique styles, you can set the prefix that will be added to all the 156// classes in the output. 157// For example, normal output may have this: 158// <SPAN CLASS="cpTodayTextDisabled">Today<SPAN> 159// But if you set the prefix like this: 160cal.setCssPrefix("Test"); 161// The output will then look like: 162// <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN> 163// And you can define that style somewhere in your page. 164 165// When using Year navigation, you can make the year be an input box, so 166// the user can manually change it and jump to any year 167cal.showYearNavigationInput(); 168 169// Set the calendar offset to be different than the default. By default it
170// will appear just below and to the right of the anchorname. So if you have 171// a text box where the date will go and and anchor immediately after the 172// text box, the calendar will display immediately under the text box. 173cal.offsetX = 20; 174cal.offsetY = 20; 175 176NOTES: 1771) Requires the functions in AnchorPosition.js and PopupWindow.js 178 1792) Your anchor tag MUST contain both NAME and ID attributes which are the 180 same. For example: 181 <A NAME="test" ID="test"> </A> 182 1833) There must be at least a space between <A> </A> for IE5.5 to see the 184 anchor tag correctly. Do not do <A></A> with no space. 185 1864) When a CalendarPopup object is created, a handler for 'onmouseup' is 187 attached to any event handler you may have already defined. Do NOT define 188 an event handler for 'onmouseup' after you define a CalendarPopup object 189 or the autoHide() will not work correctly. 190 1915) The calendar popup display uses style sheets to make it look nice. 192 193*/ 194 195// CONSTRUCTOR for the CalendarPopup Object 196function CalendarPopup() { 197 var c; 198 if (arguments.length>0) { 199 c = new PopupWindow(arguments[0]); 200 } 201 else { 202 c = new PopupWindow(); 203 c.setSize(150,175); 204 } 205 c.offsetX = -152; 206 c.offsetY = 25; 207 c.autoHide(); 208 // Calendar-specific properties 209 c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 210 c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); 211 c.dayHeaders = new Array("S","M","T","W","T","F","S"); 212 c.returnFunction = "CP_tmpReturnFunction"; 213 c.returnMonthFunction = "CP_tmpReturnMonthFunction"; 214 c.returnQuarterFunction = "CP_tmpReturnQuarterFunction"; 215 c.returnYearFunction = "CP_tmpReturnYearFunction"; 216 c.weekStartDay = 0; 217 c.isShowYearNavigation = false; 218 c.displayType = "date"; 219 c.disabledWeekDays = new Object(); 220 c.disabledDatesExpression = ""; 221 c.yearSelectStartOffset = 2; 222 c.currentDate = null; 223 c.todayText="Today"; 224 c.cssPrefix=""; 225 c.isShowNavigationDropdowns=false; 226 c.isShowYearNavigationInput=false; 227 window.CP_calendarObject = null; 228 window.CP_targetInput = null; 229 window.CP_dateFormat = "MM/dd/yyyy"; 230 // Method mappings 231 c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow; 232 c.setReturnFunction = CP_setReturnFunction; 233 c.setReturnMonthFunction = CP_setReturnMonthFunction; 234 c.setReturnQuarterFunction = CP_setReturnQuarterFunction; 235 c.setReturnYearFunction = CP_setReturnYearFunction; 236 c.setMonthNames = CP_setMonthNames; 237 c.setMonthAbbreviations = CP_setMonthAbbreviations; 238 c.setDayHeaders = CP_setDayHeaders; 239 c.setWeekStartDay = CP_setWeekStartDay; 240 c.setDisplayType = CP_setDisplayType; 241 c.setDisabledWeekDays = CP_setDisabledWeekDays; 242 c.addDisabledDates = CP_addDisabledDates; 243 c.setYearSelectStartOffset = CP_setYearSelectStartOffset; 244 c.setTodayText = CP_setTodayText; 245 c.showYearNavigation = CP_showYearNavigation; 246 c.showCalendar = CP_showCalendar; 247 c.hideCalendar = CP_hideCalendar; 248 c.getStyles = getCalendarStyles; 249 c.refreshCalendar = CP_refreshCalendar; 250 c.getCalendar = CP_getCalendar; 251 c.select = CP_select; 252 c.setCssPrefix = CP_setCssPrefix; 253 c.showNavigationDropdowns = CP_showNavigationDropdowns; 254 c.showYearNavigationInput = CP_showYearNavigationInput; 255 c.copyMonthNamesToWindow(); 256 // Return the object 257 return c; 258 } 259function CP_copyMonthNamesToWindow() { 260 // Copy these values over to the date.js 261 if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) { 262 window.MONTH_NAMES = new Array(); 263 for (var i=0; i<this.monthNames.length; i++) { 264 window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i]; 265 } 266 for (var i=0; i<this.monthAbbreviations.length; i++) { 267 window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i]; 268 } 269 } 270} 271// Temporary default functions to be called when items clicked, so no error is thrown 272function CP_tmpReturnFunction(y,m,d) { 273 if (window.CP_targetInput!=null) { 274 var dt = new Date(y,m-1,d,0,0,0); 275 if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); } 276 window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat); 277 } 278 else { 279 alert('Use setReturnFunction() to define which function will get the clicked results!'); 280 } 281 } 282function CP_tmpReturnMonthFunction(y,m) { 283 alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 284 } 285function CP_tmpReturnQuarterFunction(y,q) { 286 alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 287 } 288function CP_tmpReturnYearFunction(y) { 289 alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 290 } 291 292// Set the name of the functions to call to get the clicked item 293function CP_setReturnFunction(name) { this.returnFunction = name; } 294function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; } 295function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; } 296function CP_setReturnYearFunction(name) { this.returnYearFunction = name; } 297 298// Over-ride the built-in month names 299function CP_setMonthNames() { 300 for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; } 301 this.copyMonthNamesToWindow(); 302 } 303 304// Over-ride the built-in month abbreviations 305function CP_setMonthAbbreviations() { 306 for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; } 307 this.copyMonthNamesToWindow(); 308 } 309 310// Over-ride the built-in column headers for each day 311function CP_setDayHeaders() { 312 for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; } 313 } 314 315// Set the day of the week (0-7) that the calendar display starts on 316// This is for countries other than the US whose calendar displays start on Monday(1), for example 317function CP_setWeekStartDay(day) { this.weekStartDay = day; } 318 319// Show next/last year navigation links 320function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; } 321 322// Which type of calendar to display 323function CP_setDisplayType(type) { 324 if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; } 325 this.displayType=type; 326 } 327 328// How many years back to start by default for year display 329function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; } 330 331// Set which weekdays should not be clickable 332function CP_setDisabledWeekDays() { 333 this.disabledWeekDays = new Object(); 334 for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; } 335 } 336 337// Disable individual dates or ranges 338// Builds an internal logical test which is run via eval() for efficiency 339function CP_addDisabledDates(start, end) { 340 if (arguments.length==1) { end=start; } 341 if (start==null && end==null) { return; } 342 if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; } 343 if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());} 344 if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());} 345 if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; } 346 else if (end ==null) { this.disabledDatesExpression+="(ds>="+start+")"; } 347 else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; } 348 } 349 350// Set the text to use for the "Today" link 351function CP_setTodayText(text) { 352 this.todayText = text; 353 } 354 355// Set the prefix to be added to all CSS classes when writing output 356function CP_setCssPrefix(val) { 357 this.cssPrefix = val; 358 } 359 360// Show the navigation as an dropdowns that can be manually changed 361function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; } 362 363// Show the year navigation as an input box that can be manually changed 364function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; } 365 366// Hide a calendar object
367function CP_hideCalendar() { 368 if (arguments.length > 0) { window.popupWindowObjects[arguments[0]].hidePopup(); } 369 else { this.hidePopup(); } 370 } 371 372// Refresh the contents of the calendar display 373function CP_refreshCalendar(index) { 374 var calObject = window.popupWindowObjects[index]; 375 if (arguments.length>1) { 376 calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5])); 377 } 378 else { 379 calObject.populate(calObject.getCalendar()); 380 } 381 calObject.refresh(); 382 } 383 384// Populate the calendar and display it 385function CP_showCalendar(anchorname) { 386 if (arguments.length>1) { 387 if (arguments[1]==null||arguments[1]=="") { 388 this.currentDate=new Date(); 389 } 390 else { 391 this.currentDate=new Date(parseDate(arguments[1])); 392 } 393 } 394 this.populate(this.getCalendar()); 395 this.showPopup(anchorname); 396 } 397 398// Simple method to interface popup calendar with a text-entry box 399function CP_select(inputobj, linkname, format) { 400 var selectedDate=(arguments.length>3)?arguments[3]:null; 401 if (!window.getDateFromFormat) { 402 alert("calendar.select: To use this method you must also include 'date.js' for date formatting"); 403 return; 404 } 405 if (this.displayType!="date"&&this.displayType!="week-end") { 406 alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'"); 407 return; 408 } 409 if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 410 alert("calendar.select: Input object passed is not a valid form input object"); 411 window.CP_targetInput=null; 412 return; 413 } 414 if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input! 415 window.CP_targetInput = inputobj; 416 window.CP_calendarObject = this; 417 this.currentDate=null; 418 var time=0; 419 if (selectedDate!=null) { 420 time = getDateFromFormat(selectedDate,format) 421 } 422 else if (inputobj.value!="") { 423 time = getDateFromFormat(inputobj.value,format); 424 } 425 if (selectedDate!=null || inputobj.value!="") { 426 if (time==0) { this.currentDate=null; } 427 else { this.currentDate=new Date(time); } 428 } 429 window.CP_dateFormat = format; 430 this.showCalendar(linkname); 431 } 432 433// Get style block needed to display the calendar correctly 434function getCalendarStyles() { 435 var result = ""; 436 var p = ""; 437 if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; } 438 result += "<STYLE>\n"; 439 result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n"; 440 result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n"; 441 result += "TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0 0 1 0; }\n"; 442 result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate { text-align:right; text-decoration:none; }\n"; 443 result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n"; 444 result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n"; 445 result += "."+p+"cpOtherMonthDate { color:#808080; }\n"; 446 result += "TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1; border:solid thin #800000; }\n"; 447 result += "TD."+p+"cpCurrentDateDisabled { border-width:1; border:solid thin #FFAAAA; }\n"; 448 result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1 0 0 0;}\n"; 449 result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n"; 450 result += "A."+p+"cpTodayText { color:black; }\n"; 451 result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n"; 452 result += "."+p+"cpBorder { border:solid thin #808080; }\n"; 453 result += "</STYLE>\n"; 454 return result; 455 } 456 457// Return a string containing all the calendar code to be displayed
458function CP_getCalendar() { 459 var now = new Date(); 460 // Reference to window 461 if (this.type == "WINDOW") { var windowref = "window.opener."; } 462 else { var windowref = ""; } 463 var result = ""; 464 // If POPUP, write entire HTML document 465 if (this.type == "WINDOW") { 466 result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n"; 467 result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n'; 468 } 469 else { 470 result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n'; 471 result += '<TR><TD ALIGN=CENTER>\n'; 472 result += '<CENTER>\n'; 473 } 474 // Code for DATE display (default) 475 // ------------------------------- 476 if (this.displayType=="date" || this.displayType=="week-end") { 477 if (this.currentDate==null) { this.currentDate = now; } 478 if (arguments.length > 0) { var month = arguments[0]; } 479 else { var month = this.currentDate.getMonth()+1; } 480 if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; } 481 else { var year = this.currentDate.getFullYear(); } 482 var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31); 483 if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) { 484 daysinmonth[2] = 29; 485 } 486 var current_month = new Date(year,month-1,1); 487 var display_year = year; 488 var display_month = month; 489 var display_date = 1; 490 var weekday= current_month.getDay(); 491 var offset = 0; 492 493 offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ; 494 if (offset > 0) { 495 display_month--; 496 if (display_month < 1) { display_month = 12; display_year--; } 497 display_date = daysinmonth[display_month]-offset+1; 498 }
499 var next_month = month+1; 500 var next_month_year = year; 501 if (next_month > 12) { next_month=1; next_month_year++; } 502 var last_month = month-1; 503 var last_month_year = year; 504 if (last_month < 1) { last_month=12; last_month_year--; } 505 var date_class; 506 if (this.type!="WINDOW") { 507 result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>"; 508 } 509 result += '<TR>\n'; 510 var refresh = windowref+'CP_refreshCalendar'; 511 var refreshLink = 'javascript:' + refresh; 512 if (this.isShowNavigationDropdowns) { 513 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">'; 514 for( var monthCounter=1; monthCounter<=12; monthCounter++ ) { 515 var selected = (monthCounter==month) ? 'SELECTED' : ''; 516 result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>'; 517 } 518 result += '</select></TD>'; 519 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>'; 520 521 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">'; 522 for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) { 523 var selected = (yearCounter==year) ? 'SELECTED' : ''; 524 result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>'; 525 } 526 result += '</select></TD>'; 527 } 528 else { 529 if (this.isShowYearNavigation) { 530 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');"><</A></TD>'; 531 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>'; 532 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">></A></TD>'; 533 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"> </TD>'; 534 535 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');"><</A></TD>'; 536 if (this.isShowYearNavigationInput) { 537 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>'; 538 } 539 else { 540 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>'; 541 } 542 result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">></A></TD>'; 543 } 544 else { 545 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');"><<</A></TD>\n'; 546 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n'; 547 result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">>></A></TD>\n'; 548 } 549 } 550 result += '</TR></TABLE>\n'; 551 result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n'; 552 result += '<TR>\n'; 553 for (var j=0; j<7; j++) { 554 555 result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n'; 556 } 557 result += '</TR>\n'; 558 for (var row=1; row<=6; row++) { 559 result += '<TR>\n'; 560 for (var col=1; col<=7; col++) { 561 var disabled=false; 562 if (this.disabledDatesExpression!="") { 563 var ds=""+display_year+LZ(display_month)+LZ(display_date); 564 eval("disabled=("+this.disabledDatesExpression+")"); 565 } 566 var dateClass = ""; 567 if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) { 568 dateClass = "cpCurrentDate"; 569 } 570 else if (display_month == month) { 571 dateClass = "cpCurrentMonthDate"; 572 } 573 else { 574 dateClass = "cpOtherMonthDate"; 575 } 576 if (disabled || this.disabledWeekDays[col-1]) { 577 result += ' <TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n'; 578 } 579 else { 580 var selected_date = display_date; 581 var selected_month = display_month; 582 var selected_year = display_year; 583 if (this.displayType=="week-end") { 584 var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0); 585 d.setDate(d.getDate() + (7-col)); 586 selected_year = d.getYear(); 587 if (selected_year < 1000) { selected_year += 1900; } 588 selected_month = d.getMonth()+1; 589 selected_date = d.getDate(); 590 } 591 result += ' <TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n'; 592 } 593 display_date++; 594 if (display_date > daysinmonth[display_month]) { 595 display_date=1; 596 display_month++; 597 } 598 if (display_month > 12) { 599 display_month=1; 600 display_year++; 601 } 602 } 603 result += '</TR>'; 604 } 605 var current_weekday = now.getDay() - this.weekStartDay; 606 if (current_weekday < 0) { 607 current_weekday += 7; 608 } 609 result += '<TR>\n'; 610 result += ' <TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n'; 611 if (this.disabledDatesExpression!="") { 612 var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate()); 613 eval("disabled=("+this.disabledDatesExpression+")"); 614 } 615 if (disabled || this.disabledWeekDays[current_weekday+1]) { 616 result += ' <SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n'; 617 } 618 else { 619 result += ' <A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">
619'+this.todayText+'</A>\n'; 620 } 621 result += ' <BR>\n'; 622 result += ' </TD></TR></TABLE></CENTER></TD></TR></TABLE>\n'; 623 } 624 625 // Code common for MONTH, QUARTER, YEAR 626 // ------------------------------------ 627 if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") { 628 if (arguments.length > 0) { var year = arguments[0]; } 629 else { 630 if (this.displayType=="year") { var year = now.getFullYear()-this.yearSelectStartOffset; } 631 else { var year = now.getFullYear(); } 632 } 633 if (this.displayType!="year" && this.isShowYearNavigation) { 634 result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>"; 635 result += '<TR>\n'; 636 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');"><<</A></TD>\n'; 637 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n'; 638 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">>></A></TD>\n'; 639 result += '</TR></TABLE>\n'; 640 } 641 } 642 643 // Code for MONTH display 644 // ---------------------- 645 if (this.displayType=="month") { 646 // If POPUP, write entire HTML document 647 result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n'; 648 for (var i=0; i<4; i++) { 649 result += '<TR>'; 650 for (var j=0; j<3; j++) { 651 var monthindex = ((i*3)+j); 652 result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>'; 653 } 654 result += '</TR>'; 655 } 656 result += '</TABLE></CENTER></TD></TR></TABLE>\n'; 657 } 658 659 // Code for QUARTER display 660 // ------------------------ 661 if (this.displayType=="quarter") { 662 result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n'; 663 for (var i=0; i<2; i++) { 664 result += '<TR>'; 665 for (var j=0; j<2; j++) { 666 var quarter = ((i*2)+j+1); 667 result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>'; 668 } 669 result += '</TR>'; 670 } 671 result += '</TABLE></CENTER></TD></TR></TABLE>\n'; 672 } 673 674 // Code for YEAR display 675 // --------------------- 676 if (this.displayType=="year") { 677 var yearColumnSize = 4; 678 result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>"; 679 result += '<TR>\n'; 680 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');"><<</A></TD>\n'; 681 result += ' <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">>></A></TD>\n'; 682 result += '</TR></TABLE>\n'; 683 result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n'; 684 for (var i=0; i<yearColumnSize; i++) { 685 for (var j=0; j<2; j++) { 686 var currentyear = year+(j*yearColumnSize)+i; 687 result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>'; 688 } 689 result += '</TR>'; 690 } 691 result += '</TABLE></CENTER></TD></TR></TABLE>\n'; 692 } 693 // Common 694 if (this.type == "WINDOW") { 695 result += "</BODY></HTML>\n"; 696 } 697 return result; 698 } 699 700/* XXXXXXXXXXXXXXXXXXXXXXXX REQUIRED FILE: AnchorPosition.js XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/ 701 702/* 703AnchorPosition.js 704Author: Matt Kruse 705Last modified: 10/11/02 706 707DESCRIPTION: These functions find the position of an <A> tag in a document, 708so other elements can be positioned relative to it. 709 710COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small 711positioning errors - usually with Window positioning - occur on the 712Macintosh platform. 713 714FUNCTIONS: 715getAnchorPosition(anchorname) 716 Returns an Object() having .x and .y properties of the pixel coordinates
717 of the upper-left corner of the anchor. Position is relative to the PAGE. 718 719getAnchorWindowPosition(anchorname) 720 Returns an Object() having .x and .y properties of the pixel coordinates 721 of the upper-left corner of the anchor, relative to the WHOLE SCREEN. 722 723NOTES: 724 7251) For popping up separate browser windows, use getAnchorWindowPosition. 726 Otherwise, use getAnchorPosition 727 7282) Your anchor tag MUST contain both NAME and ID attributes which are the 729 same. For example: 730 <A NAME="test" ID="test"> </A> 731 7323) There must be at least a space between <A> </A> for IE5.5 to see the 733 anchor tag correctly. Do not do <A></A> with no space. 734*/ 735 736// getAnchorPosition(anchorname) 737// This function returns an object having .x and .y properties which are the coordinates 738// of the named anchor, relative to the page. 739function getAnchorPosition(anchorname) { 740 // This function will return an Object with x and y properties 741 var useWindow=false; 742 var coordinates=new Object(); 743 var x=0,y=0; 744 // Browser capability sniffing 745 var use_gebi=false, use_css=false, use_layers=false; 746 if (document.getElementById) { use_gebi=true; } 747 else if (document.all) { use_css=true; } 748 else if (document.layers) { use_layers=true; } 749 // Logic to find position 750 if (use_gebi && document.all) { 751 x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); 752 y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); 753 } 754 else if (use_gebi) { 755 var o=document.getElementById(anchorname); 756 x=AnchorPosition_getPageOffsetLeft(o); 757 y=AnchorPosition_getPageOffsetTop(o); 758 } 759 else if (use_css) { 760 x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); 761 y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); 762 } 763 else if (use_layers) { 764 var found=0; 765 for (var i=0; i<document.anchors.length; i++) { 766 if (document.anchors[i].name==anchorname) { found=1; break; } 767 } 768 if (found==0) { 769 coordinates.x=0; coordinates.y=0; return coordinates; 770 } 771 x=document.anchors[i].x; 772 y=document.anchors[i].y; 773 } 774 else { 775 coordinates.x=0; coordinates.y=0; return coordinates; 776 } 777 coordinates.x=x; 778 coordinates.y=y; 779 return coordinates; 780 } 781 782// getAnchorWindowPosition(anchorname) 783// This function returns an object having .x and .y properties which are the coordinates 784// of the named anchor, relative to the window 785function getAnchorWindowPosition(anchorname) { 786 var coordinates=getAnchorPosition(anchorname); 787 var x=0; 788 var y=0; 789 if (document.getElementById) { 790 if (isNaN(window.screenX)) { 791 x=coordinates.x-document.body.scrollLeft+window.screenLeft; 792 y=coordinates.y-document.body.scrollTop+window.screenTop; 793 } 794 else { 795 x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset; 796 y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset; 797 } 798 } 799 else if (document.all) { 800 x=coordinates.x-document.body.scrollLeft+window.screenLeft; 801 y=coordinates.y-document.body.scrollTop+window.screenTop; 802 } 803 else if (document.layers) { 804 x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset; 805 y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset; 806 } 807 coordinates.x=x; 808 coordinates.y=y; 809 return coordinates; 810 } 811 812// Functions for IE to get position of an object 813function AnchorPosition_getPageOffsetLeft (el) { 814 var ol=el.offsetLeft; 815 while ((el=el.offsetParent) != null) { ol += el.offsetLeft; } 816 return ol; 817 } 818function AnchorPosition_getWindowOffsetLeft (el) { 819 return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft; 820 } 821function AnchorPosition_getPageOffsetTop (el) { 822 var ot=el.offsetTop; 823 while((el=el.offsetParent) != null) { ot += el.offsetTop; } 824 return ot; 825 } 826function AnchorPosition_getWindowOffsetTop (el) { 827 return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop; 828 } 829 830/* XXXXXXXXXXXXXXXXXXXXXXXX REQUIRED FILE: PopupWindow.js XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/ 831 832/* 833PopupWindow.js 834Author: Matt Kruse 835Last modified: 02/16/04 836 837DESCRIPTION: This object allows you to easily and quickly popup a window 838in a certain place. The window can either be a DIV or a separate browser 839window. 840 841COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small 842positioning errors - usually with Window positioning - occur on the 843Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 844window with <STYLE> tags may cause errors. 845 846USAGE: 847// Create an object for a WINDOW popup 848var win = new PopupWindow(); 849 850// Create an object for a DIV window using the DIV named 'mydiv' 851var win = new PopupWindow('mydiv'); 852 853// Set the window to automatically hide itself when the user clicks 854// anywhere else on the page except the popup 855win.autoHide(); 856
857// Show the window relative to the anchor name passed in 858win.showPopup(anchorname); 859 860// Hide the popup 861win.hidePopup(); 862 863// Set the size of the popup window (only applies to WINDOW popups 864win.setSize(width,height); 865 866// Populate the contents of the popup window that will be shown. If you 867// change the contents while it is displayed, you will need to refresh() 868win.populate(string); 869 870// set the URL of the window, rather than populating its contents 871// manually 872win.setUrl("http://www.site.com/"); 873 874// Refresh the contents of the popup 875win.refresh(); 876 877// Specify how many pixels to the right of the anchor the popup will appear 878win.offsetX = 50; 879 880// Specify how many pixels below the anchor the popup will appear 881win.offsetY = 100; 882 883NOTES: 8841) Requires the functions in AnchorPosition.js 885 8862) Your anchor tag MUST contain both NAME and ID attributes which are the 887 same. For example: 888 <A NAME="test" ID="test"> </A> 889 8903) There must be at least a space between <A> </A> for IE5.5 to see the 891 anchor tag correctly. Do not do <A></A> with no space. 892 8934) When a PopupWindow object is created, a handler for 'onmouseup' is 894 attached to any event handler you may have already defined. Do NOT define 895 an event handler for 'onmouseup' after you define a PopupWindow object or 896 the autoHide() will not work correctly. 897*/ 898 899// Set the position of the popup window based on the anchor 900function PopupWindow_getXYPosition(anchorname) { 901 var coordinates; 902 if (this.type == "WINDOW") { 903 coordinates = getAnchorWindowPosition(anchorname); 904 } 905 else { 906 coordinates = getAnchorPosition(anchorname); 907 } 908 this.x = coordinates.x; 909 this.y = coordinates.y; 910 } 911// Set width/height of DIV/popup window 912function PopupWindow_setSize(width,height) { 913 this.width = width; 914 this.height = height; 915 } 916// Fill the window with contents 917function PopupWindow_populate(contents) { 918 this.contents = contents; 919 this.populated = false; 920 } 921// Set the URL to go to 922function PopupWindow_setUrl(url) { 923 this.url = url; 924 } 925// Set the window popup properties 926function PopupWindow_setWindowProperties(props) { 927 this.windowProperties = props; 928 } 929// Refresh the displayed contents of the popup 930function PopupWindow_refresh() { 931 if (this.divName != null) { 932 // refresh the DIV object 933 if (this.use_gebi) { 934 document.getElementById(this.divName).innerHTML = this.contents; 935 } 936 else if (this.use_css) { 937 document.all[this.divName].innerHTML = this.contents; 938 } 939 else if (this.use_layers) { 940 var d = document.layers[this.divName]; 941 d.document.open(); 942 d.document.writeln(this.contents); 943 d.document.close(); 944 } 945 } 946 else { 947 if (this.popupWindow != null && !this.popupWindow.closed) { 948 if (this.url!="") { 949 this.popupWindow.location.href=this.url; 950 } 951 else { 952 this.popupWindow.document.open(); 953 this.popupWindow.document.writeln(this.contents); 954 this.popupWindow.document.close(); 955 } 956 this.popupWindow.focus(); 957 } 958 } 959 } 960// Position and show the popup, relative to an anchor object 961function PopupWindow_showPopup(anchorname) { 962 this.getXYPosition(anchorname); 963 this.x += this.offsetX; 964 this.y += this.offsetY; 965 if (!this.populated && (this.contents != "")) { 966 this.populated = true; 967 this.refresh(); 968 } 969 if (this.divName != null) { 970 // Show the DIV object 971 if (this.use_gebi) { 972 document.getElementById(this.divName).style.left = this.x + "px"; 973 document.getElementById(this.divName).style.top = this.y + "px"; 974 document.getElementById(this.divName).style.visibility = "visible"; 975 } 976 else if (this.use_css) { 977 document.all[this.divName].style.left = this.x; 978 document.all[this.divName].style.top = this.y; 979 document.all[this.divName].style.visibility = "visible"; 980 } 981 else if (this.use_layers) { 982 document.layers[this.divName].left = this.x; 983 document.layers[this.divName].top = this.y; 984 document.layers[this.divName].visibility = "visible"; 985 } 986 } 987 else { 988 if (this.popupWindow == null || this.popupWindow.closed) { 989 // If the popup window will go off-screen, move it so it doesn't 990 if (this.x<0) { this.x=0; } 991 if (this.y<0) { this.y=0; } 992 if (screen && screen.availHeight) { 993 if ((this.y + this.height) > screen.availHeight) { 994 this.y = screen.availHeight - this.height; 995 } 996 }
997 if (screen && screen.availWidth) { 998 if ((this.x + this.width) > screen.availWidth) { 999 this.x = screen.availWidth - this.width; 1000 } 1001 } 1002 var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ); 1003 this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+""); 1004 } 1005 this.refresh(); 1006 } 1007 } 1008// Hide the popup 1009function PopupWindow_hidePopup() { 1010 if (this.divName != null) { 1011 if (this.use_gebi) { 1012 document.getElementById(this.divName).style.visibility = "hidden"; 1013 } 1014 else if (this.use_css) { 1015 document.all[this.divName].style.visibility = "hidden"; 1016 } 1017 else if (this.use_layers) { 1018 document.layers[this.divName].visibility = "hidden"; 1019 } 1020 } 1021 else { 1022 if (this.popupWindow && !this.popupWindow.closed) { 1023 this.popupWindow.close(); 1024 this.popupWindow = null; 1025 } 1026 } 1027 } 1028// Pass an event and return whether or not it was the popup DIV that was clicked 1029function PopupWindow_isClicked(e) { 1030 if (this.divName != null) { 1031 if (this.use_layers) { 1032 var clickX = e.pageX; 1033 var clickY = e.pageY; 1034 var t = document.layers[this.divName]; 1035 if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) { 1036 return true; 1037 } 1038 else { return false; } 1039 } 1040 else if (document.all) { // Need to hard-code this to trap IE for error-handling 1041 var t = window.event.srcElement; 1042 while (t.parentElement != null) { 1043 if (t.id==this.divName) { 1044 return true; 1045 } 1046 t = t.parentElement; 1047 } 1048 return false; 1049 } 1050 else if (this.use_gebi && e) { 1051 var t = e.originalTarget; 1052 while (t.parentNode != null) { 1053 if (t.id==this.divName) { 1054 return true; 1055 } 1056 t = t.parentNode; 1057 } 1058 return false; 1059 } 1060 return false; 1061 } 1062 return false; 1063 } 1064 1065// Check an onMouseDown event to see if we should hide 1066function PopupWindow_hideIfNotClicked(e) { 1067 if (this.autoHideEnabled && !this.isClicked(e)) { 1068 this.hidePopup(); 1069 } 1070 } 1071// Call this to make the DIV disable automatically when mouse is clicked outside it 1072function PopupWindow_autoHide() { 1073 this.autoHideEnabled = true; 1074 } 1075// This global function checks all PopupWindow objects onmouseup to see if they should be hidden 1076function PopupWindow_hidePopupWindows(e) { 1077 for (var i=0; i<popupWindowObjects.length; i++) { 1078 if (popupWindowObjects[i] != null) { 1079 var p = popupWindowObjects[i]; 1080 p.hideIfNotClicked(e); 1081 } 1082 } 1083 } 1084// Run this immediately to attach the event listener 1085function PopupWindow_attachListener() { 1086 if (document.layers) { 1087 document.captureEvents(Event.MOUSEUP); 1088 } 1089 window.popupWindowOldEventListener = document.onmouseup; 1090 if (window.popupWindowOldEventListener != null) { 1091 document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();"); 1092 } 1093 else { 1094 document.onmouseup = PopupWindow_hidePopupWindows; 1095 } 1096 } 1097// CONSTRUCTOR for the PopupWindow object 1098// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup 1099function PopupWindow() { 1100 if (!window.popupWindowIndex) { window.popupWindowIndex = 0; } 1101 if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); } 1102 if (!window.listenerAttached) { 1103 window.listenerAttached = true; 1104 PopupWindow_attachListener(); 1105 } 1106 this.index = popupWindowIndex++; 1107 popupWindowObjects[this.index] = this; 1108 this.divName = null; 1109 this.popupWindow = null; 1110 this.width=0; 1111 this.height=0; 1112 this.populated = false; 1113 this.visible = false; 1114 this.autoHideEnabled = false; 1115 1116 this.contents = ""; 1117 this.url=""; 1118 this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no"; 1119 if (arguments.length>0) { 1120 this.type="DIV"; 1121 this.divName = arguments[0]; 1122 } 1123 else { 1124 this.type="WINDOW"; 1125 } 1126 this.use_gebi = false; 1127 this.use_css = false; 1128 this.use_layers = false;
1129 if (document.getElementById) { this.use_gebi = true; } 1130 else if (document.all) { this.use_css = true; } 1131 else if (document.layers) { this.use_layers = true; } 1132 else { this.type = "WINDOW"; } 1133 this.offsetX = 0; 1134 this.offsetY = 0; 1135 // Method mappings 1136 this.getXYPosition = PopupWindow_getXYPosition; 1137 this.populate = PopupWindow_populate; 1138 this.setUrl = PopupWindow_setUrl; 1139 this.setWindowProperties = PopupWindow_setWindowProperties; 1140 this.refresh = PopupWindow_refresh; 1141 this.showPopup = PopupWindow_showPopup; 1142 this.hidePopup = PopupWindow_hidePopup; 1143 this.setSize = PopupWindow_setSize; 1144 this.isClicked = PopupWindow_isClicked; 1145 this.autoHide = PopupWindow_autoHide; 1146 this.hideIfNotClicked = PopupWindow_hideIfNotClicked; 1147 } 1148 1149/* XXXXXXXXXXXXXXXXXXXXXXXX REQUIRED FILE: PopupWindow.js XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/ 1150 1151// =================================================================== 1152// Author: Matt Kruse <[email protected]> 1153// WWW: http://www.mattkruse.com/ 1154// 1155// NOTICE: You may use this code for any purpose, commercial or
1156// private, without any further permission from the author. You may 1157// remove this notice from your final code if you wish, however it is 1158// appreciated by the author if at least my web site address is kept. 1159// 1160// You may *NOT* re-distribute this code in any way except through its 1161// use. That means, you can include it in your product, or your web 1162// site, or any other form where the code is actually being used. You 1163// may not put the plain javascript up on your site for download or 1164// include it in your javascript libraries for download. 1165// If you wish to share this code with others, please just point them 1166// to the URL instead. 1167// Please DO NOT link directly to my .js files from your site. Copy 1168// the files to your server and use them there. Thank you. 1169// =================================================================== 1170 1171// HISTORY 1172// ------------------------------------------------------------------ 1173// May 17, 2003: Fixed bug in parseDate() for dates <1970 1174// March 11, 2003: Added parseDate() function 1175// March 11, 2003: Added "NNN" formatting option. Doesn't match up 1176// perfectly with SimpleDateFormat formats, but 1177// backwards-compatability was required. 1178 1179// ------------------------------------------------------------------ 1180// These functions use the same 'format' strings as the 1181// java.text.SimpleDateFormat class, with minor exceptions. 1182// The format string consists of the following abbreviations: 1183// 1184// Field | Full Form | Short Form 1185// -------------+--------------------+----------------------- 1186// Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits) 1187// Month | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits) 1188// | NNN (abbr.) | 1189// Day of Month | dd (2 digits) | d (1 or 2 digits) 1190// Day of Week | EE (name) | E (abbr) 1191// Hour (1-12) | hh (2 digits) | h (1 or 2 digits) 1192// Hour (0-23) | HH (2 digits) | H (1 or 2 digits) 1193// Hour (0-11) | KK (2 digits) | K (1 or 2 digits) 1194// Hour (1-24) | kk (2 digits) | k (1 or 2 digits) 1195// Minute | mm (2 digits) | m (1 or 2 digits) 1196// Second | ss (2 digits) | s (1 or 2 digits) 1197// AM/PM | a | 1198// 1199// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm! 1200// Examples: 1201// "MMM d, y" matches: January 01, 2000 1202// Dec 1, 1900 1203// Nov 20, 00 1204// "M/d/yy" matches: 01/20/00 1205// 9/2/00 1206// "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM" 1207// ------------------------------------------------------------------ 1208 1209var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); 1210var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat'); 1211function LZ(x) {return(x<0||x>9?"":"0")+x} 1212 1213// ------------------------------------------------------------------ 1214// isDate ( date_string, format_string ) 1215// Returns true if date string matches format of format string and 1216// is a valid date. Else returns false. 1217// It is recommended that you trim whitespace around the value before 1218// passing it to this function, as whitespace is NOT ignored! 1219// ------------------------------------------------------------------ 1220function isDate(val,format) { 1221 var date=getDateFromFormat(val,format); 1222 if (date==0) { return false; } 1223 return true; 1224 } 1225 1226// ------------------------------------------------------------------- 1227// compareDates(date1,date1format,date2,date2format) 1228// Compare two date strings to see which is greater. 1229// Returns: 1230// 1 if date1 is greater than date2 1231// 0 if date2 is greater than date1 of if they are the same 1232// -1 if either of the dates is in an invalid format 1233// ------------------------------------------------------------------- 1234function compareDates(date1,dateformat1,date2,dateformat2) { 1235 var d1=getDateFromFormat(date1,dateformat1); 1236 var d2=getDateFromFormat(date2,dateformat2); 1237 if (d1==0 || d2==0) { 1238 return -1; 1239 } 1240 else if (d1 > d2) { 1241 return 1; 1242 } 1243 return 0; 1244 } 1245 1246// ------------------------------------------------------------------ 1247// formatDate (date_object, format) 1248// Returns a date in the output format specified.
1249// The format string uses the same abbreviations as in getDateFromFormat() 1250// ------------------------------------------------------------------ 1251function formatDate(date,format) { 1252 format=format+""; 1253 var result=""; 1254 var i_format=0; 1255 var c=""; 1256 var token=""; 1257 var y=date.getYear()+""; 1258 var M=date.getMonth()+1; 1259 var d=date.getDate(); 1260 var E=date.getDay(); 1261 var H=date.getHours(); 1262 var m=date.getMinutes(); 1263 var s=date.getSeconds(); 1264 var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k; 1265 // Convert real date parts into formatted versions 1266 var value=new Object(); 1267 if (y.length < 4) {y=""+(y-0+1900);} 1268 value["y"]=""+y; 1269 value["yyyy"]=y; 1270 value["yy"]=y.substring(2,4); 1271 value["M"]=M; 1272 value["MM"]=LZ(M); 1273 value["MMM"]=MONTH_NAMES[M-1]; 1274 value["NNN"]=MONTH_NAMES[M+11]; 1275 value["d"]=d; 1276 value["dd"]=LZ(d); 1277 value["E"]=DAY_NAMES[E+7]; 1278 value["EE"]=DAY_NAMES[E]; 1279 value["H"]=H; 1280 value["HH"]=LZ(H); 1281 if (H==0){value["h"]=12;} 1282 else if (H>12){value["h"]=H-12;} 1283 else {value["h"]=H;} 1284 value["hh"]=LZ(value["h"]); 1285 if (H>11){value["K"]=H-12;} else {value["K"]=H;} 1286 value["k"]=H+1; 1287 value["KK"]=LZ(value["K"]); 1288 value["kk"]=LZ(value["k"]); 1289 if (H > 11) { value["a"]="PM"; } 1290 else { value["a"]="AM"; } 1291 value["m"]=m; 1292 value["mm"]=LZ(m); 1293 value["s"]=s; 1294 value["ss"]=LZ(s); 1295 while (i_format < format.length) { 1296 c=format.charAt(i_format); 1297 token=""; 1298 while ((format.charAt(i_format)==c) && (i_format < format.length)) { 1299 token += format.charAt(i_format++); 1300 } 1301 if (value[token] != null) { result=result + value[token]; } 1302 else { result=result + token; } 1303 } 1304 return result; 1305 } 1306 1307// ------------------------------------------------------------------ 1308// Utility functions for parsing in getDateFromFormat() 1309// ------------------------------------------------------------------ 1310function _isInteger(val) { 1311 var digits="1234567890"; 1312 for (var i=0; i < val.length; i++) { 1313 if (digits.indexOf(val.charAt(i))==-1) { return false; } 1314 } 1315 return true; 1316 } 1317function _getInt(str,i,minlength,maxlength) { 1318 for (var x=maxlength; x>=minlength; x--) { 1319 var token=str.substring(i,i+x); 1320 if (token.length < minlength) { return null; } 1321 if (_isInteger(token)) { return token; } 1322 } 1323 return null; 1324 } 1325 1326// ------------------------------------------------------------------ 1327// getDateFromFormat( date_string , format_string ) 1328// 1329// This function takes a date string and a format string. It matches 1330// If the date string matches the format string, it returns the 1331// getTime() of the date. If it does not match, it returns 0. 1332// ------------------------------------------------------------------ 1333function getDateFromFormat(val,format) { 1334 val=val+""; 1335 format=format+""; 1336 var i_val=0; 1337 var i_format=0; 1338 var c=""; 1339 var token=""; 1340 var token2=""; 1341 var x,y; 1342 var now=new Date(); 1343 var year=now.getYear(); 1344 var month=now.getMonth()+1; 1345 var date=1; 1346 var hh=now.getHours(); 1347 var mm=now.getMinutes(); 1348 var ss=now.getSeconds(); 1349 var ampm=""; 1350 1351 while (i_format < format.length) { 1352 // Get next token from format string 1353 c=format.charAt(i_format); 1354 token=""; 1355 while ((format.charAt(i_format)==c) && (i_format < format.length)) { 1356 token += format.charAt(i_format++); 1357 } 1358 // Extract contents of value based on format token 1359 if (token=="yyyy" || token=="yy" || token=="y") { 1360 if (token=="yyyy") { x=4;y=4; } 1361 if (token=="yy") { x=2;y=2; } 1362 if (token=="y") { x=2;y=4; } 1363 year=_getInt(val,i_val,x,y); 1364 if (year==null) { return 0; } 1365 i_val += year.length; 1366 if (year.length==2) { 1367 if (year > 70) { year=1900+(year-0); } 1368 else { year=2000+(year-0); } 1369 } 1370 } 1371 else if (token=="MMM"||token=="NNN"){ 1372 month=0; 1373 for (var i=0; i<MONTH_NAMES.length; i++) { 1374 var month_name=MONTH_NAMES[i]; 1375 if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) { 1376 if (token=="MMM"||(token=="NNN"&&i>11)) { 1377 month=i+1; 1378 if (month>12) { month -= 12; } 1379 i_val += month_name.length; 1380 break; 1381 } 1382 } 1383 } 1384 if ((month < 1)||(month>12)){return 0;} 1385 } 1386 else if (token=="EE"||token=="E"){ 1387 for (var i=0; i<DAY_NAMES.length; i++) { 1388 var day_name=DAY_NAMES[i]; 1389 if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) { 1390 i_val += day_name.length; 1391 break; 1392 } 1393 } 1394 } 1395 else if (token=="MM"||token=="M") { 1396 month=_getInt(val,i_val,token.length,2); 1397 if(month==null||(month<1)||(month>12)){return 0;} 1398 i_val+=month.length;} 1399 else if (token=="dd"||token=="d") { 1400 date=_getInt(val,i_val,token.length,2); 1401 if(date==null||(date<1)||(date>31)){return 0;} 1402 i_val+=date.length;} 1403 else if (token=="hh"||token=="h") { 1404 hh=_getInt(val,i_val,token.length,2); 1405 if(hh==null||(hh<1)||(hh>12)){return 0;} 1406 i_val+=hh.length;} 1407 else if (token=="HH"||token=="H") { 1408 hh=_getInt(val,i_val,token.length,2); 1409 if(hh==null||(hh<0)||(hh>23)){return 0;} 1410 i_val+=hh.length;} 1411 else if (token=="KK"||token=="K") { 1412 hh=_getInt(val,i_val,token.length,2); 1413 if(hh==null||(hh<0)||(hh>11)){return 0;} 1414 i_val+=hh.length;} 1415 else if (token=="kk"||token=="k") { 1416 hh=_getInt(val,i_val,token.length,2); 1417 if(hh==null||(hh<1)||(hh>24)){return 0;} 1418 i_val+=hh.length;hh--;} 1419 else if (token=="mm"||token=="m") { 1420 mm=_getInt(val,i_val,token.length,2); 1421 if(mm==null||(mm<0)||(mm>59)){return 0;} 1422 i_val+=mm.length;} 1423 else if (token=="ss"||token=="s") { 1424 ss=_getInt(val,i_val,token.length,2); 1425 if(ss==null||(ss<0)||(ss>59)){return 0;} 1426 i_val+=ss.length;} 1427 else if (token=="a") { 1428 if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";} 1429 else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";} 1430 else {return 0;} 1431 i_val+=2;} 1432 else { 1433 if (val.substring(i_val,i_val+token.length)!=token) {return 0;} 1434 else {i_val+=token.length;} 1435 } 1436 } 1437 // If there are any trailing characters left in the value, it doesn't match 1438 if (i_val != val.length) { return 0; } 1439 // Is date valid for month? 1440 if (month==2) { 1441 // Check for leap year 1442 if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year 1443 if (date > 29){ return 0; } 1444 } 1445 else { if (date > 28) { return 0; } } 1446 } 1447 if ((month==4)||(month==6)||(month==9)||(month==11)) { 1448 if (date > 30) { return 0; } 1449 } 1450 // Correct hours value 1451 if (hh<12 && ampm=="PM") { hh=hh-0+12; } 1452 else if (hh>11 && ampm=="AM") { hh-=12; } 1453 var newdate=new Date(year,month-1,date,hh,mm,ss); 1454 return newdate.getTime(); 1455 } 1456 1457// ------------------------------------------------------------------ 1458// parseDate( date_string [, prefer_euro_format] ) 1459// 1460// This function takes a date string and tries to match it to a 1461// number of possible date formats to get the value. It will try to 1462// match against the following international formats, in this order: 1463// y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d 1464// M/d/y M-d-y M.d.y MMM-d M/d M-d 1465// d/M/y d-M-y d.M.y d-MMM d/M d-M 1466// A second argument may be passed to instruct the method to search 1467// for formats like d/M/y (european format) before M/d/y (American). 1468// Returns a Date object or null if no patterns match. 1469// ------------------------------------------------------------------ 1470function parseDate(val) { 1471 var preferEuro=(arguments.length==2)?arguments[1]:false; 1472 generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
1473 monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d'); 1474 dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M'); 1475 var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst'); 1476 var d=null; 1477 for (var i=0; i<checkList.length; i++) { 1478 var l=window[checkList[i]]; 1479 for (var j=0; j<l.length; j++) { 1480 d=getDateFromFormat(val,l[j]); 1481 if (d!=0) { return new Date(d); } 1482 } 1483 } 1484 return null; 1485 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.