1// ;(function( $ ) { 2var scwDateNow = new Date(Date.parse(new Date().toDateString())); 3 var scwBaseYear = scwDateNow.getFullYear() - 10; 4 var scwDropDownYears = 20; 5 var scwLanguage; 6 7 function scwSetDefaultLanguage() { 8 try { 9 scwSetLanguage(); 10 } catch (exception) { // English 11 scwToday = 'Today:'; 12 scwClear = 'Clear'; 13 scwDrag = 'click here to drag'; 14 scwArrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 15 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' 16 ]; 17 scwArrWeekInits = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; 18 scwInvalidDateMsg = 'The entered date is invalid.\n'; 19 scwOutOfRangeMsg = 'The entered date is out of range.'; 20 scwDoesNotExistMsg = 'The entered date does not exist.'; 21 scwInvalidAlert = ['Invalid date (', ') ignored.']; 22 scwDateDisablingError = ['Error ', ' is not a Date object.']; 23 scwRangeDisablingError = ['Error ', 24 ' should consist of two elements.' 25 ]; 26 } 27 }; 28 29 30 var scwWeekStart = 0; 31 var scwWeekNumberDisplay = false; 32 var scwWeekNumberBaseDay = 4; 33 var scwShowInvalidDateMsg = true, 34 scwShowOutOfRangeMsg = true, 35 scwShowDoesNotExistMsg = true, 36 scwShowInvalidAlert = true, 37 scwShowDateDisablingError = true, 38 scwShowRangeDisablingError = true; 39 var scwArrDelimiters = ['/', '-', '.', ',', ' ']; 40 41 42 function scwDateOutput(dateOut) { 43 if (document.forms["chkAvailabilityForm"].dateFlag != null) { 44 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 45 var scwDateOutputFormat = 'DD/MM/YYYY'; 46 return scwDateOutputFormat; 47 } else { 48 var scwDateOutputFormat = 'MM/DD/YYYY'; 49 return scwDateOutputFormat; 50 } 51 } 52 }; 53 54 55 56 var scwZindex = 10000; 57 var scwBlnStrict = false; 58 var scwClearButton = false; 59 var scwAutoPosition = false; 60 var scwEnabledDay = [true, true, true, true, true, true, true, 61 true, true, true, true, true, true, true, 62 true, true, true, true, true, true, true, 63 true, true, true, true, true, true, true, 64 true, true, true, true, true, true, true, 65 true, true, true, true, true, true, true 66 ]; 67 68 var scwDisabledDates = new Array(); 69 var scwActiveToday = true; 70 var scwOutOfMonthDisable = false; 71 var scwOutOfMonthHide = false; 72 var scwOutOfRangeDisable = true; 73 var scwFormatTodayCell = true; 74 var scwTodayCellBorderColour = '#333333'; 75 var scwAllowDrag = false; 76 var scwClickToHide = false; 77 document.writeln( 78 '<style type="text/css">' + 79 '.scw {padding:1px;vertical-align:middle;}' + 80 'iframe.scw {position:absolute;z-index:' + scwZindex + 81 ';top:0px;left:0px;visibility:hidden;' + 82 'width:1px;height:1px;}' + 83 'table.scw {padding:0px;visibility:hidden;' + 84 'position:absolute;cursor:default;' + 85 'width:100px;top:0px;left:0px;' + 86 'z-index:' + (scwZindex + 1) + 87 ';text-align:center;}' + 88 '</style>'); 89 90 document.writeln( 91 '<style type="text/css">' + 92 '/* IMPORTANT: The SCW calendar script requires all ' + 93 ' the classes defined here.' + 94 '*/' + 95 'table.scw {padding: 1px;' + 96 'vertical-align:middle;' + 97 'border: #c5c5c5 ridge 1px;' + 98 'font-size: 12px;' + 99 'font-family: ' + 100 'Arial,Helvetica,Sans-Serif;' + 101 'font-weight: normal;}' + 102 'td.scwDrag,' + 103 'td.scwHead {padding: 0px 0px;' + 104 'text-align: center;}' + 105 'td.scwDrag {font-size: 12px;}' + 106 'select.scwHead {margin: 3px 1px;' + 107 'text-align: center;}' + 108 'input.scwHead {height: 22px;' + 109 'line-height: 15px;' + 110 'width: 22px;' + 111 'vertical-align:middle;' + 112 'text-align: center;' + 113 'margin: 2px 1px;' + 114 'font-weight: bold;' + 115 'font-size: 12px;' + 116 'font-family: fixedSys;}' + 117 'td.scwWeekNumberHead,' + 118 'td.scwWeek {padding: 0px;' + 119 'text-align: center;' + 120 'font-weight: bold;}' + 121 'td.scwNow,' + 122 'td.scwNowHover,' + 123 'td.scwNow:hover,' + 124 'td.scwNowDisabled {padding: 0px;' + 125 'text-align: center;' + 126 'vertical-align:middle;' + 127 'font-weight: normal;}' + 128 'table.scwCells {text-align: right;background-color: #e6e6e6;' + 129 'font-size: 12px;' + 130 'width: 96%;}' + 131 'td.scwCells,' + 132 'td.scwCellsHover,' + 133 'td.scwCells:hover,' + 134 'td.scwCellsDisabled,' + 135 'td.scwCellsExMonth,' + 136 'td.scwCellsExMonthHover,' + 137 'td.scwCellsExMonth:hover,' + 138 'td.scwCellsExMonthDisabled,' + 139 'td.scwCellsWeekend,' + 140 'td.scwCellsWeekendHover,' + 141 'td.scwCellsWeekend:hover,' + 142 'td.scwCellsWeekendDisabled,' + 143 'td.scwInputDate,' + 144 'td.scwInputDateHover,' + 145 'td.scwInputDate:hover,' + 146 'td.scwInputDateDisabled,' + 147 'td.scwWeekNo,' + 148 'td.scwWeeks {padding: 5px;' + 149 'width: 16px;' + 150 'height: 16px;' + 151 'border-width: 0px;' + 152 'border-style: solid;' + 153 'font-weight: bold;' + 154 'vertical-align: middle;}' + 155 '/* Blend the colours into your page here... */' + 156 '/* Calendar background */' + 157 'table.scw {background-color: #f2f2f2;}' + 158 159 '/* Drag Handle */' + 160 'td.scwDrag {background-color: #9999CC;' + 161 'color: #CCCCFF;}' + 162 '/* Week number heading */' + 163 'td.scwWeekNumberHead {color: #c4c46e;}' + 164 165 '/* Week day headings */' + 166 'td.scwWeek {background-color: #333333;' + 167 'color: #ffffff;}' + 168 '/* Week numbers */' + 169 'td.scwWeekNo {background-color: #776677;' + 170 'color: #CCCCCC;}' + 171 '/* Enabled Days */' + 172 '/* Week Day */' + 173 'td.scwCells {background-color: #ffffff;' + 174 'font-weight: bold;' + 175 'color: #000000;}' + 176 '/* Day matching the input date */' + 177 'td.scwInputDate {background-color: #ffffff;' + 178 'font-weight: bold;' + 179 'color: #000000;}' + 180 '/* Weekend Day */' + 181 'td.scwCellsWeekend {background-color: #ffffff;' + 182 'font-weight: bold;' + 183 'color: #000000;}' + 184 185 '/* Day outside the current month */' + 186 'td.scwCellsExMonth {background-color: #ffffff;' + 187 'color: #666666;}' + 188 '/* Today selector */' + 189 'td.scwNow {background-color: #444444;' + 190 'border-width: 2px;' + 191 'border-color: #333333;' + 192 'border-style: solid;' + 193 'font-size: 12px;' + 194 'color: #FFFFFF;}' + 195 '/* Clear Button */' + 196 'td.scwClear {padding: 0px;}' + 197 'input.scwClear {padding: 0px;' + 198 'text-align: center;' + 199 'font-size: 12px;}' + 200 '/* MouseOver/Hover formatting ' + 201 ' If you want to "turn off" any of the formatting ' + 202 ' then just set to the same as the standard format' + 203 ' above.' + 204 ' ' + 205 ' Note: The reason that the following are' + 206 ' implemented using both a class and a :hover' + 207 ' pseudoclass is because Opera handles the rendering' + 208 ' involved in the class swap very poorly and IE6 ' + 209 ' (and below) only implements pseudoclasses on the' + 210 ' anchor tag.' + 211 '*/' + 212 '/* Active cells */' + 213 'td.scwCells:hover,' + 214 'td.scwCellsHover {background-color: #3399ff;' + 215 'cursor: pointer;' + 216 'color: #f2f2f2;}' + 217 '/* Day matching the input date */' + 218 'td.scwInputDate:hover,' + 219 'td.scwInputDateHover {background-color: #3399ff;' + 220 'cursor: pointer;' + 221 'color: #f2f2f2;}' + 222 '/* Weekend cells */' + 223 'td.scwCellsWeekend:hover,' + 224 'td.scwCellsWeekendHover {background-color: #3399ff;' + 225 'cursor: pointer;' + 226 'color: #f2f2f2;}' + 227 '/* Day outside the current month */' + 228 'td.scwCellsExMonth:hover,' + 229 'td.scwCellsExMonthHover {background-color: #3399ff;' + 230 'cursor: pointer;' + 231 'color: #f2f2f2;}' + 232 '/* Today selector */' + 233 'td.scwNow:hover,' + 234 'td.scwNowHover {background-color: #333333;' + 235 'border-width: 2px;' + 236 'border-color: #333333;' + 237 'border-style: solid;' + 238 'color: #FFFFFF;}' + 239 'cursor: pointer;' + 240 'font-weight: bold;}' + 241 '/* Disabled cells */' + 242 '/* Week Day */' + 243 '/* Day matching the input date */' + 244 'td.scwInputDateDisabled {background-color: #F2F2F2' + 245 'color: #666666;}' + 246 'td.scwCellsDisabled {background-color: #F2F2F2;' + 247 'color: #666666;}' + 248 '/* Weekend Day */' + 249 'td.scwCellsWeekendDisabled {background-color: #F2F2F2;' + 250 'padding: 2px;' + 251 'color: #666666;}' + 252 '/* Day outside the current month */' + 253 'td.scwCellsExMonthDisabled {background-color: #F2F2F2;' + 254 'padding: 2px;' + 255 'color: #666666;}' + 256 'td.scwNowDisabled {background-color: #a5a5a5;' + 257 'color: #FFFFFF;}' + 258 '#scwMonths,#scwYears {width: auto !important' + 259 '</style>' 260 ); 261 262 var scwTargetEle, 263 scwTriggerEle, 264 scwMonthSum = 0, 265 scwBlnFullInputDate = false, 266 scwPassEnabledDay = new Array(), 267 scwSeedDate = new Date(), 268 scwParmActiveToday = true, 269 scwWeekStart = scwWeekStart % 7, 270 scwToday, 271 scwClear, 272 scwDrag, 273 scwArrMonthNames, 274 scwArrWeekInits, 275 scwInvalidDateMsg, 276 scwOutOfRangeMsg, 277 scwDoesNotExistMsg, 278 scwInvalidAlert, 279 scwDateDisablingError, 280 scwRangeDisablingError; 281 282 283 Date.prototype.scwFormat = 284 function (scwFormat) { 285 var charCount = 0, 286 codeChar = '', 287 result = ''; 288 289 for (var i = 0; i <= scwFormat.length; i++) { 290 if (i < scwFormat.length && scwFormat.charAt(i) == codeChar) { 291 charCount++; 292 } else { 293 switch (codeChar) { 294 case 'y': 295 case 'Y': 296 result += (this.getFullYear() % Math.pow(10, charCount)).toString(). 297 scwPadLeft(charCount); 298 break; 299 case 'm': 300 case 'M': 301 302 result += (charCount < 3) ? 303 (this.getMonth() + 1). 304 toString().scwPadLeft(charCount): scwArrMonthNames[this.getMonth()];
305 break; 306 case 'd': 307 case 'D': 308 309 result += this.getDate().toString(). 310 scwPadLeft(charCount); 311 break; 312 default: 313 314 while (charCount-- > 0) { 315 result += codeChar; 316 } 317 } 318 319 if (i < scwFormat.length) { 320 codeChar = scwFormat.charAt(i); 321 charCount = 1; 322 } 323 } 324 } 325 return result; 326 }; 327 328 String.prototype.scwPadLeft = 329 function (padToLength) { 330 var result = ''; 331 for (var i = 0; i < (padToLength - this.length); i++) { 332 result += '0'; 333 } 334 return (result + this); 335 }; 336 337 Function.prototype.runsAfterSCW = 338 function () { 339 var func = this, 340 args = new Array(arguments.length); 341 342 for (var i = 0; i < args.length; ++i) { 343 args[i] = arguments[i]; 344 } 345 346 return function () { // concat/join the two argument arrays 347 for (var i = 0; i < arguments.length; ++i) { 348 args[args.length] = arguments[i]; 349 } 350 return (args.shift() == scwTriggerEle) ? func.apply(this, args) : null; 351 }; 352 }; 353 354 function scwID(id) { 355 if (document.getElementById(id) || (!document.getElementById(id) && document.getElementsByName(id).length == 0)) { 356 return document.getElementById(id); 357 } else { 358 if (document.getElementsByName(id).length == 1) { 359 return document.getElementsByName(id)[0]; 360 } else { 361 if (document.getElementsByName(id).length > 1) { 362 alert('SCW' + 363 ' \nCannot uniquely identify element named: ' + id + 364 '.\nMore than one identical NAME attribute defined' + 365 '.\nSolution: Assign the required element a unique ID attribute value.'); 366 } 367 } 368 } 369 }; 370 371 var scwNextActionReturn, scwNextAction; 372 373 function showCal(scwEle, scwSource) { 374 scwShow(scwEle, scwSource); 375 }; 376 377 function scwShow(scwEle, scwSource) { 378 if (!scwSource) { 379 scwSource = window.event; 380 } 381 382 if (scwSource.tagName) // Second parameter isn't an event it's an element 383 { 384 var scwSourceEle = scwSource; 385 386 if (scwID('scwIE')) { 387 window.event.cancelBubble = true; 388 } else { 389 scwSourceEle.parentNode.addEventListener('click', scwStopPropagation, false); 390 } 391 } else // Second parameter is an event 392 { 393 var scwSourceEle = (scwSource.target) ? 394 scwSource.target : 395 scwSource.srcElement; 396 if (scwSource.stopPropagation) { 397 scwSource.stopPropagation(); 398 } else { 399 scwSource.cancelBubble = true; 400 } 401 } 402 403 scwTriggerEle = scwSourceEle; 404 scwParmActiveToday = true; 405 406 for (var i = 0; i < 7; i++) { 407 scwPassEnabledDay[(i + 7 - scwWeekStart) % 7] = true; 408 for (var j = 2; j < arguments.length; j++) { 409 if (arguments[j] == i) { 410 scwPassEnabledDay[(i + 7 - scwWeekStart) % 7] = false; 411 if (scwDateNow.getDay() == i) { 412 scwParmActiveToday = false; 413 } 414 } 415 } 416 } 417 418 419 scwSeedDate = scwDateNow; 420 var scwDateValue = ''; 421 422 if (scwEle.value) { 423 scwDateValue = scwEle.value.replace(/^\s+/, '').replace(/\s+$/, ''); 424 } else { 425 if (typeof scwEle.value == 'undefined') { 426 var scwChildNodes = scwEle.childNodes; 427 for (var i = 0; i < scwChildNodes.length; i++) { 428 if (scwChildNodes[i].nodeType == 3) { 429 scwDateValue = scwChildNodes[i].nodeValue.replace(/^\s+/, '').replace(/\s+$/, ''); 430 if (scwDateValue.length > 0) { 431 scwTriggerEle.scwTextNode = scwChildNodes[i]; 432 scwTriggerEle.scwLength = scwChildNodes[i].nodeValue.length; 433 break; 434 } 435 } 436 } 437 } 438 } 439 440 scwSetDefaultLanguage(); 441 442 scwID('scwDragText').innerHTML = scwDrag; 443 444 scwID('scwMonths').options.length = 0; 445 for (var i = 0; i < scwArrMonthNames.length; i++) { 446 scwID('scwMonths').options[i] = new Option(scwArrMonthNames[i], scwArrMonthNames[i]); 447 } 448 449 scwID('scwYears').options.length = 0; 450 for (var i = 0; i < scwDropDownYears; i++) { 451 scwID('scwYears').options[i] = new Option((scwBaseYear + i), (scwBaseYear + i)); 452 } 453 454 for (var i = 0; i < scwArrWeekInits.length; i++) { 455 scwID('scwWeekInit' + i).innerHTML = scwArrWeekInits[(i + scwWeekStart) % scwArrWeekInits.length]; 456 } 457 458 if (((new Date(scwBaseYear + scwDropDownYears, 0, 0)) > scwDateNow && 459 (new Date(scwBaseYear, 0, 0)) < scwDateNow) || 460 (scwClearButton && (scwEle.readOnly || scwEle.disabled)) 461 ) { 462 scwID('scwFoot').style.display = ''; 463 scwID('scwNow').innerHTML = scwToday + ' ' + scwDateNow.scwF
463ormat(scwDateOutput()); 464 scwID('scwClearButton').value = scwClear; 465 if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) > scwDateNow && 466 (new Date(scwBaseYear, 0, 0)) < scwDateNow 467 ) { 468 scwID('scwNow').style.display = ''; 469 if (scwClearButton && (scwEle.readOnly || scwEle.disabled)) { 470 scwID('scwClear').style.display = ''; 471 scwID('scwClear').style.textAlign = 'left'; 472 scwID('scwNow').style.textAlign = 'right'; 473 } else { 474 scwID('scwClear').style.display = 'none'; 475 scwID('scwNow').style.textAlign = 'center'; 476 } 477 } else { 478 scwID('scwClear').style.textAlign = 'center'; 479 scwID('scwClear').style.display = ''; 480 scwID('scwNow').style.display = 'none'; 481 } 482 } else { 483 scwID('scwFoot').style.display = 'none'; 484 } 485 486 if (scwDateValue.length == 0) { 487 scwBlnFullInputDate = false; 488 489 if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) < scwSeedDate || 490 (new Date(scwBaseYear, 0, 1)) > scwSeedDate 491 ) { 492 scwSeedDate = new Date(scwBaseYear + Math.floor(scwDropDownYears / 2), 5, 1); 493 } 494 } else { 495 function scwInputFormat() { 496 var scwArrSeed = new Array(), 497 scwArrInput = scwDateValue.split(new RegExp('[\\' + scwArrDelimiters.join('\\') + ']+', 'g')); 498 499 if (scwArrInput[0] != null) { 500 if (scwArrInput[0].length == 0) { 501 scwArrInput.splice(0, 1); 502 } 503 if (scwArrInput[scwArrInput.length - 1].length == 0) { 504 scwArrInput.splice(scwArrInput.length - 1, 1); 505 } 506 } 507 508 scwBlnFullInputDate = false; 509 510 scwDateOutputFormat = scwDateOutput().toUpperCase(); 511 512 var template = ['D', 'M', 'Y']; 513 514 var result = new Array(); 515 516 for (var i = 0; i < template.length; i++) { 517 if (scwDateOutputFormat.search(template[i]) > -1) { 518 result[scwDateOutputFormat.search(template[i])] = template[i]; 519 } 520 } 521 522 var scwDateSequence = result.join(''); 523 524 switch (scwArrInput.length) { 525 case 1: 526 { 527 if (scwDateOutputFormat.indexOf('Y') > -1 && 528 scwArrInput[0].length > scwDateOutputFormat.lastIndexOf('Y')) { 529 scwArrSeed[0] = parseInt(scwArrInput[0].substring(scwDateOutputFormat.indexOf('Y'), 530 scwDateOutputFormat.lastIndexOf('Y') + 1), 10); 531 } else { 532 scwArrSeed[0] = 0; 533 } 534 535 if (scwDateOutputFormat.indexOf('M') > -1 && 536 scwArrInput[0].length > scwDateOutputFormat.lastIndexOf('M')) { 537 scwArrSeed[1] = scwArrInput[0].substring(scwDateOutputFormat.indexOf('M'), 538 scwDateOutputFormat.lastIndexOf('M') + 1); 539 } else { 540 scwArrSeed[1] = '6'; 541 } 542 543 if (scwDateOutputFormat.indexOf('D') > -1 && 544 scwArrInput[0].length > scwDateOutputFormat.lastIndexOf('D')) { 545 scwArrSeed[2] = parseInt(scwArrInput[0].substring(scwDateOutputFormat.indexOf('D'), 546 scwDateOutputFormat.lastIndexOf('D') + 1), 10); 547 } else { 548 scwArrSeed[2] = 1; 549 } 550 551 if (scwArrInput[0].length == scwDateOutputFormat.length) { 552 scwBlnFullInputDate = true; 553 } 554 break; 555 } 556 case 2: 557 { 558 scwArrSeed[0] = 559 parseInt(scwArrInput[scwDateSequence.replace(/D/i, '').search(/Y/i)], 10); // Year 560 scwArrSeed[1] = scwArrInput[scwDateSequence.replace(/D/i, '').search(/M/i)]; // Month 561 scwArrSeed[2] = 1; // Day 562 break; 563 } 564 case 3: 565 { 566 567 scwArrSeed[0] = 568 parseInt(scwArrInput[scwDateSequence.search(/Y/i)], 10); // Year 569 scwArrSeed[1] = scwArrInput[scwDateSequence.search(/M/i)]; // Month 570 scwArrSeed[2] = 571 parseInt(scwArrInput[scwDateSequence.search(/D/i)], 10); // Day 572 573 scwBlnFullInputDate = true; 574 break; 575 } 576 default: 577 { 578 scwArrSeed[0] = 0; // Year 579 scwArrSeed[1] = 0; // Month 580 scwArrSeed[2] = 0; // Day 581 } 582 } 583 584 var scwExpValDay = new RegExp('^(0?[1-9]|[1-2][0-9]|3[0-1])$'), 585 scwExpValMonth = new RegExp('^(0?[1-9]|1[0-2]|' + 586 scwArrMonthNames.join('|') + 587 ')$', 'i'), 588 scwExpValYear = new RegExp('^([0-9]{1,2}|[0-9]{4})$'); 589 590 if (scwExpValYear.exec(scwArrSeed[0]) == null || 591 scwExpValMonth.exec(scwArrSeed[1]) == null || 592 scwExpValDay.exec(scwArrSeed[2]) == null 593 ) { 594 if (scwShowInvalidDateMsg) { 595 alert(scwInvalidDateMsg + 596 scwInvalidAlert[0] + scwDateValue + 597 scwInvalidAlert[1]); 598 } 599 scwBlnFullInputDate = false; 600 scwArrSeed[0] = scwBaseYear + 601 Math.floor(scwDropDownYears / 2); // Year 602 scwArrSeed[1] = '6'; // Month 603 scwArrSeed[2] = 1; // Day 604 } 605 606 return scwArrSeed; 607 }; 608 609 scwArrSeedDate = scwInputFormat(); 610 if (scwArrSeedDate[0] < 100) { 611 scwArrSeedDate[0] += (scwArrSeedDate[0] > 50) ? 1900 : 2000; 612 } 613 if (scwArrSeedDate[1].search(/\d+/) < 0) { 614 for (i = 0; i < scwArrMonthNames.length; i++) { 615 if (scwArrSeedDate[1].toUpperCase() == scwArrMonthNames[i].toUpperCase()) { 616 scwArrSeedDate[1] = i + 1; 617 break; 618 } 619 } 620 } 621 622 scwSeedDate = new Date(scwArrSeedDate[0], scwArrSeedDate[1] - 1, scwArrSeedDate[2]); 623 } 624 625 if (isNaN(scwSeedDate)) { 626 if (scwShowInvalidDateMsg) { 627 alert(scwInvalidDateMsg + scwInvalidAlert[0] + scwDateValue + scwInvalidAlert[1]); 628 } 629 scwSeedDate = new Date(scwBaseYear + Math.floor(scwDropDownYears / 2), 5, 1); 630 scwBlnFullInputDate = false; 631 } else { 632 if ((new Date(scwBaseYear, 0, 1)) > scwSeedDate) { 633 if (scwBlnStrict && scwShowOutOfRangeMsg) { 634 alert(scwOutOfRangeMsg); 635 } 636 scwSeedDate = new Date(scwBaseYear, 0, 1); 637 scwBlnFullInputDate = false; 638 } else { 639 if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) < scwSeedDate) { 640 if (scwBlnStrict && scwShowOutOfRangeMsg) { 641 alert(scwOutOfRangeMsg); 642 } 643 scwSeedDate = new Date(scwBaseYear + Math.floor(scwDropDownYears) - 1, 11, 1); 644 scwBlnFullInputDate = false; 645 } else { 646 if (scwBlnStrict && scwBlnFullInputDate && 647 (scwSeedDate.getDate() != scwArrSeedDate[2] || 648 (scwSeedDate.getMonth() + 1) != scwArrSeedDate[1] || 649 scwSeedDate.getFullYear() != scwArrSeedDate[0] 650 ) 651 ) { 652 if (scwShowDoesNotExistMsg) alert(scwDoesNotExistMsg); 653 scwSeedDate = new Date(scwSeedDate.getFullYear(), scwSeedDate.getMonth() - 1, 1); 654 scwBlnFullInputDate = false; 655 } 656 } 657 } 658 } 659 660 661 for (var i = 0; i < scwDisabledDates.length; i++) { 662 if (!((typeof scwDisabledDates[i] == 'object') && (scwDisabledDates[i].constructor == Date))) { 663 if ((typeof scwDisabledDates[i] == 'object') && (scwDisabledDates[i].constructor == Array)) { 664 var scwPass = true; 665 666 if (scwDisabledDates[i].length != 2) { 667 if (scwShowRangeDisablingError) { 668 alert(scwRangeDisablingError[0] + scwDisabledDates[i] + scwRangeDisablingError[1]); 669 } 670 scwPass = false; 671 } else { 672 for (var j = 0; j < scwDisabledDates[i].length; j++) { 673 if (!((typeof scwDisabledDates[i][j] == 'object') && (scwDisabledDates[i][j].constructor == Date))) { 674 if (scwShowRangeDisablingError) { 675 alert(scwDateDisablingError[0] + scwDisabledDates[i][j] + scwDateDisablingError[1]); 676 } 677 scwPass = false; 678 } 679 } 680 } 681 682 if (scwPass && (scwDisabledDates[i][0] > scwDisabledDates[i][1])) { 683 scwDisabledDates[i].reverse(); 684 } 685 } else { 686 if (scwShowRangeDisablingError) { 687 alert(scwDateDisablingError[0] + scwDisabledDates[i] + scwDateDisablingError[1]); 688 } 689 } 690 } 691 } 692 693 694 scwMonthSum = 12 * (scwSeedDate.getFullYear() - scwBaseYear) + scwSeedDate.getMonth(); 695 696 scwID('scwYears').options.selectedIndex = Math.floor(scwMonthSum / 12); 697 scwID('scwMonths').options.selectedIndex = (scwMonthSum % 12); 698 699 scwID('scwDrag').style.display = (scwAllowDrag) ? '' : 'none'; 700 701 scwShowMonth(0); 702 scwTargetEle = scwEle; 703 704 var offsetTop = parseInt(scwEle.offsetTop, 10) + parseInt(scwEle.offsetHeight, 10), 705 offsetLeft = parseInt(scwEle.offsetLeft, 10); 706 707 if (!window.opera) { 708 while (scwEle.tagName != 'BODY' && scwEle.tagName != 'HTML') { 709 offsetTop -= parseInt(scwEle.scrollTop, 10); 710 offsetLeft -= parseInt(scwEle.scrollLeft, 10); 711 scwEle = scwEle.parentNode; 712 } 713 scwEle = scwTargetEle; 714 } 715 716 do { 717 scwEle = scwEle.offsetParent; 718 offsetTop += parseInt(scwEle.offsetTop, 10); 719 offsetLeft += parseInt(scwEle.offsetLeft, 10); 720 } 721 while (scwEle.tagName != 'BODY' && scwEle.tagName != 'HTML'); 722 723 if (scwAutoPosition) { 724 var scwWidth = parseInt(scwID('scw').offsetWidth, 10), 725 scwHeight = parseInt(scwID('scw').offsetHeight, 10), 726 scwWindowLeft = 727 (document.body && document.body.scrollLeft) ? 728 document.body.scrollLeft //DOM compliant 729 : 730 (document.documentElement && document.documentElement.scrollLeft) ? 731 document.documentElement.scrollLeft //IE6+ standards compliant 732 : 733 0, //Failed 734 scwWindowWidth = 735 (typeof (innerWidth) == 'number') ? 736 innerWidth //DOM compliant 737 : 738 (document.documentElement && document.documentElement.clientWidth) ? 739 document.documentElement.clientWidth //IE6+ standards compliant 740 : 741 (document.body && document.body.clientWidth) ? 742 document.body.clientWidth //IE non-compliant 743 : 744 0, //Failed 745 scwWindowTop = 746 (document.body && document.body.scrollTop) ? 747 document.body.scrollTop //DOM compliant 748 : 749 (document.documentElement && document.documentElement.scrollTop) ? 750 document.documentElement.scrollTop //IE6+ standards compliant 751 : 752 0, //Failed 753 scwWindowHeight = 754 (typeof (innerHeight) == 'number') ? 755 innerHeight //DOM compliant 756 : 757 (document.documentElement && document.documentElement.clientHeight) ? 758 document.documentElement.clientHeight //IE6+ standards compliant 759 : 760 (document.body && document.body.clientHeight) ? 761 document.body.clientHeight //IE non-compliant 762 : 763 0; //Failed 764 765 offsetLeft -= (offsetLeft - scwWidth + parseInt(scwTargetEle.offsetWidth, 10) >= scwWindowLeft && 766 offsetLeft + scwWidth > scwWindowLeft + scwWindowWidth 767 ) ? (scwWidth - parseInt(scwTargetEle.offsetWidth, 10)) : 0; 768 769 offsetTop -= (offsetTop - scwHeight - parseInt(scwTargetEle.offsetHeight, 10) >= scwWindowTop && 770 offsetTop + scwHeight > scwWindowTop + scwWindowHeight 771 ) ? (scwHeight + parseInt(scwTargetEle.offsetHeight, 10)) : 0; 772 } 773 774 scwID('scw').style.top = offsetTop + 'px'; 775 scwID('scw').style.left = offsetLeft + 'px'; 776 scwID('scwIframe').style.top = offsetTop + 'px'; 777 scwID('scwIframe').style.left = offsetLeft + 'px'; 778 779 scwID('scwIframe').style.width = (scwID('scw').offsetWidth - (scwID('scwIE') ? 2 : 4)) + 'px';
780 scwID('scwIframe').style.height = (scwID('scw').offsetHeight - (scwID('scwIE') ? 2 : 4)) + 'px'; 781 scwID('scwIframe').style.visibility = 'inherit'; 782 783 // Show it on the page 784 scwID('scw').style.visibility = 'inherit'; 785 }; 786 787 function scwHide() { 788 scwID('scw').style.visibility = 'hidden'; 789 scwID('scwIframe').style.visibility = 'hidden'; 790 791 792 scwID('scw').style.top = '0px'; 793 scwID('scw').style.left = '0px'; 794 scwID('scwIframe').style.top = '0px'; 795 scwID('scwIframe').style.left = '0px'; 796 797 scwID('scwIframe').style.width = '0px'; 798 scwID('scwIframe').style.height = '0px'; 799 800 801 if (typeof scwNextAction != 'undefined' && scwNextAction != null) { 802 scwNextActionReturn = scwNextAction(); 803 // Explicit null set to prevent closure causing memory leak 804 scwNextAction = null; 805 } 806 }; 807 808 function scwCancel(scwEvt) { 809 if (scwClickToHide) { 810 scwHide(); 811 } 812 scwStopPropagation(scwEvt); 813 }; 814 815 function scwStopPropagation(scwEvt) { 816 if (scwEvt.stopPropagation) { 817 scwEvt.stopPropagation(); 818 } // Capture phase 819 else { 820 scwEvt.cancelBubble = true; 821 } // Bubbling phase 822 }; 823 824 function scwBeginDrag(event) { 825 var elementToDrag = scwID('scw'); 826 827 var deltaX = event.clientX, 828 deltaY = event.clientY, 829 offsetEle = elementToDrag; 830 831 do { 832 deltaX -= parseInt(offsetEle.offsetLeft, 10); 833 deltaY -= parseInt(offsetEle.offsetTop, 10); 834 offsetEle = offsetEle.offsetParent; 835 } 836 while (offsetEle.tagName != 'BODY' && 837 offsetEle.tagName != 'HTML'); 838 839 if (document.addEventListener) { 840 document.addEventListener('mousemove', moveHandler, true); // Capture phase 841 document.addEventListener('mouseup', upHandler, true); // Capture phase 842 } else { 843 elementToDrag.attachEvent('onmousemove', moveHandler); // Bubbling phase 844 elementToDrag.attachEvent('onmouseup', upHandler); // Bubbling phase 845 elementToDrag.setCapture(); 846 } 847 848 scwStopPropagation(event); 849 850 function moveHandler(scwEvt) { 851 if (!scwEvt) scwEvt = window.event; 852 853 elementToDrag.style.left = (scwEvt.clientX - deltaX) + 'px'; 854 elementToDrag.style.top = (scwEvt.clientY - deltaY) + 'px'; 855 856 scwID('scwIframe').style.left = (scwEvt.clientX - deltaX) + 'px'; 857 scwID('scwIframe').style.top = (scwEvt.clientY - deltaY) + 'px'; 858 859 scwStopPropagation(scwEvt); 860 }; 861 862 function upHandler(scwEvt) { 863 if (!scwEvt) scwEvt = window.event; 864 865 if (document.removeEventListener) { 866 document.removeEventListener('mousemove', moveHandler, true); // Capture phase 867 document.removeEventListener('mouseup', upHandler, true); // Capture phase 868 } else { 869 elementToDrag.detachEvent('onmouseup', upHandler); // Bubbling phase 870 elementToDrag.detachEvent('onmousemove', moveHandler); // Bubbling phase 871 elementToDrag.releaseCapture(); 872 } 873 874 scwStopPropagation(scwEvt); 875 }; 876 }; 877 878 function scwShowMonth(scwBias) { 879 var scwShowDate = new Date(Date.parse(new Date().toDateString())), 880 scwStartDate = new Date(); 881 882 scwShowDate.setHours(12); 883 884 scwSelYears = scwID('scwYears'); 885 scwSelMonths = scwID('scwMonths'); 886 887 if (scwSelYears.options.selectedIndex > -1) { 888 scwMonthSum = 12 * (scwSelYears.options.selectedIndex) + scwBias; 889 if (scwSelMonths.options.selectedIndex > -1) { 890 scwMonthSum += scwSelMonths.options.selectedIndex; 891 } 892 } else { 893 if (scwSelMonths.options.selectedIndex > -1) { 894 scwMonthSum += scwSelMonths.options.selectedIndex; 895 } 896 } 897 898 scwShowDate.setFullYear(scwBaseYear + Math.floor(scwMonthSum / 12), (scwMonthSum % 12), 1); 899 900 scwID('scwWeek_').style.display = (scwWeekNumberDisplay) ? '' : 'none'; 901 if (window.opera) { 902 scwID('scwMonths').style.display = 'inherit'; 903 scwID('scwYears').style.display = 'inherit'; 904 } 905 906 scwTemp = (12 * parseInt((scwShowDate.getFullYear() - scwBaseYear), 10)) + parseInt(scwShowDate.getMonth(), 10); 907 908 if (scwTemp > -1 && scwTemp < (12 * scwDropDownYears)) { 909 scwSelYears.options.selectedIndex = Math.floor(scwMonthSum / 12); 910 scwSelMonths.options.selectedIndex = (scwMonthSum % 12); 911 912 scwCurMonth = scwShowDate.getMonth(); 913 914 scwShowDate.setDate((((scwShowDate.getDay() - scwWeekStart) < 0) ? -6 : 1) + 915 scwWeekStart - scwShowDate.getDay()); 916 917 // This statement moved by Michael Cerveny to make version 3.55 918 var scwCompareDateValue = new Date(scwShowDate.getFullYear(), 919 scwShowDate.getMonth(), 920 scwShowDate.getDate()).valueOf(); 921 922 scwStartDate = new Date(scwShowDate); 923 924 if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) > scwDateNow && 925 (new Date(scwBaseYear, 0, 0)) < scwDateNow) { 926 var scwNow = scwID('scwNow'); 927 928 function scwNowOutput() { 929 scwSetOutput(scwDateNow); 930 }; 931 932 if (scwDisabledDates.length == 0) { 933 if (scwActiveToday && scwParmActiveToday) { 934 scwNow.onclick = scwNowOutput; 935 scwNow.className = 'scwNow'; 936 937 if (scwID('scwIE')) {
938 scwNow.onmouseover = scwChangeClass; 939 scwNow.onmouseout = scwChangeClass; 940 } 941 942 } else { 943 scwNow.onclick = null; 944 scwNow.className = 'scwNowDisabled'; 945 946 if (scwID('scwIE')) { 947 scwNow.onmouseover = null; 948 scwNow.onmouseout = null; 949 } 950 951 if (document.addEventListener) { 952 scwNow.addEventListener('click', scwStopPropagation, false); 953 } else { 954 scwNow.attachEvent('onclick', scwStopPropagation); 955 } 956 } 957 } else { 958 for (var k = 0; k < scwDisabledDates.length; k++) { 959 if (!scwActiveToday || !scwParmActiveToday || 960 ((typeof scwDisabledDates[k] == 'object') && 961 (((scwDisabledDates[k].constructor == Date) && 962 scwDateNow.valueOf() == scwDisabledDates[k].valueOf() 963 ) || 964 ((scwDisabledDates[k].constructor == Array) && 965 scwDateNow.valueOf() >= scwDisabledDates[k][0].valueOf() && 966 scwDateNow.valueOf() <= scwDisabledDates[k][1].valueOf() 967 ) 968 ) 969 ) 970 ) { 971 scwNow.onclick = null; 972 scwNow.className = 'scwNowDisabled'; 973 974 if (scwID('scwIE')) { 975 scwNow.onmouseover = null; 976 scwNow.onmouseout = null; 977 } 978 979 if (document.addEventListener) { 980 scwNow.addEventListener('click', scwStopPropagation, false); 981 } else { 982 scwNow.attachEvent('onclick', scwStopPropagation); 983 } 984 break; 985 } else { 986 scwNow.onclick = scwNowOutput; 987 scwNow.className = 'scwNow'; 988 989 if (scwID('scwIE')) { 990 scwNow.onmouseover = scwChangeClass; 991 scwNow.onmouseout = scwChangeClass; 992 } 993 } 994 } 995 } 996 } 997 998 function scwSetOutput(scwOutputDate) { 999 if (typeof scwTargetEle.value == 'undefined') { 1000 scwTriggerEle.scwTextNode.replaceData(0, scwTriggerEle.scwLength, scwOutputDate.scwFormat(scwDateOutputFormat)); 1001 } else { 1002 scwTargetEle.value = scwOutputDate.scwFormat(scwDateOutputFormat); 1003 } 1004 scwHide(); 1005 setNights(); 1006 }; 1007 1008 function scwCellOutput(scwEvt) { 1009 var scwEle = scwEventTrigger(scwEvt), 1010 scwOutputDate = new Date(scwStartDate); 1011 1012 if (scwEle.nodeType == 3) scwEle = scwEle.parentNode; 1013 1014 scwOutputDate.setDate(scwStartDate.getDate() + parseInt(scwEle.id.substr(8), 10)); 1015 1016 scwSetOutput(scwOutputDate); 1017 }; 1018 1019 function scwChangeClass(scwEvt) { 1020 var scwEle = scwEventTrigger(scwEvt); 1021 1022 if (scwEle.nodeType == 3) { 1023 scwEle = scwEle.parentNode; 1024 } 1025 1026 switch (scwEle.className) { 1027 case 'scwCells': 1028 scwEle.className = 'scwCellsHover'; 1029 break; 1030 case 'scwCellsHover': 1031 scwEle.className = 'scwCells'; 1032 break; 1033 case 'scwCellsExMonth': 1034 scwEle.className = 'scwCellsExMonthHover'; 1035 break; 1036 case 'scwCellsExMonthHover': 1037 scwEle.className = 'scwCellsExMonth'; 1038 break; 1039 case 'scwCellsWeekend': 1040 scwEle.className = 'scwCellsWeekendHover'; 1041 break; 1042 case 'scwCellsWeekendHover': 1043 scwEle.className = 'scwCellsWeekend'; 1044 break; 1045 case 'scwNow': 1046 scwEle.className = 'scwNowHover'; 1047 break; 1048 case 'scwNowHover': 1049 scwEle.className = 'scwNow'; 1050 break; 1051 case 'scwInputDate': 1052 scwEle.className = 'scwInputDateHover'; 1053 break; 1054 case 'scwInputDateHover': 1055 scwEle.className = 'scwInputDate'; 1056 } 1057 1058 return true; 1059 } 1060 1061 function scwEventTrigger(scwEvt) { 1062 if (!scwEvt) { 1063 scwEvt = event; 1064 } 1065 return scwEvt.target || scwEvt.srcElement; 1066 }; 1067 1068 function scwWeekNumber(scwInDate) { // The base day in the week of the input date 1069 var scwInDateWeekBase = new Date(scwInDate); 1070 1071 scwInDateWeekBase.setDate(scwInDateWeekBase.getDate() - 1072 scwInDateWeekBase.getDay() + 1073 scwWeekNumberBaseDay 1074 1075 + 1076 ((scwInDate.getDay() > 1077 scwWeekNumberBaseDay) ? 7 : 0)); 1078 1079 // The first Base Day in the year 1080 var scwFirstBaseDay = new Date(scwInDateWeekBase.getFullYear(), 0, 1); 1081 1082 scwFirstBaseDay.setDate(scwFirstBaseDay.getDate() - 1083 scwFirstBaseDay.getDay() + 1084 scwWeekNumberBaseDay 1085 ); 1086 1087 if (scwFirstBaseDay < new Date(scwInDateWeekBase.getFullYear(), 0, 1)) { 1088 scwFirstBaseDay.setDate(scwFirstBaseDay.getDate() + 7); 1089 } 1090 1091 // Start of Week 01 1092 var scwStartWeekOne = new Date(scwFirstBaseDay - 1093 scwWeekNumberBaseDay + 1094 scwInDate.getDay()); 1095 1096 if (scwStartWeekOne > scwFirstBaseDay) { 1097 scwStartWeekOne.setDate(scwStartWeekOne.getDate() - 7); 1098 } 1099 1100 var scwWeekNo = '0' + (Math.round((scwInDateWeekBase - scwFirstBaseDay) / 604800000, 0) + 1); 1101 1102 return scwWeekNo.substring(scwWeekNo.length - 2, scwWeekNo.length); 1103 }; 1104 var scwCells = scwID('scwCells'); 1105 1106 for (i = 0; i < scwCells.childNodes.length; i++) { 1107 var scwRows = scwCells.childNodes[i];
1108 if (scwRows.nodeType == 1 && scwRows.tagName == 'TR') { 1109 if (scwWeekNumberDisplay) { //Calculate the week number using scwShowDate 1110 scwTmpEl = scwRows.childNodes[0]; 1111 scwTmpEl.innerHTML = scwWeekNumber(scwShowDate); 1112 scwTmpEl.style.borderColor = 1113 (scwTmpEl.currentStyle) ? 1114 scwTmpEl.currentStyle['backgroundColor'] : 1115 (window.getComputedStyle) ? 1116 document.defaultView.getComputedStyle(scwTmpEl, null).getPropertyValue('background-color') : 1117 ''; 1118 scwTmpEl.style.display = ''; 1119 } else { 1120 scwRows.childNodes[0].style.display = 'none'; 1121 } 1122 1123 for (j = 1; j < scwRows.childNodes.length; j++) { 1124 var scwCols = scwRows.childNodes[j]; 1125 if (scwCols.nodeType == 1 && scwCols.tagName == 'TD') { 1126 scwRows.childNodes[j].innerHTML = 1127 scwShowDate.getDate(); 1128 var scwCell = scwRows.childNodes[j], 1129 scwDisabled = 1130 ((scwOutOfRangeDisable && 1131 (scwShowDate < 1132 (new Date(scwBaseYear, 0, 1, 1133 scwShowDate.getHours())) || 1134 scwShowDate > 1135 (new Date(scwBaseYear + 1136 scwDropDownYears, 0, 0, 1137 scwShowDate.getHours())) 1138 ) 1139 ) || 1140 (scwOutOfMonthDisable && 1141 (scwShowDate < 1142 (new Date(scwShowDate.getFullYear(), 1143 scwCurMonth, 1, 1144 scwShowDate.getHours())) || 1145 scwShowDate > 1146 (new Date(scwShowDate.getFullYear(), 1147 scwCurMonth + 1, 0, 1148 scwShowDate.getHours())) 1149 ) 1150 ) 1151 ) ? true : false; 1152 1153 scwCell.style.visibility = 1154 (scwOutOfMonthHide && 1155 (scwShowDate < 1156 (new Date(scwShowDate.getFullYear(), 1157 scwCurMonth, 1, 1158 scwShowDate.getHours())) || 1159 scwShowDate > 1160 (new Date(scwShowDate.getFullYear(), 1161 scwCurMonth + 1, 0, 1162 scwShowDate.getHours())) 1163 ) 1164 ) ? 'hidden' : 'inherit'; 1165 1166 for (var k = 0; k < scwDisabledDates.length; k++) { 1167 if ((typeof scwDisabledDates[k] == 'object') && 1168 (scwDisabledDates[k].constructor == Date) && 1169 scwCompareDateValue == scwDisabledDates[k].valueOf() 1170 ) { 1171 scwDisabled = true; 1172 } else { 1173 if ((typeof scwDisabledDates[k] == 'object') && 1174 (scwDisabledDates[k].constructor == Array) && 1175 scwCompareDateValue >= scwDisabledDates[k][0].valueOf() && 1176 scwCompareDateValue <= scwDisabledDates[k][1].valueOf() 1177 ) { 1178 scwDisabled = true; 1179 } 1180 } 1181 } 1182 1183 if (scwDisabled || 1184 !scwEnabledDay[j - 1 + (7 * ((i * scwCells.childNodes.length) / 6))] || 1185 !scwPassEnabledDay[(j - 1 + (7 * (i * scwCells.childNodes.length / 6))) % 7] 1186 ) { 1187 scwRows.childNodes[j].onclick = null; 1188 1189 if (scwID('scwIE')) { 1190 scwRows.childNodes[j].onmouseover = null; 1191 scwRows.childNodes[j].onmouseout = null; 1192 } 1193 1194 scwCell.className = 1195 (scwShowDate.getMonth() != scwCurMonth) ? 1196 'scwCellsExMonthDisabled' : 1197 (scwBlnFullInputDate && 1198 scwShowDate.toDateString() == 1199 scwSeedDate.toDateString()) ? 1200 'scwInputDateDisabled' : 1201 (scwShowDate.getDay() % 6 == 0) ? 1202 'scwCellsWeekendDisabled' : 1203 'scwCellsDisabled'; 1204 1205 scwCell.style.borderColor = 1206 (scwFormatTodayCell && scwShowDate.toDateString() == scwDateNow.toDateString()) ? 1207 scwTodayCellBorderColour : 1208 (scwCell.currentStyle) ? 1209 scwCell.currentStyle['backgroundColor'] : 1210 (window.getComputedStyle) 1211 1212 ? 1213 document.defaultView.getComputedStyle(scwCell, null).getPropertyValue('background-color'): ''; 1214 } else { 1215 scwRows.childNodes[j].onclick = scwCellOutput; 1216 1217 if (scwID('scwIE')) {
1218 scwRows.childNodes[j].onmouseover = scwChangeClass; 1219 scwRows.childNodes[j].onmouseout = scwChangeClass; 1220 } 1221 1222 scwCell.className = 1223 (scwShowDate.getMonth() != scwCurMonth) ? 1224 'scwCellsExMonth' : 1225 (scwBlnFullInputDate && 1226 scwShowDate.toDateString() == 1227 scwSeedDate.toDateString()) ? 1228 'scwInputDate' : 1229 (scwShowDate.getDay() % 6 == 0) ? 1230 'scwCellsWeekend' : 1231 'scwCells'; 1232 1233 scwCell.style.borderColor = 1234 (scwFormatTodayCell && scwShowDate.toDateString() == scwDateNow.toDateString()) ? 1235 scwTodayCellBorderColour : 1236 (scwCell.currentStyle) ? 1237 scwCell.currentStyle['backgroundColor'] : 1238 (window.getComputedStyle) ? 1239 document.defaultView.getComputedStyle(scwCell, null).getPropertyValue('background-color') : 1240 ''; 1241 } 1242 1243 scwShowDate.setDate(scwShowDate.getDate() + 1); 1244 scwCompareDateValue = new Date(scwShowDate.getFullYear(), scwShowDate.getMonth(), scwShowDate.getDate()).valueOf(); 1245 } 1246 } 1247 } 1248 } 1249 } 1250 1251 if (window.opera) { 1252 scwID('scwMonths').style.display = 'inline'; 1253 scwID('scwYears').style.display = 'inline'; 1254 scwID('scw').style.visibility = 'hidden'; 1255 scwID('scw').style.visibility = 'inherit'; 1256 } 1257 }; 1258 1259 document.writeln("<!--[if IE]><div id='scwIE'></div><![endif]-->"); 1260 document.writeln("<!--[if lt IE 7]><div id='scwIElt7'></div><![endif]-->"); 1261 document.write( 1262 "<iframe class='scw' " + (scwID('scwIElt7') ? "src='/scwblank.html '" : '') + 1263 "id='scwIframe' name='scwIframe' frameborder='0'>" + 1264 "</iframe>" + 1265 "<table id='scw' class='scw'>" + 1266 "<tr class='scw'>" + 1267 "<td class='scw'>" + 1268 "<table class='scwHead' id='scwHead' align='center' width='100%' " + 1269 "cellspacing='0' cellpadding='0'>" + 1270 "<tr id='scwDrag' style='display:none;'>" + 1271 "<td colspan='6' class='scwDrag' " + 1272 "onmousedown='scwBeginDrag(event);'>" + 1273 "<span id='scwDragText'></span>" + 1274 "</td>" + 1275 "</tr>" + 1276 "<tr class='scwHead' >" + 1277 "<td align='right' class='scwHead'>" + 1278 "<input class='scwHead' id='scwHeadLeft' type='button' value='<' " + 1279 "onclick='scwShowMonth(-1);' /></td>" + 1280 "<td align='left' class='scwHead'>" + 1281 "<select id='scwMonths' class='scwHead' " + 1282 "onchange='scwShowMonth(0);'>" + 1283 "</select>" + 1284 "</td>" + 1285 "<td align='right' class='scwHead'>" + ' ' + "</td>" + 1286 "<td align='right' class='scwHead'>" + ' ' + "</td>" + 1287 "<td align='right' class='scwHead'>" + 1288 "<select id='scwYears' class='scwHead' " + 1289 "onchange='scwShowMonth(0);'>" + 1290 "</select>" + 1291 "</td>" + 1292 "<td align='left' class='scwHead'>" + 1293 "<input class='scwHead' id='scwHeadRight' type='button' value='>' " + 1294 "onclick='scwShowMonth(1);' /></td>" + 1295 "</tr>" + 1296 "</table>" + 1297 "</td>" + 1298 "</tr>" + 1299 "<tr class='scw'>" + 1300 "<td class='scw'>" + 1301 "<table class='scwCells' align='center' width='100%' cellpadding='3' cellspacing='1' bgcolor='#75adc5' >" + 1302 "<thead>" + 1303 "<tr><td bgcolor='#f2f2f2' class='scwWeekNumberHead' id='scwWeek_' ></td>"); 1304 1305 for (i = 0; i < 7; i++) { 1306 document.write( 1307 "<td bgcolor='#f2f2f2' class='scwWeek' id='scwWeekInit" + i + "'></td>"); 1308 } 1309 1310 document.write("</tr>" + 1311 "</thead>" + 1312 "<tbody id='scwCells' onClick='scwStopPropagation(event);'>"); 1313 1314 for (i = 0; i < 6; i++) { 1315 document.write( 1316 "<tr>" + 1317 "<td bgcolor='#f2f2f2' class='scwWeekNo' id='scwWeek_" + i + "'></td>"); 1318 for (j = 0; j < 7; j++) { 1319 document.write( 1320 "<td bgcolor='#f2f2f2' class='scwCells' id='scwCell_" + (j + (i * 7)) + 1321 "'></td>"); 1322 } 1323 1324 document.write( 1325 "</tr>"); 1326 } 1327 1328 document.write( 1329 "</tbody>" + 1330 "<tfoot>" + 1331 "<tr id='scwFoot' bgcolor='#f2f2f2' >" + 1332 "<td colspan='8' style='padding:1px;' bgcolor='#f2f2f2' >" + 1333 "<table width='100%'>" + 1334 "<tr>" + 1335 "<td id='scwClear' class='scwClear'>" + 1336 "<input type='button' id='scwClearButton' class='scwClear' " + 1337 "onclick='scwTargetEle.value = \"\";scwHide();' />" + 1338 "</td>" + 1339 "<td bgcolor='#f2f2f2' class='scwNow' id='scwNow'></td>" + 1340 "</tr>" + 1341 "</table>" + 1342 "</td>" + 1343 "</tr>" + 1344 "</tfoot>" + 1345 "</table>" + 1346 "</td>" + 1347 "</tr>" + 1348 "</table>"); 1349 1350 if (document.addEventListener) { 1351 scwID('scw').addEventListener('click', scwCancel, false); 1352 scwID('scwHeadLeft').addEventListener('click', scwStopPropagation, false); 1353 scwID('scwMonths').addEventListener('click', scwStopPropagation, false); 1354 scwID('scwMonths').addEventListener('change', scwStopPropagation, false); 1355 scwID('scwYears').addEventListener('click', scwStopPropagation, false); 1356 scwID('scwYears').addEventListener('change', scwStopPropagation, false); 1357 scwID('scwHeadRight').addEventListener('click', scwStopPropagation, false); 1358 } else { 1359 scwID('scw').attachEvent('onclick', scwCancel); 1360 scwID('scwHeadLeft').attachEvent('onclick', scwStopPropagation); 1361 scwID('scwMonths').attachEvent('onclick', scwStopPropagation); 1362 scwID('scwMonths').attachEvent('onchange', scwStopPropagation); 1363 scwID('scwYears').attachEvent('onclick', scwStopPropagation); 1364 scwID('scwYears').attachEvent('onchange', scwStopPropagation); 1365 scwID('scwHeadRight').attachEvent('onclick', scwStopPropagation); 1366 } 1367 1368 1369 if (document.addEventListener) { 1370 document.addEventListener('click', scwHide, false); 1371 } else { 1372 document.attachEvent('onclick', scwHide); 1373 } 1374 1375 function clickedstartdate(event) { 1376 1377 1378 var mydate = new Date(); 1379 mydate.setDate(mydate.getDate() - 1); 1380 1381 var theyear = mydate.getFullYear(); 1382 var themonth = mydate.getMonth(); 1383 var theyesterday = mydate.getDate(); 1384 1385 1386 scwDisabledDates[0] = [new Date(2000, 0, 1), new Date(theyear, themonth, theyesterday)]; 1387 1388 scwShow(document.getElementById("dateStart"), event); 1389 //scwNextAction=trivialAlert.runsAfterSCW(this); 1390 } 1391 1392 function clickedenddate(event) { 1393 1394 var mydate = new Date(); 1395 mydate.setDate(mydate.getDate() - 1); 1396 1397 var theyear = mydate.getFullYear(); 1398 var themonth = mydate.getMonth(); 1399 var theyesterday = mydate.getDate(); 1400 1401 scwDisabledDates[0] = [new Date(2000, 0, 1), new Date(theyear, themonth, theyesterday)]; 1402 1403 1404 scwShow(document.getElementById("dateEnd"), event); 1405 1406 1407 } 1408 1409 function ReverseUSDate(dateStr) { 1410 dateStr = dateStr.split("/"); 1411 1412 var nwVal = dateStr[1] + '/' + dateStr[0] + '/' + dateStr[2]; 1413 return nwVal; 1414 } 1415 1416 function sendToReservation() { 1417 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 1418 if (validateForm()) { 1419 var beFilterName = document.forms["chkAvailabilityForm"].beFilterName.value; 1420 var beFilterValue = document.forms["chkAvailabilityForm"].beFilterVal.value; 1421 if (document.forms["chkAvailabilityForm"].openInNewWindow.value == "1") { 1422 var sendStrDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateStart.value) 1423 var sendEndDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateEnd.value) 1424 1425 if (document.forms["chkAvailabilityForm"].adults.value != null) 1426 mine = window.open("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value + "/logon.aspx?adults=" + document.forms["chkAvailabilityForm"].adults.value + "&children=" + document.forms["chkAvailabilityForm"].children.value + "&dateStart=" + sendStrDate + "&dateEnd=" + sendEndDate + "&" + beFilterName + "=" + beFilterValue + "&promoCode=" + document.forms["chkAvailabilityForm"].promoCode.value); 1427 else 1428 mine = window.open("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value); 1429 window.document.location.replace("index.html"); 1430 } else { 1431 if (document.forms["chkAvailabilityForm"].useIFrame.value == "1") { 1432 document.forms["chkAvailabilityForm"].submit(); 1433 } else { 1434 // If iFrame is not exist than opening in the same window. 1435 var mine; 1436 var sendStrDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateStart.value) 1437 var sendEndDate = ReverseUSDate(document.forms["chkAvailabilityForm"].dateEnd.value) 1438 if (document.forms["chkAvailabilityForm"].adults.value != null) 1439 window.top.location.replace("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value + "/logon.aspx?adults=" + document.forms["chkAvailabilityForm"].adults.value + "&children=" + document.forms["chkAvailabilityForm"].children.value + "&dateStart=" + sendStrDate + "&dateEnd=" + sendEndDate + "&" + beFilterName + "=" + beFilterValue + "&promoCode=" + document.forms["chkAvailabilityForm"].promoCode.value); 1440 else 1441 window.top.location.replace("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value); 1442 } 1443 } 1444 } 1445 1446 } else { 1447 if (validateForm()) { 1448 var beFilterName = document.forms["chkAvailabilityForm"].beFilterName.value; 1449 var beFilterValue = document.forms["chkAvailabilityForm"].beFilterVal.value; 1450 1451 if (document.forms["chkAvailabilityForm"].openInNewWindow.value == "1") { 1452 if (document.forms["chkAvailabilityForm"].adults.value != null) 1453 mine = window.open("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value + "/logon.aspx?adults=" + document.forms["chkAvailabilityForm"].adults.value + "&children=" + document.forms["chkAvailabilityForm"].children.value + "&dateStart=" + document.forms["chkAvailabilityForm"].dateStart.value + "&dateEnd=" + document.forms["chkAvailabilityForm"].dateEnd.value + "&" + beFilterName + "=" + beFilterValue + "&promoCode=" + document.forms["chkAvailabilityForm"].promoCode.value); 1454 else 1455 mine = window.open("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value); 1456 window.document.location.replace("index.html"); 1457 } else { 1458 if (document.forms["chkAvailabilityForm"].useIFrame.value == "1") { 1459 document.forms["chkAvailabilityForm"].submit(); 1460 } else { 1461 // If iFrame is not exist than opening in the same window. 1462 var mine; 1463 1464 if (document.forms["chkAvailabilityForm"].adults.value != null) { 1465 var newQueryString = "&pAdults=" + document.forms["chkAvailabilityForm"].adults.value + "&pChildren=" + document.forms["chkAvailabilityForm"].children.value + "&pDateStart=" + document.forms["chkAvailabilityForm"].dateStart.value + "&pDateEnd=" + document.forms["chkAvailabilityForm"].dateEnd.value; 1466 window.top.location.replace("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value + "/logon.aspx?adults=" + document.forms["chkAvailabilityForm"].adults.value + "&children=" + document.forms["chkAvailabilityForm"].children.value + "&dateStart=" + document.forms["chkAvailabilityForm"].dateStart.value + "&dateEnd=" + document.forms["chkAvailabilityForm"].dateEnd.value + "&" + beFilterName + "=" + beFilterValue + "&promoCode=" + document.forms["chkAvailabilityForm"].promoCode.value + newQueryString); 1467 } else 1468 window.top.location.replace("http://clients.innroad.com/" + document.forms["chkAvailabilityForm"].clientCode.value); 1469 1470 } 1471 } 1472 } 1473 1474 } 1475 } 1476 1477 function validateForm() { 1478 if (document.forms["chkAvailabilityForm"].beFilterVal.value == '') { 1479 if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'town') 1480 alert("Please select a Town"); 1481 if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'property') 1482 alert("Please select a Property"); 1483 if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'roomclass') 1484 alert("Please select a Room Class"); 1485 1486 document.forms["chkAvailabilityForm"].beFilterVal.focus(); 1487 return false; 1488 } 1489 1490 if (!validateNotEmpty(trim(document.forms["chkAvailabilityForm"].dateStart.value))) { 1491 alert("Please enter Checkin Date");
1492 document.forms["chkAvailabilityForm"].dateStart.focus(); 1493 return false; 1494 } 1495 1496 if (!validateNotEmpty(trim(document.forms["chkAvailabilityForm"].dateEnd.value))) { 1497 alert("Please enter Checkout Date"); 1498 document.forms["chkAvailabilityForm"].dateEnd.focus(); 1499 return false; 1500 } 1501 1502 if (validateDateOffset()) { 1503 if (document.forms["chkAvailabilityForm"].adults.value == '0') { 1504 alert("Please select adults"); 1505 document.forms["chkAvailabilityForm"].adults.focus(); 1506 return false; 1507 } else 1508 return true; 1509 } else 1510 return false; 1511 } 1512 1513 function validateDateOffset() { 1514 1515 var returnVal = true; 1516 var startDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateStart.value)).getTime(); 1517 var endDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateEnd.value)).getTime(); 1518 1519 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 1520 startDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateStart.value)).getTime(); 1521 endDateTime = new Date(FormatUSDate(document.forms["chkAvailabilityForm"].dateEnd.value)).getTime(); 1522 } else { 1523 startDateTime = new Date(document.forms["chkAvailabilityForm"].dateStart.value).getTime(); 1524 endDateTime = new Date(document.forms["chkAvailabilityForm"].dateEnd.value).getTime(); 1525 1526 } 1527 var curDate = new Date(); 1528 1529 var y = curDate.getFullYear(); 1530 1531 // if(navigator.appName=='Netscape') 1532 // { 1533 // y = y + 1900; 1534 // } 1535 curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate())); 1536 var curDateTime = curDate.getTime(); 1537 1538 var one_day = 1000 * 60 * 60 * 24; 1539 1540 if (startDateTime >
1540= endDateTime) { 1541 alert("Please enter valid Check Out date"); 1542 returnVal = false; 1543 1544 } else { 1545 if (document.forms["chkAvailabilityForm"].daysOffset.value > 0) { 1546 if (startDateTime > curDateTime) { 1547 if (Math.ceil((startDateTime - curDateTime) / (one_day)) < document.forms["chkAvailabilityForm"].daysOffset.value) { 1548 alert("Please enter Check In date which is greater than " + document.forms["chkAvailabilityForm"].daysOffset.value + " from now"); 1549 returnVal = false; 1550 } 1551 } else { 1552 alert("Please enter Check In date which is greater than " + document.forms["chkAvailabilityForm"].daysOffset.value + " from now"); 1553 returnVal = false; 1554 } 1555 } 1556 } 1557 return returnVal; 1558 } 1559 1560 function populateDates() { 1561 var curDate = new Date(); 1562 var targetTZ = parseInt(document.forms["chkAvailabilityForm"].PropTimeZone.value); 1563 var currtz = curDate.getTimezoneOffset(); 1564 var diffInMins = currtz + targetTZ; 1565 1566 curDate.setTime(curDate.getTime() + diffInMins * 60 * 1000); 1567 1568 var y = curDate.getFullYear(); 1569 1570 // if(navigator.appName == 'Netscape') 1571 // { 1572 // y = y + 1900; 1573 // } 1574 1575 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 1576 1577 curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate()) + parseInt(document.forms["chkAvailabilityForm"].daysOffset.value)); 1578 document.forms["chkAvailabilityForm"].dateStart.value = formatDate(curDate, "dd/MM/yyyy"); 1579 1580 y = curDate.getFullYear(); 1581 1582 } else { 1583 1584 curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate()) + parseInt(document.forms["chkAvailabilityForm"].daysOffset.value)); 1585 document.forms["chkAvailabilityForm"].dateStart.value = formatDate(curDate, "MM/dd/yyyy"); 1586 1587 y = curDate.getFullYear(); 1588 1589 } 1590 1591 // if(navigator.appName == 'Netscape') 1592 // { 1593 // y = y + 1900; 1594 // } 1595 1596 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 1597 1598 curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate() + 1)); 1599 document.forms["chkAvailabilityForm"].dateEnd.value = formatDate(curDate, "dd/MM/yyyy"); 1600 setNights(); 1601 1602 } else { 1603 1604 curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate() + 1)); 1605 document.forms["chkAvailabilityForm"].dateEnd.value = formatDate(curDate, "MM/dd/yyyy"); 1606 setNights(); 1607 } 1608 1609 } 1610 1611 function calClosed() { 1612 1613 setCheckoutDate(); 1614 1615 1616 } 1617 1618 function setCheckoutDate() { 1619 setCheckoutDateParams(document.forms["chkAvailabilityForm"].dateStart, document.forms["chkAvailabilityForm"].noOfNights, document.forms["chkAvailabilityForm"].dateEnd); 1620 1621 } 1622 1623 1624 function setCheckoutDateParams(checkinDate, noOfNights, checkOutDate) { 1625 if (checkinDate.value != '' && isNumericVal(noOfNights.value, 0) && noOfNights.value != '') { 1626 1627 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 1628 1629 var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", 1630 "Sep", "Oct", "Nov", "Dec"); 1631 1632 var myDate = new Date(FormatUSDate(checkinDate.value)); 1633 var nights = noOfNights.value; 1634 var datevalue; 1635 var monthsvalue = 0; 1636 1637 1638 myDate.setDate(myDate.getDate() + parseInt(nights)) 1639 if (myDate.getDate() < 10) 1640 datevalue = "0" + myDate.getDate(); 1641 else 1642 datevalue = myDate.getDate(); 1643 1644 if (myDate.getMonth() == 0) 1645 checkOutDate.value = datevalue + "/" + "01" + "/" + myDate.getFullYear(); 1646 else if (myDate.getMonth() < 9) 1647 checkOutDate.value = datevalue + "/" + "0" + (myDate.getMonth() + 1) + "/" + myDate.getFullYear(); 1648 else 1649 checkOutDate.value = datevalue + "/" + (myDate.getMonth() + 1) + "/" + myDate.getFullYear(); 1650 } else { 1651 var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", 1652 "Sep", "Oct", "Nov", "Dec"); 1653 1654 var myDate = new Date(checkinDate.value) 1655 var nights = noOfNights.value; 1656 var datevalue; 1657 var monthsvalue = 0; 1658 1659 1660 myDate.setDate(myDate.getDate() + parseInt(nights)) 1661 if (myDate.getDate() < 10) 1662 datevalue = "0" + myDate.getDate(); 1663 else 1664 datevalue = myDate.getDate(); 1665 1666 if (myDate.getMonth() == 0) 1667 checkOutDate.value = "01" + "/" + datevalue + "/" + myDate.getFullYear(); 1668 else if (myDate.getMonth() < 9) 1669 checkOutDate.value = "0" + (myDate.getMonth() + 1) + "/" + datevalue + "/" + myDate.getFullYear(); 1670 else 1671 checkOutDate.value = (myDate.getMonth() + 1) + "/" + datevalue + "/" + myDate.getFullYear(); 1672 1673 } 1674 } 1675 } 1676 1677 function isNumericVal(c, varTest) { 1678 //allows alhabetic and space characters 1679 var letters = "-0123456789"; 1680 var LETTERS = "-0123456789"; 1681 1682 var index1 = c.indexOf("-"); 1683 var index2 = c.indexOf("-", index1 + 1); 1684 var index3 = c.indexOf("-", index2 + 1); 1685 1686 if (varTest == 1) { 1687 if (!((index1 == 3) && (index2 == 7) && (index3 == -1))) { 1688 return false; 1689 } 1690 1691 } 1692 1693 if (c.length > 1) { 1694 for (j = 0; j < c.length; j++) { 1695 // call isAlphaCell recursively for each character
1696 alpha = isNumericVal(c.substring(j, j + 1), 2); // 2nd time entry 1697 if (!alpha) return alpha; 1698 } 1699 return alpha; 1700 } else { 1701 // if c is alpha return true 1702 if (letters.indexOf(c) >= 0 || LETTERS.indexOf(c) >= 0) return true; 1703 return false; 1704 } 1705 } 1706 1707 function setNights() { 1708 return setNightsParams(document.forms["chkAvailabilityForm"].dateStart, document.forms["chkAvailabilityForm"].noOfNights, document.forms["chkAvailabilityForm"].dateEnd); 1709 } 1710 1711 function FormatUSDate(dateStr) { 1712 dateStr = dateStr.split("/"); 1713 return new Date(dateStr[2], dateStr[1] - 1, dateStr[0]); 1714 } 1715 1716 function setNightsParams(checkinDate, noOfNights, checkOutDate) { 1717 1718 var one_day = 1000 * 60 * 60 * 24 1719 if (checkinDate.value != '' && checkOutDate.value != '') { 1720 1721 var totNights = new Number(); 1722 var zero = 0; 1723 1724 if (document.forms["chkAvailabilityForm"].dateFlag.value == 1) { 1725 1726 var stDate = new Date(FormatUSDate(checkinDate.value)); 1727 var endDate = new Date(FormatUSDate(checkOutDate.value)); 1728 1729 stDate.setHours(0); 1730 stDate.setMinutes(0); 1731 stDate.setSeconds(0); 1732 1733 stDate.setHours(0); 1734 endDate.setMinutes(0); 1735 endDate.setSeconds(0); 1736 1737 totNights = Math.round((endDate.getTime() - stDate.getTime()) / one_day); 1738 1739 1740 if (totNights < zero) { 1741 alert('Arrival Date must be earlier than Departure Date'); 1742 return false; 1743 } else { 1744 noOfNights.value = totNights; 1745 return true; 1746 } 1747 } else { 1748 1749 var stDate = new Date(checkinDate.value); 1750 var endDate = new Date(checkOutDate.value); 1751 1752 stDate.setHours(0); 1753 stDate.setMinutes(0); 1754 stDate.setSeconds(0); 1755 1756 stDate.setHours(0); 1757 endDate.setMinutes(0); 1758 endDate.setSeconds(0); 1759 1760 totNights = Math.round((endDate.getTime() - stDate.getTime()) / one_day); 1761 1762 1763 if (totNights < zero) { 1764 alert('Arrival Date must be earlier than Departure Date'); 1765 return false; 1766 } else { 1767 noOfNights.value = totNights; 1768 return true; 1769 } 1770 1771 } 1772 } 1773 } 1774 1775 function fillForm() { 1776 if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'town') { 1777 document.forms["chkAvailabilityForm"].beFilterName.value = "townID"; 1778 document.getElementById("beFilterLabel").innerHTML = "Town:"; 1779 } 1780 1781 if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'property') { 1782 1783 document.forms["chkAvailabilityForm"].beFilterName.value = "propertyID"; 1784 document.getElementById("beFilterLabel").innerHTML = "Property:"; 1785 } 1786 1787 if (document.forms["chkAvailabilityForm"].beFilterConfig.value == 'roomClass') { 1788 document.forms["chkAvailabilityForm"].beFilterName.value = "roomClassID"; 1789 document.getElementById("beFilterLabel").innerHTML = "Room Class:"; 1790 } 1791 1792 if (document.forms["chkAvailabilityForm"].showHideBEFilter.value == 'hide') { 1793 document.getElementById("beFilterTR").style.display = 'none'; 1794 } 1795 1796 if (document.forms["chkAvailabilityForm"].showHideBEFilter.value == 'show') { 1797 document.getElementById("beFilterTR").style.display = ''; 1798 } 1799 1800 if (document.forms["chkAvailabilityForm"].showHideChildren.value == 'hide') { 1801 document.getElementById("beChildrenTD").style.display = 'none'; 1802 document.getElementById("beChildrenHelpTD").style.display = 'none'; 1803 } 1804 if (document.forms["chkAvailabilityForm"].showHideChildren.value == 'show') { 1805 document.getElementById("beChildrenTD").style.display = ''; 1806 document.getElementById("beChildrenHelpTD").style.display = ''; 1807 } 1808 1809 if (document.forms["chkAvailabilityForm"].showHideNights.value == 'hide') { 1810 document.getElementById("beNightsTR").style.display = 'none'; 1811 } 1812 if (document.forms["chkAvailabilityForm"].showHideNights.value == 'show') { 1813 document.getElementById("beNightsTR").style.display = ''; 1814 } 1815 1816 if (document.forms["chkAvailabilityForm"].showHidePromoCode.value == 'hide') { 1817 document.getElementById("bePromoCodeTR").style.display = 'none'; 1818 } 1819 if (document.forms["chkAvailabilityForm"].showHidePromoCode.value == 'show') { 1820 document.getElementById("bePromoCodeTR").style.display = ''; 1821 } 1822 } 1823 1824 /***************************** Validation *************************/ 1825 1826 var reSpecialChars = /[\'\"]/g; //matches any occurence of single quote or double quote 1827 var reInitialWhitespace = /^\s+/g; //matches one or more whitespace char at start of string 1828 var reTermialWhitespace = /\s+$/g; //matches one or more whitespace char at end of string 1829 var reBackSlash = /%5C/gi; 1830 var reSemiColon = /\;/gi; 1831 var reForwardSlash = /[\\]/g; 1832 var reOpenBrackets = /[\{\<]/g; 1833 var reCloseBrackets = /[\}\>]/g; 1834 1835 1836 // These methods below are not necessary but are included as sample library functions that are used in the example 1837 function validateNotEmpty(strValue) { 1838 /************************************************ 1839 DESCRIPTION: Validates that a string is not all 1840 blank (whitespace) characters. 1841 1842 PARAMETERS: 1843 strValue - String to be tested for validity 1844 1845 RETURNS: 1846 True if not empty, otherwise false. 1847 *************************************************/ 1848 var strTemp = strValue; 1849 strTemp = trimAll(strTemp); 1850 if (strTemp.length > 0) { 1851 return true; 1852 } 1853 return false; 1854 } 1855 1856 //Description : Removes spaces from the start and end of the string. Spaces in the middle are not removed. 1857 //Input Parameters : s - String 1858 //Output : String sOutStr 1859 function trim(s) { 1860 return stripCharacters(stripCharacters(s, reInitialWhitespace), reTermialWhitespace); 1861 } 1862 1863 function trimAll(strValue) { 1864 /************************************************
1865 DESCRIPTION: Removes leading and trailing spaces. 1866 1867 PARAMETERS: Source string from which spaces will 1868 be removed; 1869 1870 RETURNS: Source string with whitespaces removed. 1871 *************************************************/ 1872 var objRegExp = /^(\s*)$/; 1873 1874 //check for all spaces 1875 if (objRegExp.test(strValue)) { 1876 strValue = strValue.replace(objRegExp, ''); 1877 if (strValue.length == 0) 1878 return strValue; 1879 } 1880 1881 //check for leading & trailing spaces 1882 objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/; 1883 if (objRegExp.test(strValue)) { 1884 //remove leading and trailing whitespace characters 1885 strValue = strValue.replace(objRegExp, '$2'); 1886 } 1887 return strValue; 1888 } 1889 1890 //Description : Strip character in passed reBag (valid RegExp expression) from passed String 1891 // ; Note that reBag must be a valid RegExp which matches sigle characters in isolation 1892 // ; and make sure the 'g' modifier is appended for global search & replace. 1893 //Input Parameters : s - String 1894 //Output : String with designated (reBag) characters removed 1895 function stripCharacters(s, reBag) { 1896 return s.replace(reBag, '') 1897 } 1898 1899 var testresults 1900 1901 function checkemail(email) { 1902 var str = email 1903 var filter = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i 1904 if (filter.test(str)) 1905 testresults = true 1906 else { 1907 alert("Please input a valid email address!") 1908 testresults = false 1909 } 1910 return (testresults) 1911 } 1912 1913 1914 /****************************** Date Util *****************************/ 1915 1916 1917 1918 var 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'); 1919 var DAY_NAMES = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); 1920 1921 function LZ(x) { 1922 return (x < 0 || x > 9 ? "" : "0") + x 1923 } 1924 1925 function isDate(val, format) { 1926 var date = getDateFromFormat(val, format); 1927 if (date == 0) { 1928 return false; 1929 } 1930 return true; 1931 } 1932 1933 function compareDates(date1, dateformat1, date2, dateformat2) { 1934 var d1 = getDateFromFormat(date1, dateformat1); 1935 var d2 = getDateFromFormat(date2, dateformat2); 1936 if (d1 == 0 || d2 == 0) { 1937 return -1; 1938 } else if (d1 > d2) { 1939 return 1; 1940 } 1941 return 0; 1942 } 1943 1944 function formatDate(date, format) { 1945 format = format + ""; 1946 var result = ""; 1947 var i_format = 0; 1948 var c = ""; 1949 var token = ""; 1950 var y = date.getFullYear() + ""; 1951 var M = date.getMonth() + 1; 1952 var d = date.getDate(); 1953 var E = date.getDay(); 1954 var H = date.getHours(); 1955 var m = date.getMinutes(); 1956 var s = date.getSeconds(); 1957 var yyyy, yy, MMM, MM, dd, hh, h, mm, ss, ampm, HH, H, KK, K, kk, k; 1958 // Convert real date parts into formatted versions 1959 var value = new Object(); 1960 if (y.length < 4) { 1961 y = "" + (y - 0 + 1900); 1962 } 1963 value["y"] = "" + y; 1964 value["yyyy"] = y; 1965 value["yy"] = y.substring(2, 4); 1966 value["M"] = M; 1967 value["MM"] = LZ(M); 1968 value["MMM"] = MONTH_NAMES[M - 1]; 1969 value["NNN"] = MONTH_NAMES[M + 11]; 1970 value["d"] = d; 1971 value["dd"] = LZ(d); 1972 value["E"] = DAY_NAMES[E + 7]; 1973 value["EE"] = DAY_NAMES[E]; 1974 value["H"] = H; 1975 value["HH"] = LZ(H); 1976 if (H == 0) { 1977 value["h"] = 12; 1978 } else if (H > 12) { 1979 value["h"] = H - 12; 1980 } else { 1981 value["h"] = H; 1982 } 1983 value["hh"] = LZ(value["h"]); 1984 if (H > 11) { 1985 value["K"] = H - 12; 1986 } else { 1987 value["K"] = H; 1988 } 1989 value["k"] = H + 1; 1990 value["KK"] = LZ(value["K"]); 1991 value["kk"] = LZ(value["k"]); 1992 if (H > 11) { 1993 value["a"] = "PM"; 1994 } else { 1995 value["a"] = "AM"; 1996 } 1997 value["m"] = m; 1998 value["mm"] = LZ(m); 1999 value["s"] = s; 2000 value["ss"] = LZ(s); 2001 while (i_format < format.length) { 2002 c = format.charAt(i_format); 2003 token = ""; 2004 while ((format.charAt(i_format) == c) && (i_format < format.length)) { 2005 token += format.charAt(i_format++); 2006 } 2007 if (value[token] != null) { 2008 result = result + value[token]; 2009 } else { 2010 result = result + token; 2011 } 2012 } 2013 return result; 2014 } 2015 2016 // ------------------------------------------------------------------ 2017 // Utility functions for parsing in getDateFromFormat() 2018 // ------------------------------------------------------------------ 2019 function _isInteger(val) { 2020 var digits = "1234567890"; 2021 for (var i = 0; i < val.length; i++) { 2022 if (digits.indexOf(val.charAt(i)) == -1) { 2023 return false; 2024 } 2025 } 2026 return true; 2027 } 2028 2029 function _getInt(str, i, minlength, maxlength) { 2030 for (var x = maxlength; x >= minlength; x--) { 2031 var token = str.substring(i, i + x); 2032 if (token.length < minlength) { 2033 return null; 2034 } 2035 if (_isInteger(token)) { 2036 return token; 2037 } 2038 } 2039 return null; 2040 } 2041 2042 // ------------------------------------------------------------------ 2043 // getDateFromFormat( date_string , format_string ) 2044 //
2045 // This function takes a date string and a format string. It matches 2046 // If the date string matches the format string, it returns the 2047 // getTime() of the date. If it does not match, it returns 0. 2048 // ------------------------------------------------------------------ 2049 function getDateFromFormat(val, format) { 2050 val = val + ""; 2051 format = format + ""; 2052 var i_val = 0; 2053 var i_format = 0; 2054 var c = ""; 2055 var token = ""; 2056 var token2 = ""; 2057 var x, y; 2058 var now = new Date(); 2059 var year = now.getFullYear(); 2060 var month = now.getMonth() + 1; 2061 var date = 1; 2062 var hh = now.getHours(); 2063 var mm = now.getMinutes(); 2064 var ss = now.getSeconds(); 2065 var ampm = ""; 2066 2067 while (i_format < format.length) { 2068 // Get next token from format string 2069 c = format.charAt(i_format); 2070 token = ""; 2071 while ((format.charAt(i_format) == c) && (i_format < format.length)) { 2072 token += format.charAt(i_format++); 2073 } 2074 // Extract contents of value based on format token 2075 if (token == "yyyy" || token == "yy" || token == "y") { 2076 if (token == "yyyy") { 2077 x = 4; 2078 y = 4; 2079 } 2080 if (token == "yy") { 2081 x = 2; 2082 y = 2; 2083 } 2084 if (token == "y") { 2085 x = 2; 2086 y = 4; 2087 } 2088 year = _getInt(val, i_val, x, y); 2089 if (year == null) { 2090 return 0; 2091 } 2092 i_val += year.length; 2093 if (year.length == 2) { 2094 if (year > 70) { 2095 year = 1900 + (year - 0); 2096 } else { 2097 year = 2000 + (year - 0); 2098 } 2099 } 2100 } else if (token == "MMM" || token == "NNN") { 2101 month = 0; 2102 for (var i = 0; i < MONTH_NAMES.length; i++) { 2103 var month_name = MONTH_NAMES[i]; 2104 if (val.substring(i_val, i_val + month_name.length).toLowerCase() == month_name.toLowerCase()) { 2105 if (token == "MMM" || (token == "NNN" && i > 11)) { 2106 month = i + 1; 2107 if (month > 12) { 2108 month -= 12; 2109 } 2110 i_val += month_name.length; 2111 break; 2112 } 2113 } 2114 } 2115 if ((month < 1) || (month > 12)) { 2116 return 0; 2117 } 2118 } else if (token == "EE" || token == "E") { 2119 for (var i = 0; i < DAY_NAMES.length; i++) { 2120 var day_name = DAY_NAMES[i]; 2121 if (val.substring(i_val, i_val + day_name.length).toLowerCase() == day_name.toLowerCase()) { 2122 i_val += day_name.length; 2123 break; 2124 } 2125 } 2126 } else if (token == "MM" || token == "M") { 2127 month = _getInt(val, i_val, token.length, 2); 2128 if (month == null || (month < 1) || (month > 12)) { 2129 return 0; 2130 } 2131 i_val += month.length; 2132 } else if (token == "dd" || token == "d") { 2133 date = _getInt(val, i_val, token.length, 2); 2134 if (date == null || (date < 1) || (date > 31)) { 2135 return 0; 2136 } 2137 i_val += date.length; 2138 } else if (token == "hh" || token == "h") { 2139 hh = _getInt(val, i_val, token.length, 2); 2140 if (hh == null || (hh < 1) || (hh > 12)) { 2141 return 0; 2142 } 2143 i_val += hh.length; 2144 } else if (token == "HH" || token == "H") { 2145 hh = _getInt(val, i_val, token.length, 2); 2146 if (hh == null || (hh < 0) || (hh > 23)) { 2147 return 0; 2148 } 2149 i_val += hh.length; 2150 } else if (token == "KK" || token == "K") { 2151 hh = _getInt(val, i_val, token.length, 2); 2152 if (hh == null || (hh < 0) || (hh > 11)) { 2153 return 0; 2154 } 2155 i_val += hh.length; 2156 } else if (token == "kk" || token == "k") { 2157 hh = _getInt(val, i_val, token.length, 2); 2158 if (hh == null || (hh < 1) || (hh > 24)) { 2159 return 0; 2160 } 2161 i_val += hh.length; 2162 hh--; 2163 } else if (token == "mm" || token == "m") { 2164 mm = _getInt(val, i_val, token.length, 2); 2165 if (mm == null || (mm < 0) || (mm > 59)) { 2166 return 0; 2167 } 2168 i_val += mm.length; 2169 } else if (token == "ss" || token == "s") { 2170 ss = _getInt(val, i_val, token.length, 2); 2171 if (ss == null || (ss < 0) || (ss > 59)) { 2172 return 0; 2173 } 2174 i_val += ss.length; 2175 } else if (token == "a") { 2176 if (val.substring(i_val, i_val + 2).toLowerCase() == "am") { 2177 ampm = "AM"; 2178 } else if (val.substring(i_val, i_val + 2).toLowerCase() == "pm") { 2179 ampm = "PM"; 2180 } else { 2181 return 0; 2182 } 2183 i_val += 2; 2184 } else { 2185 if (val.substring(i_val, i_val + token.length) != token) { 2186 return 0; 2187 } else { 2188 i_val += token.length; 2189 } 2190 } 2191 } 2192 // If there are any trailing characters left in the value, it doesn't match 2193 if (i_val != val.length) { 2194 return 0; 2195 } 2196 // Is date valid for month? 2197 if (month == 2) { 2198 // Check for leap year 2199 if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { // leap year 2200 if (date > 29) { 2201 return 0; 2202 } 2203 } else { 2204 if (date > 28) { 2205 return 0; 2206 } 2207 } 2208 } 2209 if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) { 2210 if (date > 30) { 2211 return 0; 2212 } 2213 } 2214 // Correct hours value 2215 if (hh < 12 && ampm == "PM") { 2216 hh = hh - 0 + 12; 2217 } else if (hh > 11 && ampm == "AM") { 2218 hh -= 12; 2219 } 2220 var newdate = new Date(year, month - 1, date, hh, mm, ss); 2221 return newdate.getTime(); 2222 } 2223 2224 // ------------------------------------------------------------------ 2225 // parseDate( date_string [, prefer_euro_format] ) 2226 // 2227 // This function takes a date string and tries to match it to a 2228 // number of possible date formats to get the value. It will try to 2229 // match against the following international formats, in this order: 2230 // y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d 2231 // M/d/y M-d-y M.d.y MMM-d M/d M-d 2232 // d/M/y d-M-y d.M.y d-MMM d/M d-M 2233 // A second argument may be passed to instruct the method to search 2234 // for formats like d/M/y (european format) before M/d/y (American). 2235 // Returns a Date object or null if no patterns match. 2236 // ------------------------------------------------------------------ 2237 function parseDate(val) { 2238 var preferEuro = (arguments.length == 2) ? arguments[1] : false; 2239 generalFormats = new Array('y-M-d', 'MMM d, y', 'MMM d,y', 'y-MMM-d', 'd-MMM-y', 'MMM d'); 2240 monthFirst = new Array('M/d/y', 'M-d-y', 'M.d.y', 'MMM-d', 'M/d', 'M-d'); 2241 dateFirst = new Array('d/M/y', 'd-M-y', 'd.M.y', 'd-MMM', 'd/M', 'd-M'); 2242 var checkList = new Array('generalFormats', preferEuro ? 'dateFirst' : 'monthFirst', preferEuro ? 'monthFirst' : 'dateFirst'); 2243 var d = null; 2244 for (var i = 0; i < checkList.length; i++) { 2245 var l = window[checkList[i]]; 2246 for (var j = 0; j < l.length; j++) { 2247 d = getDateFromFormat(val, l[j]); 2248 if (d != 0) { 2249 return new Date(d); 2250 } 2251 } 2252 } 2253 return null; 2254 }
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.