1/* 2(C) www.dhtmlgoodies.com, September 2005 3 4Version 1.2, November 8th - 2005 - Added <iframe> background in IE 5Version 1.3, November 12th - 2005 - Fixed top bar position in Opera 7 6Version 1.4, December 28th - 2005 - Support for Spanish and Portuguese 7Version 1.5, January 18th - 2006 - Fixed problem with next-previous buttons after a month has been selected from dropdown 8Version 1.6, February 22nd - 2006 - Added variable which holds the path to images. 9 Format todays date at the bottom by use of the todayStringFormat variable 10 Pick todays date by clicking on todays date at the bottom of the calendar 11 12This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website. 13 14Terms of use: 15You are free to use this script as long as the copyright message is kept intact. However, you may not 16redistribute, sell or repost it without our permission. 17 18Thank you! 19 20www.dhtmlgoodies.com 21Alf Magne Kalleland 22 23*/ 24var languageCode = 'en'; // Possible values: en,ge,no,nl,es,pt-br,fr 25 // en = english, ge = german, no = norwegian,nl = dutch, es = spanish, pt-br = portuguese, fr = french, da = danish, hu = hungarian(Use UTF-8 doctype for hungarian) 26 27 28// Format of current day at the bottom of the calendar 29// [todayString] = the value of todayString 30// [dayString] = day of week (examle: Mon, Tue, Wed...) 31// [day] = Day of month, 1..31 32// [monthString] = Name of current month 33// [year] = Current year 34var todayStringFormat = '[todayString] [dayString]. [day]. [monthString] [year]'; 35//var pathToImages = '//192.168.10.10/vipul/account/css/admin/images/'; // Relative to your HTML file 36var pathToImages = rootfolderpath; // Relative to your HTML file 37 38var calendar_offsetTop = 0; // Offset - calendar placement - You probably have to modify this value if you're not using a strict doctype 39var calendar_offsetLeft = 0; // Offset - calendar placement - You probably have to modify this value if you're not using a strict doctype 40var calendarDiv = false; 41 42var MSIE = false; 43var Opera = false; 44if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)MSIE=true; 45if(navigator.userAgent.indexOf('Opera')>=0)Opera=true; 46 47 48switch(languageCode){ 49 case "en": /* English */ 50 var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December']; 51 var monthArrayShort = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; 52 var dayArray = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']; 53 var weekString = 'Week'; 54 var todayString = 'Today is'; 55 break; 56 case "ge": /* German */ 57 var monthArray = ['Jänner','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember']; 58 var monthArrayShort = ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez']; 59 var dayArray = ['Mon','Die','Mit','Don','Fre','Sam','Son']; 60 var weekString = 'Woche'; 61 var todayString = 'Heute'; 62 break; 63 case "no": /* Norwegian */ 64 var monthArray = ['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember']; 65 var monthArrayShort = ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Des']; 66 var dayArray = ['Man','Tir','Ons','Tor','Fre','Lør','Søn']; 67 var weekString = 'Uke'; 68 var todayString = 'Dagen i dag er'; 69 break; 70 case "nl": /* Dutch */ 71 var monthArray = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December']; 72 var monthArrayShort = ['Jan','Feb','Mar','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec']; 73 var dayArray = ['Ma','Di','Wo','Do','Vr','Za','Zo']; 74 var weekString = 'Week'; 75 var todayString = 'Vandaag'; 76 break; 77 case "es": /* Spanish */ 78 var monthArray = ['Enero','Febrero','Marzo','April','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']; 79 var monthArrayShort =['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic']; 80 var dayArray = ['Lun','Mar','Mie','Jue','Vie','Sab','Dom']; 81 var weekString = 'Semana'; 82 var todayString = 'Hoy es'; 83 break; 84 case "pt-br": /* Brazilian portuguese (pt-br) */ 85 var monthArray = ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro']; 86 var monthArrayShort = ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez']; 87 var dayArray = ['Seg','Ter','Qua','Qui','Sex','Sáb','Dom']; 88 var weekString = 'Sem.'; 89 var todayString = 'Hoje é'; 90 break; 91 case "fr": /* French */ 92 var monthArray = ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','N
92ovembre','Décembre']; 93 var monthArrayShort = ['Jan','Fev','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','Dec']; 94 var dayArray = ['Lun','Mar','Mer','Jeu','Ven','Sam','Dim']; 95 var weekString = 'Sem'; 96 var todayString = "Aujourd'hui"; 97 break; 98 case "ru": /* Russian - Remember to use encoding windows-1251 , i.e. the <meta> tag. */ 99 var monthArray = ['ßíâàðü','Ôåâðàëü','Ìàðò','Àïðåëü','Ìàé','Èþíü','Èþëü','Àâãóñò','Ñåíòÿáðü','Îêòÿáðü','Íîÿáðü','Äåêàáðü']; 100 var monthArrayShort = ['ÿíâ','ôåâ','ìàð','àïð','ìàé','èþí','èþë','àâã','ñåí','îêò','íîÿ','äåê']; 101 var dayArray = ['Ïí','Âò','Ñð','×ò','Ïò','Ñá','Âñ']; 102 var weekString = '#'; 103 var todayString = 'Ñåãîäíÿ'; 104 break; 105 case "da": /*Danish*/ 106 var monthArray = ['januar','februar','marts','april','maj','juni','juli','august','september','oktober','november','december']; 107 var monthArrayShort = ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec']; 108 var dayArray = ['man','tirs','ons','tors','fre','lør','søn'] 109 var weekString = 'Uge'; 110 var todayString = 'I dag er den'; 111 break; 112 case "hu": /* Hungarian - Remember to use UTF-8 encoding, i.e. the <meta> tag */ 113 var monthArray = ['Január','Február','Március','Ã?prilis','Május','Június','Július','Augusztus','Szeptember','Október','November','December']; 114 var monthArrayShort = ['Jan','Feb','Márc','Ã?pr','Máj','Jún','Júl','Aug','Szep','Okt','Nov','Dec']; 115 var dayArray = ['Hé','Ke','Sze','Cs','Pé','Szo','Vas']; 116 var weekString = 'Hét'; 117 var todayString = 'Mai nap'; 118} 119 120 121 122var daysInMonthArray = [31,28,31,30,31,30,31,31,30,31,30,31]; 123var currentMonth; 124var currentYear; 125var calendarContentDiv; 126var returnDateTo; 127var returnFormat; 128var activeSelectBoxMonth; 129var activeSelectBoxYear; 130var iframeObj = false; 131 132var returnDateToYear; 133var returnDateToMonth; 134var returnDateToDay; 135 136var inputYear; 137var inputMonth; 138var inputDay; 139 140 141var selectBoxHighlightColor = '#D60808'; // Highlight color of select boxes 142var selectBoxRolloverBgColor = '#E2EBED'; // Background color on drop down lists(rollover) 143function cancelCalendarEvent() 144{ 145 return false; 146} 147function isLeapYear(inputYear) 148{ 149 if(inputYear%400==0||(inputYear%4==0&&inputYear%100!=0)) return true; 150 return false; 151 152} 153var activeSelectBoxMonth = false; 154 155function highlightMonthYear() 156{ 157 if(activeSelectBoxMonth)activeSelectBoxMonth.className=''; 158 159 if(this.className=='monthYearActive'){ 160 this.className=''; 161 }else{ 162 this.className = 'monthYearActive'; 163 activeSelectBoxMonth = this; 164 } 165} 166 167function showMonthDropDown() 168{ 169 if(document.getElementById('monthDropDown').style.display=='block'){ 170 document.getElementById('monthDropDown').style.display='none'; 171 }else{ 172 document.getElementById('monthDropDown').style.display='block'; 173 document.getElementById('yearDropDown').style.display='none'; 174 } 175} 176 177function showYearDropDown() 178{ 179 if(document.getElementById('yearDropDown').style.display=='block'){ 180 document.getElementById('yearDropDown').style.display='none'; 181 }else{ 182 document.getElementById('yearDropDown').style.display='block'; 183 document.getElementById('monthDropDown').style.display='none'; 184 } 185 186} 187 188function selectMonth() 189{ 190 document.getElementById('calendar_month_txt').innerHTML = this.innerHTML 191 currentMonth = this.id.replace(/[^\d]/g,''); 192 193 document.getElementById('monthDropDown').style.display='none'; 194 for(var no=0;no<monthArray.length;no++){ 195 document.getElementById('monthDiv_'+no).style.color=''; 196 } 197 this.style.color = selectBoxHighlightColor; 198 activeSelectBoxMonth = this; 199 writeCalendarContent(); 200 201} 202 203function selectYear() 204{ 205 document.getElementById('calendar_year_txt').innerHTML = this.innerHTML 206 currentYear = this.innerHTML.replace(/[^\d]/g,''); 207 document.getElementById('yearDropDown').style.display='none'; 208 if(activeSelectBoxYear){ 209 activeSelectBoxYear.style.color=''; 210 } 211 activeSelectBoxYear=this; 212 this.style.color = selectBoxHighlightColor; 213 writeCalendarContent(); 214 215} 216 217function switchMonth() 218{ 219 if(this.src.indexOf('left')>=0){ 220 currentMonth=currentMonth-1;; 221 if(currentMonth<0){ 222 currentMonth=11; 223 currentYear=currentYear-1; 224 } 225 }else{ 226 currentMonth=currentMonth+1;; 227 if(currentMonth>11){ 228 currentMonth=0; 229 currentYear=currentYear/1+1; 230 } 231 } 232 233 writeCalendarContent(); 234 235 236} 237 238function createMonthDiv(){ 239 var div = document.createElement('DIV'); 240 div.className='monthYearPicker'; 241 div.id = 'monthPicker'; 242 243 for(var no=0;no<monthArray.length;no++){ 244 var subDiv = document.createElement('DIV'); 245 subDiv.innerHTML = monthArray[no]; 246 subDiv.onmouseover = highlightMonthYear; 247 subDiv.onmouseout = highlightMonthYear; 248 subDiv.onclick = selectMonth; 249 subDiv.id = 'monthDiv_' + no; 250 subDiv.style.width = '56px'; 251 subDiv.onselectstart = cancelCalendarEvent; 252 div.appendChild(subDiv); 253 if(currentMonth && currentMonth==no){ 254 subDiv.style.color = selectBoxHighlightColor; 255 activeSelectBoxMonth = subDiv; 256 } 257 258 } 259 return div; 260 261} 262 263function changeSelectBoxYear() 264{ 265 266 var yearItems = this.parentNode.getElementsByTagName('DIV'); 267 if(this.innerHTML.indexOf('-')>=0){ 268 var startYear = yearItems[1].innerHTML/1 -1; 269 if(activeSelectBoxYear){ 270 activeSelectBoxYear.style.color=''; 271 } 272 }else{ 273 var startYear = yearItems[1].innerHTML/1 +1; 274 if(activeSelectBoxYear){ 275 activeSelectBoxYear.style.color=''; 276 277 } 278 } 279 280 for(var no=1;no<yearItems.length-1;no++){ 281 yearItems[no].innerHTML = startYear+no-1; 282 yearItems[no].id = 'yearDiv' + (startYear/1+no/1-1); 283 284 } 285 if(activeSelectBoxYear){ 286 activeSelectBoxYear.style.color=''; 287 if(document.getElementById('yearDiv'+currentYear)){ 288 activeSelectBoxYear = document.getElementById('yearDiv'+currentYear); 289 activeSelectBoxYear.style.color=selectBoxHighlightColor;; 290 } 291 } 292} 293 294function updateYearDiv() 295{ 296 var div = document.getElementById('yearDropDown'); 297 var yearItems = div.getElementsByTagName('DIV'); 298 for(var no=1;no<yearItems.length-1;no++){ 299 yearItems[no].innerHTML = currentYear/1 -6 + no; 300 if(currentYear==(currentYear/1 -6 + no)){ 301 yearItems[no].style.color = selectBoxHighlightColor; 302 activeSelectBoxYear = yearItems[no]; 303 }else{ 304 yearItems[no].style.color = ''; 305 } 306 } 307} 308 309function updateMonthDiv() 310{ 311 for(no=0;no<12;no++){ 312 document.getElementById('monthDiv_' + no).style.color = ''; 313 } 314 document.getElementById('monthDiv_' + currentMonth).style.color = selectBoxHighlightColor; 315 activeSelectBoxMonth = document.getElementById('monthDiv_' + currentMonth); 316} 317 318function createYearDiv() 319{ 320 321 if(!document.getElementById('yearDropDown')){ 322 var div = document.createElement('DIV'); 323 div.className='monthYearPicker'; 324 }else{ 325 var div = document.getElementById('yearDropDown'); 326 var subDivs = div.getElementsByTagName('DIV'); 327 for(var no=0;no<subDivs.length;no++){ 328 subDivs[no].parentNode.removeChild(subDivs[no]); 329 } 330 } 331 332 333 var d = new Date(); 334 if(currentYear){ 335 d.setFullYear(currentYear); 336 } 337 338 var startYear = d.getFullYear()/1 - 5; 339 340 341 var subDiv = document.createElement('DIV'); 342 subDiv.innerHTML = ' - '; 343 subDiv.onclick = changeSelectBoxYear; 344 subDiv.onmouseover = highlightMonthYear; 345 subDiv.onmouseout = highlightMonthYear; 346 subDiv.onselectstart = cancelCalendarEvent; 347 div.appendChild(subDiv); 348 349 for(var no=startYear;no<(startYear+10);no++){ 350 var subDiv = document.createElement('DIV'); 351 subDiv.innerHTML = no; 352 subDiv.onmouseover = highlightMonthYear; 353 subDiv.onmouseout = highlightMonthYear; 354 subDiv.onclick = selectYear; 355 subDiv.id = 'yearDiv' + no; 356 subDiv.onselectstart = cancelCalendarEvent; 357 div.appendChild(subDiv); 358 if(currentYear && currentYear==no){ 359 subDiv.style.color = selectBoxHighlightColor; 360 activeSelectBoxYear = subDiv; 361 } 362 } 363 var subDiv = document.createElement('DIV'); 364 subDiv.innerHTML = ' + '; 365 subDiv.onclick = changeSelectBoxYear; 366 subDiv.onmouseover = highlightMonthYear; 367 subDiv.onmouseout = highlightMonthYear; 368 subDiv.onselectstart = cancelCalendarEvent; 369 div.appendChild(subDiv); 370 371 372 return div; 373} 374 375function highlightSelect() 376{ 377 if(this.className=='selectBox'){ 378 this.className = 'selectBoxOver'; 379 this.getElementsByTagName('IMG')[0].src = pathToImages + 'down_over.gif'; 380 }else{ 381 this.className = 'selectBox'; 382 this.getElementsByTagName('IMG')[0].src = pathToImages + 'down1.gif'; 383 } 384 385} 386 387function highlightArrow() 388{ 389 if(this.src.indexOf('over')>=0){ 390 if(this.src.indexOf('left')>=0)this.src = pathToImages + 'left.gif'; 391 if(this.src.indexOf('right')>=0)this.src = pathToImages + 'right.gif'; 392 }else{ 393 if(this.src.indexOf('left')>=0)this.src = pathToImages + 'left_over.gif'; 394 if(this.src.indexOf('right')>=0)this.src = pathToImages + 'right_over.gif'; 395 } 396} 397 398function highlightClose() 399{ 400 if(this.src.indexOf('over')>=0){ 401 this.src = pathToImages + 'close.gif'; 402 }else{ 403 this.src = pathToImages + 'close_over.gif'; 404 } 405 406} 407
408function closeCalendar(){ 409 410 document.getElementById('yearDropDown').style.display='none'; 411 document.getElementById('monthDropDown').style.display='none'; 412 413 calendarDiv.style.display='none'; 414 if(iframeObj)iframeObj.style.display='none'; 415 if(activeSelectBoxMonth)activeSelectBoxMonth.className=''; 416 if(activeSelectBoxYear)activeSelectBoxYear.className=''; 417 418 419} 420 421function writeTopBar() 422{ 423 424 var topBar = document.createElement('DIV'); 425 topBar.className = 'topBar'; 426 topBar.id = 'topBar'; 427 calendarDiv.appendChild(topBar); 428 429 // Left arrow 430 var leftDiv = document.createElement('DIV'); 431 leftDiv.style.marginRight = '1px'; 432 var img = document.createElement('IMG'); 433 img.src = pathToImages + 'left.gif'; 434 img.onmouseover = highlightArrow; 435 img.onclick = switchMonth; 436 img.onmouseout = highlightArrow; 437 leftDiv.appendChild(img); 438 topBar.appendChild(leftDiv); 439 if(Opera)leftDiv.style.width = '16px'; 440 441 // Right arrow 442 var rightDiv = document.createElement('DIV'); 443 rightDiv.style.marginRight = '1px'; 444 var img = document.createElement('IMG'); 445 img.src = pathToImages + 'right.gif'; 446 img.onclick = switchMonth; 447 img.onmouseover = highlightArrow; 448 img.onmouseout = highlightArrow; 449 rightDiv.appendChild(img); 450 if(Opera)rightDiv.style.width = '16px'; 451 topBar.appendChild(rightDiv); 452 453 454 // Month selector 455 var monthDiv = document.createElement('DIV'); 456 monthDiv.id = 'monthSelect'; 457 monthDiv.onmouseover = highlightSelect; 458 monthDiv.onmouseout = highlightSelect; 459 monthDiv.onclick = showMonthDropDown; 460 var span = document.createElement('SPAN'); 461 span.innerHTML = monthArray[currentMonth]; 462 span.id = 'calendar_month_txt'; 463 monthDiv.appendChild(span); 464 465 var img = document.createElement('IMG'); 466 img.src = pathToImages + 'down1.gif'; 467 img.style.position = 'absolute'; 468 img.style.right = '0px'; 469 monthDiv.appendChild(img); 470 monthDiv.className = 'selectBox'; 471 if(Opera){ 472 img.style.cssText = 'float:right;position:relative'; 473 img.style.position = 'relative'; 474 img.style.styleFloat = 'right'; 475 } 476 topBar.appendChild(monthDiv); 477 478 var monthPicker = createMonthDiv(); 479 monthPicker.style.left = '37px'; 480 monthPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px'; 481 monthPicker.style.width ='60px'; 482 monthPicker.id = 'monthDropDown'; 483 484 calendarDiv.appendChild(monthPicker); 485 486 // Year selector 487 var yearDiv = document.createElement('DIV'); 488 yearDiv.onmouseover = highlightSelect; 489 yearDiv.onmouseout = highlightSelect; 490 yearDiv.onclick = showYearDropDown; 491 var span = document.createElement('SPAN'); 492 span.innerHTML = currentYear; 493 span.id = 'calendar_year_txt'; 494 yearDiv.appendChild(span); 495 topBar.appendChild(yearDiv); 496 497 var img = document.createElement('IMG'); 498 img.src = pathToImages + 'down1.gif'; 499 yearDiv.appendChild(img); 500 yearDiv.className = 'selectBox'; 501 502 if(Opera){ 503 yearDiv.style.width = '50px'; 504 img.style.cssText = 'float:right'; 505 img.style.position = 'relative'; 506 img.style.styleFloat = 'right'; 507 } 508 509 var yearPicker = createYearDiv(); 510 yearPicker.style.left = '113px'; 511 yearPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px'; 512 yearPicker.style.width = '35px'; 513 yearPicker.id = 'yearDropDown'; 514 calendarDiv.appendChild(yearPicker); 515 516 517 var img = document.createElement('IMG'); 518 img.src = pathToImages + 'close.gif'; 519 img.style.styleFloat = 'right'; 520 img.onmouseover = highlightClose; 521 img.onmouseout = highlightClose; 522 img.onclick = closeCalendar; 523 topBar.appendChild(img); 524 if(!document.all){ 525 img.style.position = 'absolute'; 526 img.style.right = '2px'; 527 } 528 529 530 531} 532 533function writeCalendarContent() 534{ 535 var calendarContentDivExists = true; 536 if(!calendarContentDiv){ 537 calendarContentDiv = document.createElement('DIV'); 538 calendarDiv.appendChild(calendarContentDiv); 539 calendarContentDivExists = false; 540 } 541 currentMonth = currentMonth/1; 542 var d = new Date(); 543 544 d.setFullYear(currentYear); 545 d.setDate(1); 546 d.setMonth(currentMonth); 547 548 var dayStartOfMonth = d.getDay(); 549 if(dayStartOfMonth==0)dayStartOfMonth=7; 550 dayStartOfMonth--; 551 552 document.getElementById('calendar_year_txt').innerHTML = currentYear; 553 document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth]; 554 555 var existingTable = calendarContentDiv.getElementsByTagName('TABLE'); 556 if(existingTable.length>0){ 557 calendarContentDiv.removeChild(existingTable[0]); 558 } 559 560 var calTable = document.createElement('TABLE'); 561 calTable.cellSpacing = '0'; 562 calendarContentDiv.appendChild(calTable); 563 var calTBody = document.createElement('TBODY'); 564 calTable.appendChild(calTBody); 565 var row = calTBody.insertRow(-1); 566 var cell = row.insertCell(-1); 567 //cell.innerHTML = weekString; 568 //cell.style.backgroundColor = selectBoxRolloverBgColor; 569 570 for(var no=0;no<dayArray.length;no++){ 571 var cell = row.insertCell(-1); 572 cell.innerHTML = dayArray[no]; 573 } 574 575 var row = calTBody.insertRow(-1); 576 var cell = row.insertCell(-1); 577 //cell.style.backgroundColor = selectBoxRolloverBgColor; 578 var week = getWeek(currentYear,currentMonth,1); 579 //cell.innerHTML = week; // Week 580 for(var no=0;no<dayStartOfMonth;no++){ 581 var cell = row.insertCell(-1); 582 cell.innerHTML = ' '; 583 } 584 585 var colCounter = dayStartOfMonth; 586 var daysInMonth = daysInMonthArray[currentMonth]; 587 if(daysInMonth==28){ 588 if(isLeapYear(currentYear))daysInMonth=29; 589 } 590 591 for(var no=1;no<=daysInMonth;no++){ 592 d.setDate(no-1); 593 if(colCounter>0 && colCounter%7==0){ 594 var row = calTBody.insertRow(-1); 595 var cell = row.insertCell(-1); 596 var week = getWeek(currentYear,currentMonth,no); 597 // cell.innerHTML = week; // Week 598 // cell.style.backgroundColor = selectBoxRolloverBgColor; 599 } 600 var cell = row.insertCell(-1); 601 if(currentYear==inputYear && currentMonth == inputMonth && no==inputDay){ 602 cell.className='activeDay'; 603 } 604 cell.innerHTML = no; 605 cell.onclick = pickDate; 606 colCounter++; 607 } 608 609 610 if(!document.all){ 611 if(calendarContentDiv.offsetHeight) 612 document.getElementById('topBar').style.top = calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight -1 + 'px'; 613 else{ 614 document.getElementById('topBar').style.top = ''; 615 document.getElementById('topBar').style.bottom = '0px'; 616 } 617 618 } 619 620 if(iframeObj){ 621 if(!calendarContentDivExists)setTimeout('resizeIframe()',350);else setTimeout('resizeIframe()',10); 622 } 623 624 625} 626 627function resizeIframe() 628{ 629 iframeObj.style.width = calendarDiv.offsetWidth + 'px'; 630 iframeObj.style.height = calendarDiv.offsetHeight + 'px' ; 631 632 633} 634 635function pickTodaysDate() 636{ 637 var d = new Date(); 638 currentMonth = d.getMonth(); 639 currentYear = d.getFullYear(); 640 pickDate(false,d.getDate()); 641 642} 643 644function pickDate(e,inputDay) 645{
646 var month = currentMonth/1 +1; 647 if(month<10)month = '0' + month; 648 var day; 649 if(!inputDay && this)day = this.innerHTML; else day = inputDay; 650 651 if(day/1<10)day = '0' + day; 652 if(returnFormat){ 653 returnFormat = returnFormat.replace('dd',day); 654 returnFormat = returnFormat.replace('mm',month); 655 returnFormat = returnFormat.replace('yyyy',currentYear); 656 returnDateTo.value = returnFormat; 657 }else{ 658 for(var no=0;no<returnDateToYear.options.length;no++){ 659 if(returnDateToYear.options[no].value==currentYear){ 660 returnDateToYear.selectedIndex=no; 661 break; 662 } 663 } 664 for(var no=0;no<returnDateToMonth.options.length;no++){ 665 if(returnDateToMonth.options[no].value==month){ 666 returnDateToMonth.selectedIndex=no; 667 break; 668 } 669 } 670 for(var no=0;no<returnDateToDay.options.length;no++){ 671 if(returnDateToDay.options[no].value==day){ 672 returnDateToDay.selectedIndex=no; 673 break; 674 } 675 } 676 677 678 } 679 closeCalendar(); 680 681} 682 683// This function is from //www.codeproject.com/csharp/gregorianwknum.asp 684// Only changed the month add 685function getWeek(year,month,day){ 686 day = day/1; 687 year = year /1; 688 month = month/1 + 1; //use 1-12 689 var a = Math.floor((14-(month))/12); 690 var y = year+4800-a;
691 var m = (month)+(12*a)-3; 692 var jd = day + Math.floor(((153*m)+2)/5) + 693 (365*y) + Math.floor(y/4) - Math.floor(y/100) + 694 Math.floor(y/400) - 32045; // (gregorian calendar) 695 var d4 = (jd+31741-(jd%7))%146097%36524%1461; 696 var L = Math.floor(d4/1460); 697 var d1 = ((d4-L)%365)+L; 698 NumberOfWeek = Math.floor(d1/7) + 1; 699 return NumberOfWeek; 700} 701 702function writeBottomBar() 703{ 704 var d = new Date(); 705 var topBar = document.createElement('DIV'); 706 topBar.id = 'bottomBar'; 707 topBar.onclick = pickTodaysDate; 708 topBar.style.cursor = 'pointer'; 709 topBar.className = 'todaysDate'; 710 // var todayStringFormat = '[todayString] [dayString] [day] [monthString] [year]'; ;; 711 712 var day = d.getDay(); 713 if(day==0)day = 7; 714 day--; 715 716 var bottomString = todayStringFormat; 717 bottomString = bottomString.replace('[monthString]',monthArrayShort[d.getMonth()]); 718 bottomString = bottomString.replace('[day]',d.getDate()); 719 bottomString = bottomString.replace('[year]',d.getFullYear()); 720 bottomString = bottomString.replace('[dayString]',dayArray[day].toLowerCase()); 721 bottomString = bottomString.replace('[todayString]',todayString); 722 723 724 topBar.innerHTML = todayString + ': ' + d.getDate() + '. ' + monthArrayShort[d.getMonth()] + ', ' + d.getFullYear() ; 725 topBar.innerHTML = bottomString ; 726 //calendarDiv.appendChild(topBar); 727 728 729 730} 731function getTopPos(inputObj) 732{ 733 734 var returnValue = inputObj.offsetTop + inputObj.offsetHeight; 735 while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop; 736 return returnValue + calendar_offsetTop; 737} 738 739function getleftPos(inputObj) 740{ 741 var returnValue = inputObj.offsetLeft; 742 while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft; 743 return returnValue + calendar_offsetLeft; 744} 745 746function positionCalendar(inputObj) 747{ 748 calendarDiv.style.left = getleftPos(inputObj) + 'px'; 749 calendarDiv.style.top = getTopPos(inputObj) + 'px'; 750 if(iframeObj){ 751 iframeObj.style.left = calendarDiv.style.left; 752 iframeObj.style.top = calendarDiv.style.top; 753 } 754 755} 756 757function initCalendar() 758{ 759 if(MSIE){ 760 iframeObj = document.createElement('IFRAME'); 761 iframeObj.style.position = 'absolute'; 762 iframeObj.border='0px'; 763 iframeObj.style.border = '0px'; 764 iframeObj.style.backgroundColor = '#FF0000'; 765 document.body.appendChild(iframeObj); 766 } 767 768 calendarDiv = document.createElement('DIV'); 769 calendarDiv.id = 'calendarDiv'; 770 calendarDiv.style.zIndex = 1000; 771 772 document.body.appendChild(calendarDiv); 773 writeBottomBar(); 774 writeTopBar(); 775 776 777 778 if(!currentYear){ 779 var d = new Date(); 780 currentMonth = d.getMonth(); 781 currentYear = d.getFullYear(); 782 } 783 writeCalendarContent(); 784 785 786 787} 788 789 790function displayCalendar(inputField,format,buttonObj) 791{ 792 if(inputField.value.length==format.length){ 793 var monthPos = format.indexOf('mm'); 794 currentMonth = inputField.value.substr(monthPos,2)/1 -1; 795 var yearPos = format.indexOf('yyyy'); 796 currentYear = inputField.value.substr(yearPos,4); 797 var dayPos = format.indexOf('dd'); 798 tmpDay = inputField.value.substr(dayPos,2); 799 }else{ 800 var d = new Date(); 801 currentMonth = d.getMonth(); 802 currentYear = d.getFullYear(); 803 tmpDay = d.getDate(); 804 } 805 806 inputYear = currentYear; 807 inputMonth = currentMonth; 808 inputDay = tmpDay/1; 809 810 if(!calendarDiv){ 811 initCalendar(); 812 }else{ 813 if(calendarDiv.style.display=='block'){ 814 closeCalendar(); 815 return false; 816 } 817 writeCalendarContent(); 818 } 819 returnFormat = format; 820 returnDateTo = inputField; 821 positionCalendar(buttonObj); 822 calendarDiv.style.visibility = 'visible'; 823 calendarDiv.style.display = 'block'; 824 if(iframeObj){ 825 iframeObj.style.display = ''; 826 iframeObj.style.height = '140px'; 827 iframeObj.style.width = '195px'; 828 } 829 updateYearDiv(); 830 updateMonthDiv(); 831 832} 833 834function displayCalendarSelectBox(yearInput,monthInput,dayInput,buttonObj) 835{ 836 currentMonth = monthInput.options[monthInput.selectedIndex].value/1-1; 837 currentYear = yearInput.options[yearInput.selectedIndex].value; 838 839 inputYear = yearInput.options[yearInput.selectedIndex].value; 840 inputMonth = monthInput.options[monthInput.selectedIndex].value/1 - 1; 841 inputDay = dayInput.options[dayInput.selectedIndex].value/1; 842 843 if(!calendarDiv){
844 initCalendar(); 845 }else{ 846 writeCalendarContent(); 847 } 848 849 returnDateToYear = yearInput; 850 returnDateToMonth = monthInput; 851 returnDateToDay = dayInput; 852 853 854 855 856 857 returnFormat = false; 858 returnDateTo = false; 859 positionCalendar(buttonObj); 860 calendarDiv.style.visibility = 'visible'; 861 calendarDiv.style.display = 'block'; 862 if(iframeObj){ 863 iframeObj.style.display = ''; 864 iframeObj.style.height = calendarDiv.offsetHeight + 'px'; 865 iframeObj.style.width = calendarDiv.offsetWidth + 'px'; 866 } 867 updateYearDiv(); 868 updateMonthDiv(); 869 870}
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.