var acd_list = new Array("20140307","20140306","20140305","20140304","20140303","20140302","20140301","20140228","20140227","20140226","20140225","20140224","20140223","20140222","20140221","20140220","20140219","20140218","20140217","20140216","20140215","20140214","20140213","20140212","20140211","20140210","20140209","20140208","20140207","20140206","20140205","20140204","20140203","20140202","20140201","20140131","20140130","20140129","20140128","20140127","20140126","20140125","20140124","20140123","20140122","20140121","20140120","20140119","20140118","20140117","20140116","20140115","20140114","20140113","20140112","20140111","20140110","20140109","20140108","20140107","20140106","20140105","20140104","20140103","20140102","20140101","20131231","20131230","20131229","20131228","20131227","20131226","20131225","20131224","20131223","20131222","20131221","20131220","20131219","20131218","20131217","20131216","20131215","20131214","20131213","20131212","20131211","20131210","20131209","20131208","20131207","20131206","20131205","20131204","20131203","20131202","20131201","20131130","20131129","20131128","20131127","20131126","20131125","20131124","20131123","20131122","20131121","20131120","20131119","20131118","20131117","20131116","20131115","20131114","20131113","20131112","20131111","20131110","20131109","20131108","20131107","20131106","20131105","20131104","20131103","20131102","20131101","20131031","20131030","20131029","20131028","20131027","20131026","20131025","20131024","20131023","20131022","20131021","20131020","20131019","20131018","20131017","20131016","20131015","20131014","20131013","20131012","20131011","20131010","20131009","20131008","20131007","20131006","20131005","20131004","20131003","20131002","20131001","20130930","20130929","20130928","20130927","20130926","20130925","20130924","20130923","20130922","20130921","20130920","20130919","20130918","20130917","20130916","20130915","20130914","20130913","20130912","20130911","20130910","20130909","20130908","20130907","20130906","20130905","20130904","20130903","20130902","20130901","20130831","20130830","20130829","20130828","20130827","20130826","20130825","20130824","20130823","20130822","20130821","20130820","20130819","20130818","20130817","20130816","20130815","20130814","20130813","20130812","20130811","20130810","20130809","20130808","20130807","20130806","20130805","20130804","20130803","20130802","20130801","20130731","20130730","20130729","20130728","20130727","20130726","20130725","20130724","20130723","20130722","20130721","20130720","20130719","20130718","20130717","20130716","20130715","20130714","20130713","20130712","20130711","20130710","20130709","20130708","20130707","20130706","20130705","20130704","20130703","20130702","20130701","20130630","20130629","20130628","20130627","20130626","20130625","20130624","20130623","20130622","20130621","20130620","20130619","20130618","20130617","20130616","20130615","20130614","20130613","20130612","20130611","20130610","20130609","20130608","20130607","20130606","20130605","20130604","20130603","20130602","20130601","20130530","20130529","20130528","20130527","20130526","20130525","20130524","20130523","20130522","20130521","20130520","20130519","20130518","20130517","20130516","20130515","20130514","20130513","20130512","20130511","20130510","20130509","20130508","20130507","20130506","20130505","20130504","20130503","20130502","20130501","20130430","20130429","20130428","20130427","20130426","20130425","20130424","20130423","20130422","20130421","20130420","20130419","20130418","20130417","20130416","20130415","20130414","20130413","20130412","20130411","20130410","20130409","20130408","20130407","20130406","20130405","20130404","20130403","20130402","20130401","20130331","20130330","20130329","20130328","20130327","20130326","20130325","20130324","20130323","20130322","20130321","20130320","20130319","20130318","20130317","20130316","20130315","20130314","20130313","20130312","20130311","20130310","20130309","20130308","20130307","20130306","20130305","20130304","20130303","20130302","20130301","20130228","20130227","20130226","20130225","20130224","20130223","20130222","20130222","20130221","20130220","20130219","20130218","20130217","20130216","20130215","20130214","20130213","20130212","20130211","20130210","20130209","20130208","20130207","20130206","20130205","20130204","20130203","20130202","20130201","20130131","20130130","20130129","20130128","20130127","20130126","20130125","20130124","20130123","20130122","20130121","20130120","20130119","20130118","20130117","20130116","20130115","20130114","20130113","20130112","20130111","20130110","20130109","20130108","20130107","20130106","20130105","20130104","20130103","20130102","20130101","20121231","20121230","20121229","20121228","20121227","20121226","20121225","20121224","20121223","20121222","20121221","20121220","20121219","20121218","20121217","20121216","20121215","20121214","20121213","20121212","20121211","20121210","20121209","20121208","20121207","20121206","20121205","20121204","20121203","20121202","20121201","20121130","20121129","20121128","20121127","20121126","20121125","20121124","20121123","20121122","20121121","20121120","20121119","20121118","20121117","20121116","20121115","20121114","20121113","20121112","20121111","20121110","20121109","20121108","20121107","20121106","20121105","20121104","20121103","20121102","20121101","20121031","20121030","20121029","20121028","20121027","20121026","20121025","20121024","20121023","20121022","20121021","20121020","20121019","20121018","20121017","20121016","20121015","20121014","20121013","20121012","20121011","20121010","20121009","20121008","20121007","20121006","20121005","20121004","20121003","20121002","20121001","20120930","20120929","20120928","20120927","20120926","20120925","20120924","20120923","20120922","20120921","20120920","20120919","20120918","20120917","20120916","20120915","20120914","20120913","20120912","20120911","20120910","20120909","20120908","20120907","20120906","20120905","20120904","20120903","20120902","20120901","20120831","20120830","20120829","20120828","20101220","20101219","20101218","20101217","20101216","20101215","20101214","20101213","20101212","20101211","20101210","20101209","20101208","20101207","20101206","20101205","20101204","20101203","20101202","20101201","20101130","20101129","20101128","20101127","20101126","20101125","20101124","20101123","20101122","20101121","20101120","20101119","20101118","20101117","20101116","20101115","20101114","20101113","20101112","20101111","20101110","20101109","20101108","20101107","20101106","20101105","20101104","20101103","20101102","20101101","20101031","20101030","20101029","20101028","20101027","20101026","20101025","20101025","20101024","20101023","20101022","20101022","20101021","20101020","20101019","20101018","20101017","20101016","20101015","20101014","20101013","20101012","20101011","20101010","20101009","20101008","20101007","20101006","20101005","20101004","20101003","20101002","20101001","20100930","20100929","20100928","20100927","20100926","20100925","20100924","20100923","20100922","20100921","20100920","20100919","20100918","20100917","20100916","20100915","20100914","20100913","20100909","20100908","20100907","20100906","20100905","20100904","20100903","20100902","20100901","20100831","20100830","20100829","20100828","20100827","20100826","20100825","20100824","20100823","20100822","20100821","20100820","20100819","20100818","20100817","20100816","20100815","20100814","20100813","20100812","20100811","20100810","20100809","20100808","20100807","20100806","20100805","20100804","20100803","20100802","20100801","20100731","20100730","20100729","20100728","20100727","20100726","20100725","20100724","20100723","20100722","20100721","20100720","20100719","20100718","20100717","20100716","20100715","20100714","20100713","20100712","20100711","20100710","20100709","20100708","20100707","20100706","20100705","20100704","20100703","20100702","20100701","20100630","20100629","20100628","20100627","20100626","20100625","20100624","20100623","20100622","20100621","20100620","20100619","20100618","20100617","20100616","20100615","20100614","20100613","20100612","20100611","20100610","20100609","20100608","20100607","20100606","20100605","20100604","20100603","20100602","20100601","20100531","20100530","20100529","20100528","20100527","20100526","20100525","20100524","20100523","20100522","20100521","20100520","20100519","20100518","20100517","20100516","20100515","20100514","20100513","20100512","20100511","20100510","20100509","20100508","20100507","20100506","20100505","20100504","20100503","20100502","20100501","20100430","20100429","20100428","20100427","20100426","20100425","20100424","20100423","20100422","20100421","20100420","20100419","20100418","20100417","20100416","20100415","20100414","20100413","20100412","20100411","20100410","20100409","20100408","20100407","20100406","20100405","20100404","20100403","20100402","20100401","20100331","20100330","20100329","20100328","20100327","20100326","20100325","20100324","20100323","20100322","20100321","20100320","20100319","20100318","20100317","20100316","20100315","20100314","20100313","20100312","20100311","20100310","20100309","20100308","20100307","20100306","20100305","20100304","20100303","20100302","20100301","20100228","20100227","20100226","20100225","20100224","20100223","20100222","20100221","20100220","20100219","20100218","20100217","20100216","20100215","20100214","20100213","20100212","20100211","20100210","20100209","20100208","20100207","20100206","20100205","20100204","20100203","20100202","20100201","20100131","20100130","20100129","20100128","20100127","20100126","20100125","20100124","20100123","20100122","20100121","20100120","20100119","20100118","20100117","20100116","20100115","20100114","20100113","20100112","20100111","20100110","20100109","20100108","20100107","20100106","20100105","20100104","20100103","20100102","20100101","20091231","20091230","20091229","20091228","20091227","20091226","20091225","20091224","20091223","20091222","20091221","20091220","20091219","20091218","20091217","20091216","20091215","20091214","20091213","20091212","20091211","20091210","20091209","20091208","20091207","20091206","20091205","20091204","20091203","20091202","20091201","20091130","20091129","20091128","20091127","20091126","20091125","20091124","20091123","20091122","20091121","20091120","20091119","20091118","20091117","20091116","20091115","20091114","20091113","20091112","20091111","20091110","20091109","20091108","20091107");//var acd_list = new Array("20091125","20091124","20091123","20091122","20091121","20091120","20091119","20091118","20091117","20091116","20091115","20091114","20091113","20091112","20091111","20091110","20091109","20091108","20091107"); // // user defined onchange handler function cal_on_change_dummy(cal, object_code) { if (object_code == 'day') { cal.show_date(); //var reg=new RegExp("(-)", "g"); for(var i=0; i < acd_list.length; i++){ if(cal.get_formatted_date('%Y%m%d')==acd_list[i]) // alert(acd_list[i]+' == ' + cal.get_formatted_date('%Y%m%d').substr(2,6)); document.location.href=cal.get_formatted_date('%Y%m%d').substr(2,6)+"-acd-stat-37410.html"; // http://www.switzernet.com/public/091029-ACDstat/091125-acd-stat-37410.html } } } function in_acd_list(day_num,cur_month,cur_year) { for(var i=0; i < acd_list.length; i++){ if (day_num<10) day = "0" + day_num; else day = day_num; var c_month = 1+cur_month; if (c_month<10) c_month = "0" + c_month; var dt = ""+cur_year+c_month+day; if(dt==acd_list[i]) return true; } return false; } // Rich Calendar RichCalendar = function(target_obj, show_time) { // value this.value = ''; // format this.format = '%Y-%m-%d'; // Week Day to start with (0 - Sunday, 1 - Monday, etc...) this.start_week_day = 1; // iframe object to show calendar object in this.iframe_obj = null; // path to calendar css and js files this.lib_path = 'rich_calendar/'; // DOM object to take/set date from/to this.target_obj = target_obj; // show time this.show_time = show_time; // function called when calendar value changes this.user_onchange_handler = null; // function called when data choice is cancelled this.user_onclose_handler = null; // function called when mouse clicked outside calendar with auto_close set // to true after it is closed this.user_onautoclose_handler = null; // default language this.default_lang = 'en'; // language this.language = 'en'; // current date this.date = new Date(); /* this.date.setFullYear(2008); this.date.setMonth(1); this.date.setDate(29); */ //this.date.setMonth(11); //this.date.setDate(31); // calendar skin name this.skin = ''; // calendar closes automatically on click outside it this.auto_close = false; // element which value is taken to initilize calendar and where calendar // returns date if user defined function to return date is not specified this.value_el = null; // specifies calendar positioning - absolute by default this.position = null; } RichCalendar.is_ie = /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent); // Static functions RichCalendar.get_iframe_styles = function() { var i; var j; var styles = document.styleSheets; var sheets_num = styles.length; var style_text = ''; for (i=0; i ' + e.srcElement + ' => ' + e.target + ' => ' + window.event); //for (var i in e) alert(i + ' => ' + e[i]); var event = RichCalendar.get_event(e); var obj = RichCalendar.get_target_object(e); if (!obj) return; var cal = obj.calendar; var cur_year = cal.date.getFullYear(); var cur_month = cal.date.getMonth(); var cur_day = cal.date.getDate(); //alert(obj.rc_object_code); switch (obj.rc_object_code) { case 'day': // alert(obj.day_num); cal.date.setDate(obj.day_num); break; case 'prev_year': // determine number of days in prev year cal.date.setDate(1); cal.date.setFullYear(cur_year-1); var month_days = RichCalendar.get_month_days(cal.date); // prevent jumping to next month if (cur_day > month_days) { cal.date.setDate(month_days); } else { cal.date.setDate(cur_day); } cal.show_date(); break; case 'prev_month': // determine number of days in prev month cal.date.setDate(1); cal.date.setMonth(cur_month-1); var month_days = RichCalendar.get_month_days(cal.date); // prevent jumping to next month if (cur_day > month_days) { cal.date.setDate(month_days); } else { cal.date.setDate(cur_day); } cal.show_date(); break; case 'next_month': // determine number of days in prev month cal.date.setDate(1); cal.date.setMonth(cur_month+1); var month_days = RichCalendar.get_month_days(cal.date); // prevent jumping to next month if (cur_day > month_days) { cal.date.setDate(month_days); } else { cal.date.setDate(cur_day); } cal.show_date(); break; case 'next_year': // determine number of days in next year cal.date.setDate(1); cal.date.setFullYear(cur_year+1); var month_days = RichCalendar.get_month_days(cal.date); // prevent jumping to next month if (cur_day > month_days) { cal.date.setDate(month_days); } else { cal.date.setDate(cur_day); } cal.show_date(); break; case 'today': var today = new Date(); today.setHours(cal.date.getHours()); today.setMinutes(cal.date.getMinutes()); today.setSeconds(cal.date.getSeconds()); cal.date = today; cal.show_date(); break; case 'clear': // handle clear request if (cal.value_el) { cal.value_el.value = ''; } break; case 'close': // handle close request cal.onclose_handler(); break; case 'week_day': //alert(obj.innerHTML); cal.start_week_day = obj.week_day_num; cal.show_date(); break; default: break; } // handle close request if (obj.rc_object_code != 'week_day') { cal.onchange_handler(obj.rc_object_code); } // handle date change // hide all other auto closing calendars RichCalendar.hide_auto_close(cal); } // calendar onmouseover event handler RichCalendar.onmouseover = function(e) { //alert(e + ' => ' + e.srcElement + ' => ' + e.target + ' => ' + window.event); //for (var i in e) alert(i + ' => ' + e[i]); var event = RichCalendar.get_event(e); var obj = RichCalendar.get_target_object(e); if (!obj) return; var cal = obj.calendar; var cur_year = cal.date.getFullYear(); var cur_month = cal.date.getMonth(); var cur_day = cal.date.getDate(); switch (obj.rc_object_code) { case 'day': var date = new Date(cal.date); date.setDate(obj.day_num); cal.set_footer_text(cal.get_formatted_date(cal.text('footerDateFormat'), date)); // highlight day cell and its row RichCalendar.add_class(obj, "rc_highlight"); RichCalendar.add_class(obj.parentNode, "rc_highlight"); break; case 'clear': case 'today': case 'close': case 'prev_year': case 'prev_month': case 'next_month': case 'next_year': cal.set_footer_text(cal.text(obj.rc_object_code)); break; case 'week_day': if (obj.week_day_num != cal.start_week_day) { var day_names = cal.text("dayNames"); var name = day_names[obj.week_day_num]; var text = cal.text("make_first"); text = text.replace("%s", name); } else { var text = cal.text('footerDefaultText'); } cal.set_footer_text(text); break; default: cal.set_footer_text(cal.text('footerDefaultText')); break; } } // calendar onmouseout event handler RichCalendar.onmouseout = function(e) { //alert(e + ' => ' + e.srcElement + ' => ' + e.target + ' => ' + window.event); //for (var i in e) alert(i + ' => ' + e[i]); var event = RichCalendar.get_event(e); var obj = RichCalendar.get_target_object(e); if (!obj) return; var cal = obj.calendar; cal.set_footer_text(cal.text('footerDefaultText')); // un-highlight day cell and its row RichCalendar.remove_class(obj, "rc_highlight"); RichCalendar.remove_class(obj.parentNode, "rc_highlight"); } // document onmousedown event handler RichCalendar.document_onmousedown = function(e) { var event = RichCalendar.get_event(e); var obj = RichCalendar.get_target_object(e); if (!obj) return; var el = obj; var cal = null; while (el) { if (el.className && el.className.match(/^rc_iframe_body/) && el.tagName.toUpperCase() == 'BODY') { cal = el.calendar; break; } el = el.parentNode; } // close all not active calendars RichCalendar.hide_auto_close(cal); } // hide all calendars that should autoclose except cal and remove // them from RichCalendar.active_calendars RichCalendar.hide_auto_close = function(cal) { var active_cals = []; var i; for (i=0; i 11) month = null; } if (!month) { month = date.getMonth(); } if (month==1 && RichCalendar.is_leap_year(year)) { return 29; } else { //alert(month + ' -> ' + RichCalendar.month_days[month]); return RichCalendar.month_days[month]; } } // return true if year is a leap year RichCalendar.is_leap_year = function(year) { return (year%4==0 && year%100!=0 || year%400==0) ? true : false; } // return day of the year RichCalendar.get_day_of_year = function(date) { var now = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); var year_start = new Date(date.getFullYear(), 0, 0, 0, 0, 0); // milliseconds in day var day_in_msecs = 24*60*60*1000; return Math.floor((now - year_start) / day_in_msecs); } // add class to element RichCalendar.add_class = function(el, class_name) { RichCalendar.remove_class(el, class_name); el.className += " " + class_name; } // remove class from element RichCalendar.remove_class = function(el, class_name) { if (!el || !el.className) return var new_class_parts = []; var class_parts = String(el.className).split(" "); var i; for (i=0; i' + '' + '' + '' + '' + '' + ''; this.iframe_doc = this.iframe_obj.contentWindow.document; this.iframe_doc.open(); this.iframe_doc.write(iframe_content); this.iframe_doc.close(); RichCalendar.attach_event(this.iframe_doc, 'mousedown', RichCalendar.document_onmousedown); this.body_obj = this.iframe_doc.getElementById('rc_body'); this.body_obj.calendar = this; // main table this.table_obj = this.iframe_doc.createElement('TABLE'); this.table_obj.className = 'rc_table'; this.table_obj.setAttribute('id', 'rc_iframe_table'); this.table_obj.cellSpacing = 0; this.table_obj.cellPadding = 0; // store reference to the calendar this.table_obj.calendar = this; // header row this.head_tr = this.table_obj.insertRow(0); this.head_tr.className = 'rc_head_tr'; this.clear_td = this.head_tr.insertCell(0); this.clear_td.innerHTML = ' '; //this.clear_td.rc_object_code = 'clear'; //this.clear_td.calendar = this; //RichCalendar.attach_events(this.clear_td); //this.clear_td.className = 'rc_head_tr'; this.head_td = this.head_tr.insertCell(1); //this.head_td.className = 'rc_head_tr'; this.head_td.colSpan = 5; //this.head_td.innerHTML = 'asdf'; this.close_td = this.head_tr.insertCell(2); this.close_td.innerHTML = ' '; //this.close_td.rc_object_code = 'close'; //this.close_td.calendar = this; //RichCalendar.attach_events(this.close_td); //this.close_td.className = 'rc_head_tr'; // navigation row this.nav_tr = this.table_obj.insertRow(1); this.nav_tr.className = 'rc_nav_tr'; this.prev_year_td = this.nav_tr.insertCell(0); this.prev_year_td.innerHTML = ' '; //this.prev_year_td.rc_object_code = 'prev_year'; //this.prev_year_td.calendar = this; //RichCalendar.attach_events(this.prev_year_td); this.prev_month_td = this.nav_tr.insertCell(1); this.prev_month_td.innerHTML = '‹'; this.prev_month_td.rc_object_code = 'prev_month'; this.prev_month_td.calendar = this; RichCalendar.attach_events(this.prev_month_td); this.today_td = this.nav_tr.insertCell(2); this.today_td.colSpan = 3; this.today_td.innerHTML = this.text('today'); this.today_td.rc_object_code = 'today'; this.today_td.calendar = this; RichCalendar.attach_events(this.today_td); this.next_month_td = this.nav_tr.insertCell(3); this.next_month_td.innerHTML = '›'; this.next_month_td.rc_object_code = 'next_month'; this.next_month_td.calendar = this; RichCalendar.attach_events(this.next_month_td); this.next_year_td = this.nav_tr.insertCell(4); this.next_year_td.innerHTML = ' '; //this.next_year_td.rc_object_code = 'next_year'; //this.next_year_td.calendar = this; //RichCalendar.attach_events(this.next_year_td); // weekdays row this.wd_tr = this.table_obj.insertRow(2); this.wd_tr.className = 'rc_wd_tr'; var i; // var day_names = this.text('dayNamesShort'); for (i=0; i<7; i++) { // var wd = (i+this.start_week_day)%7; var td = this.wd_tr.insertCell(i); td.rc_object_code = 'week_day'; td.calendar = this; RichCalendar.attach_events(td); // td.innerHTML = day_names[wd]; // if (typeof(weekend_days[wd]) != "undefined") { // td.className = "rc_weekend_head"; // } } // calendar rows (initially create min number of rows necessary - 4) var rows_num = 4; var row_indx; var cell_indx; this.cal_tr = []; for (row_indx=0; row_indx " + position); var aligns = String(position).split("-"); if (aligns.length == 2) { var el_pos = RichCalendar.get_obj_pos(el); //alert(el_pos + ' => ' + el.offsetHeight); var x = el_pos[0]; var y = el_pos[1] + el.offsetHeight; // iframe border thikness var border_width = parseInt(this.iframe_obj.style.borderWidth); var cal_width = parseInt(this.iframe_obj.width) + 2*border_width; var cal_height = parseInt(this.iframe_obj.height) + 2*border_width; //alert('!: ' + cal_width + ' => ' + cal_height); // horizontal alignment switch (aligns[0]) { case "left": x -= cal_width; break; case "center": x += (el.offsetWidth - cal_width) / 2; break; case "right": x += el.offsetWidth; break; case "adj_right": x += el.offsetWidth - cal_width; break; default: break; } // vertical alignment switch (aligns[1]) { case "top": y -= el.offsetHeight + cal_height; break; case "center": y += (el.offsetHeight - cal_height) / 2 - el.offsetHeight; break; case "bottom": break; case "adj_bottom": y -= cal_height; break; default: break; } this.iframe_obj.style.left = x + 'px'; this.iframe_obj.style.top = y + 'px'; this.iframe_obj.style.visibility = 'visible'; } } // return true if calendar is relatively positioned RichCalendar.prototype.is_relative_position = function(position) { switch (position) { case "before": case "after": case "child": return true; default: return false; } } // creates an element in iframe RichCalendar.prototype.createElement = function(tagName, parent) { var el = this.iframe_doc.createElement(tagName); if (parent) { parent.appendChild(el); } return el; } // return text data desired RichCalendar.prototype.text = function(name, language) { if (typeof(language) == "undefined") { language = this.language; } if (typeof(RichCalendar.rc_lang_data[language]) != "undefined") { return typeof(RichCalendar.rc_lang_data[language][name]) != "undefined"?RichCalendar.rc_lang_data[language][name]:''; } return typeof(RichCalendar.rc_lang_data[this.default_language][name]) != "undefined"?RichCalendar.rc_lang_data[this.default_language][name]:''; } // show date in calendar RichCalendar.prototype.show_date = function() { // update week days row // numbers of weekend days var weekend_days = this.get_weekend_days(); var i; var day_names = this.text('dayNamesShort'); for (i=0; i<7; i++) { var wd = (i+this.start_week_day)%7; var td = this.wd_tr.cells[i]; td.innerHTML = day_names[wd]; if (typeof(weekend_days[wd]) != "undefined") { td.className = "rc_weekend_head"; } else { td.className = ""; } // td.rc_object_code = 'week_day'; // td.calendar = this; td.week_day_num = wd; // RichCalendar.attach_events(td); } var month_days = RichCalendar.get_month_days(this.date); // alert(month_days); // first day of the same month and year as this.date var date = new Date(this.date); date.setDate(1); var week_day = (date.getDay()+7-this.start_week_day)%7+1; // alert(week_day); // current data var cur_year = this.date.getFullYear(); var cur_month = this.date.getMonth(); var cur_day = this.date.getDate(); //alert(cur_year + ' => ' + cur_month + ' => ' + cur_day); // today var today = new Date(); var today_year = today.getFullYear(); var today_month = today.getMonth(); var today_day = today.getDate(); // var month_names = this.text('monthNames'); this.head_td.innerHTML = month_names[cur_month] + ', ' + cur_year; var row; var day; var days = 0; var last_row; for (row=0; row<6; row++) { // all days are shown => just check if need to remove unused rows if (days == month_days) { if (this.cal_tr[last_row+1]) { this.cal_tr[last_row+1].parentNode.removeChild(this.cal_tr[last_row+1]); this.cal_tr[row] = null; } continue; } for (day=0; day<7; day++) { if (!this.cal_tr[row]) { this.create_cal_row(row); } var cur_tr = this.cal_tr[row]; var cell = cur_tr.cells[day]; cell.className = ""; // should remove or IE attach the same event several times RichCalendar.detach_events(cell); if (row==0 && day+1 < week_day || days == month_days) { var td_text = ' '; // RichCalendar.detach_events(cell); } else { var day_num = days+1; var td_text = day_num; days++; cell.rc_object_code = 'day'; cell.day_num = day_num; cell.calendar = this; RichCalendar.attach_events(cell); // hilight current date //if (cur_day == day_num) { // RichCalendar.add_class(cell, "rc_current"); //} if (in_acd_list(day_num,cur_month,cur_year)) { RichCalendar.add_class(cell, "rc_acdrouting"); } // hilight today date if (day_num == today_day && cur_month == today_month && cur_year == today_year) { RichCalendar.add_class(cell, "rc_today"); } var wd = (day+this.start_week_day)%7; // hilight weekend days if (typeof(weekend_days[wd]) != "undefined") { RichCalendar.add_class(cell, "rc_weekend_day"); } else { RichCalendar.remove_class(cell, "rc_weekend_day"); } } cell.innerHTML = " "+td_text; if (days == month_days) { last_row = row; } } } // set time if (this.show_time && this.hours_obj && this.mins_obj) { var hours = this.date.getHours(); if (hours < 10) hours = '0' + hours; var mins = this.date.getMinutes(); if (mins < 10) mins = '0' + mins; this.hours_obj.value = hours; this.mins_obj.value = mins; } // change size of the iframe to fit to its content /* var table_obj = this.iframe_doc.getElementById('rc_iframe_table'); this.iframe_obj.width = table_obj.offsetWidth; this.iframe_obj.height = table_obj.offsetHeight; */ var cal = this; window.setTimeout(function(){cal.fit_to_content()}, 1); // fix position (need to do this later then calendar is shown as // size of calendar could change in this.show(x, y) window.setTimeout(function(){cal.fix_position()}, 5); } // change size of the iframe to fit to its content RichCalendar.prototype.fit_to_content = function() { try { var table_obj = this.iframe_doc.getElementById('rc_iframe_table'); this.iframe_obj.width = table_obj.offsetWidth; this.iframe_obj.height = table_obj.offsetHeight; //alert(this.iframe_obj.width + ' => ' + this.iframe_obj.height); // sometimes IE return 0 values, so need to use another approach to // determine size of the calendar if (!parseInt(this.iframe_obj.width) || !parseInt(this.iframe_obj.height)) { this.size_div.innerHTML = this.body_obj.innerHTML; //alert(this.size_div.offsetWidth + ' => ' + this.size_div.offsetHeight); this.iframe_obj.width = this.size_div.offsetWidth; this.iframe_obj.height = this.size_div.offsetHeight; } }catch(e){} } // create calendar row RichCalendar.prototype.create_cal_row = function(index) { var row = this.table_obj.insertRow(3+index); row.className = 'rc_cal_tr'; var cell_indx; for (cell_indx=0; cell_indx<7; cell_indx++) { var td = row.insertCell(cell_indx); // td.innerHTML = index + '-' + cell_indx; } this.cal_tr[index] = row; return row; } // changes calendar layout RichCalendar.prototype.change_skin = function(skin) { if (!this.iframe_obj) return; var skin_suffix = RichCalendar.skin_suffix(skin); this.iframe_obj.className = 'rc_calendar' + skin_suffix; this.body_obj.className = 'rc_iframe_body' + skin_suffix; this.skin = skin; } // returns formatted date (chars recognized are alike used by PHP function date) RichCalendar.prototype.get_formatted_date = function(format, date) { if (!date) date = this.date; if (!format) format = this.get_date_format(); // set time if (this.show_time && this.hours_obj && this.mins_obj) { this.date.setHours(this.hours_obj.value); var mins = this.date.setMinutes(this.mins_obj.value); } var y = date.getFullYear(); var m = date.getMonth(); var d = date.getDate(); var wd = date.getDay(); var hr = date.getHours(); var mins = date.getMinutes(); var secs = date.getSeconds(); var month_names_short = this.text('monthNamesShort'); var month_names = this.text('monthNames'); var day_names_short = this.text('dayNamesShort'); var day_names = this.text('dayNames'); var am = hr < 12 ? true : false; var hr12 = hr > 12 ? hr - 12 : (hr == 0 ? 12 : hr); var f = []; f["%a"] = am?'am':'pm'; f["%A"] = am?'AM':'PM'; f["%d"] = d < 10 ? '0'+d : d; // day of the month, 2 digits with leading zeroes (01 to 31) f["%D"] = day_names_short[wd]; // day of the week, textual, short, eg "Fri" f["%F"] = month_names[m]; // month, textual, long; eg "January" f["%h"] = hr12 < 10 ? '0' + hr12 : hr12; // hour, 12-hour format (01 to 12) f["%H"] = hr < 10 ? '0' + hr : hr; // hour, 24-hour format (00 to 23) f["%g"] = hr12; // hour, 12-hour format without leading zeros (1 to 12) f["%G"] = hr; // hour, 24-hour format without leading zeros (0 to 23) f["%i"] = mins < 10 ? '0' + mins : mins; // minutes (00 to 59) f["%j"] = d; // day of the month without leading zeros (1 to 31) f["%l"] = day_names[wd]; // day of the week, textual, long, eg "Friday" f["%L"] = RichCalendar.is_leap_year(y)?1:0; // 1 if leap year, otherwise - 0 f["%m"] = m < 9 ? '0' + (m+1) : (m+1); //month (01 to 12) f["%n"] = m + 1; //month without leading zeros (1 to 12) f["%M"] = month_names_short[m]; // month, textual, short, eg "Jan" f["%s"] = secs < 10 ? '0' + secs : secs; // seconds (00 to 59) f["%t"] = RichCalendar.get_month_days(date); // number of days in the month (28 to 31) f["%w"] = wd; // day of the week, numeric (0, Sunday to 6, Saturday) f["%Y"] = y; // year, 4 digits, eg 2007 f["%y"] = String(y).substr(2, 2); // year, 2 digits, eg "07" f["%z"] = RichCalendar.get_day_of_year(date); // day of the year (1 to 366) var parts = String(format).match(/%./g); var i; var f_date = format; for (i=0; i // replace them with english month names for (j=0; j ' + f_p); for (i=0; i= 12) { hours -= 12; } else { if (/pm/i.test(p[i]) && hours < 12) { hours += 12; } } break; case '%d': case '%j': day = parseInt(Number(p[i])); break; case '%F': for (j=0; j= 12) { hours -= 12; } else { if (/pm/i.test(p[i]) && hours < 12) { hours += 12; } } break; case '%i': mins = parseInt(Number(p[i])); break; case '%m': case '%n': month = parseInt(Number(p[i]))-1; break; case '%M': for (j=0; j 29 ? 1900 : 2000); } break; default: break; } } if (isNaN(year) || year <= 0) year = today.getFullYear(); if (isNaN(month) || month < 0 || month > 11) month = today.getMonth(); if (isNaN(day) || day <= 0 || day > 31) day = today.getDate(); if (isNaN(hours) || hours < 0 || hours > 23) hours = today.getHours(); if (isNaN(mins) || mins < 0 || mins > 59) mins = today.getMinutes(); if (isNaN(seconds) || seconds < 0 || seconds > 59) seconds = today.getSeconds(); //alert(year + ' => ' + month + ' => ' + day + ' => ' + hours + ' => ' + mins + ' => ' + seconds); this.date = new Date(year, month, day, hours, mins, seconds); }