// JavaScript Document var day; var month; var year; var cal_box; var nummonths; var monthfrom; var monthto; if (document.getElementById && document.getElementsByTagName) { if (window.addEventListener) { window.addEventListener('load', selects, false); } else if (window.attachEvent) { window.attachEvent('onload', selects); } } function selects() { document.getElementById("day").onchange = dow; document.getElementById("month").onchange = dow; document.getElementById("year").onchange = dow; document.onclick = check; } function check(e){ if(e) { var target = e.target; } else { var target = event.srcElement; } var obj = document.getElementById('calimage'); var left = document.getElementById('left'); var right = document.getElementById('right'); var lefty = document.getElementById('lefty'); var righty = document.getElementById('righty'); if(target==obj || target == left || target == right|| target == lefty || target == righty) { document.getElementById('cal').style.display='block'; norm(); } else { document.getElementById('cal').style.display='none'; } } function dow() { get_values('eql'); var d=new Date(year,month,day); document.getElementById("dow").innerHTML = weekday[d.getDay()]; } //number of days in month function days_in_month(year, month) { return 32 - new Date(year, month, 32).getDate(); } //first day of month function day_of_month(year, month, layer) { return new Date(year, month, 1).getDay(); } //populate boxes on calendar function populate_boxes(year, month, day, layer) { //N.B. month, 0=January ... 11=December var monthtxt; switch (month) { case 0: monthtxt = arrmonthtxt[0]; break; case 1: monthtxt = arrmonthtxt[1]; break; case 2: monthtxt = arrmonthtxt[2]; break; case 3: monthtxt = arrmonthtxt[3]; break; case 4: monthtxt = arrmonthtxt[4]; break; case 5: monthtxt = arrmonthtxt[5]; break; case 6: monthtxt = arrmonthtxt[6]; break; case 7: monthtxt = arrmonthtxt[7]; break; case 8: monthtxt = arrmonthtxt[8]; break; case 9: monthtxt = arrmonthtxt[9]; break; case 10: monthtxt = arrmonthtxt[10]; break; case 11: monthtxt = arrmonthtxt[11]; break; default : "Jul"; } //get number of days in month, so we know when to start end blanks var num_days_in_month = days_in_month(year, month); //get first day of month 0=Sunday, 6=Saturday var first_day_of_month = day_of_month(year, month); layer[2].innerHTML = monthtxt+" "+year; var cnt = 0; for(var i=0;i<42;i++)//10 is number of li to create and fill { var li = document.createElement("li"); var newli = document.getElementById('ulcal').appendChild(li); if(i"+cnt+""; } } } function selectday(selday, t) { for(var i=0;i=12;i--) { document.getElementById('ulcal').removeChild(layer[i]); } } function get_values(action, amt) { day = document.getElementById('day').options[document.getElementById('day').selectedIndex].text; month = parseInt(document.getElementById('month').options[document.getElementById('month').selectedIndex].value)-1; if(typeof(document.getElementById('year').selectedIndex) != 'undefined' && typeof(document.getElementById('year').options) != 'undefined') { year = document.getElementById('year').options[document.getElementById('year').selectedIndex].text; } else { year = document.getElementById('selyear').options[document.getElementById('selyear').selectedIndex].text; } cal_box = document.getElementById('cal').getElementsByTagName('li'); nummonths = parseInt(document.getElementById('month').options.length); monthfrom = parseInt(document.getElementById('month').options[0].value)-1; monthto = parseInt(document.getElementById('month').options[nummonths-1].value)-1; if(typeof(document.getElementById('year').options) != 'undefined') { numyears = parseInt(document.getElementById('year').options.length); yearfrom = document.getElementById('year').options[0].text; yearto = document.getElementById('year').options[numyears-1].text; } else { numyears = parseInt(document.getElementById('selyear').options.length); yearfrom = document.getElementById('selyear').options[0].text; yearto = document.getElementById('selyear').options[numyears-1].text; } //now unpopulate the calendar lists in preparartion for a refresh unpopulate_boxes(cal_box); if(action=="add"&&month!=-1) { if(month==monthto&&yearmonthfrom&&month != -1) { if(month==monthfrom&&year>yearfrom) { document.getElementById('month').selectedIndex = nummonths-1; document.getElementById('year').selectedIndex = document.getElementById('year').selectedIndex-1; populate_boxes(parseInt(year)-1, monthto, day, cal_box); } else if(month>monthfrom) { document.getElementById('month').selectedIndex = (parseInt(month)-1)-parseInt(monthfrom); populate_boxes(year, month-1, day, cal_box); } else {populate_boxes(year, month, day, cal_box);} } else if (action=="sub"&&month==monthfrom&&month != -1) { if(year==yearto) { document.getElementById('month').selectedIndex = nummonths-1; document.getElementById('year').selectedIndex = document.getElementById('year').selectedIndex-1; populate_boxes(year-1, month, day, cal_box); } } else if(action=="addyear") { if(year != yearto) { document.getElementById('year').selectedIndex = document.getElementById('year').selectedIndex+1; populate_boxes(year+1, month, day, cal_box); } else { document.getElementById('month').selectedIndex = nummonths-1; populate_boxes(year, monthto, day, cal_box); } } else if(action=="subyear") { if(year != yearfrom) { if(typeof(document.getElementById('year').options) != 'undefined') { document.getElementById('year').selectedIndex = document.getElementById('year').selectedIndex-1; populate_boxes(year-1, month, day, cal_box); } else { document.getElementById('month').selectedIndex = 0; populate_boxes(year, monthfrom, day, cal_box); } } } else { document.getElementById('month').selectedIndex = document.getElementById('month').selectedIndex = parseInt(month)-parseInt(monthfrom); populate_boxes(year, month, day, cal_box); } } function inc() { get_values('add'); } function dec() { get_values('sub'); } function incyear() { get_values('addyear'); } function decyear() { get_values('subyear'); } function norm() { get_values('eql'); }