xmlhttp_init();var upcoming_events=new Array();var upcoming_events_order=new Array();var all_calendars=new Array();function plans_upcoming_events(_1){this.id=get_property(_1,"id","ue0");this.background_calendars_mode=get_property(_1,"background_calendars_mode","menu");this.plans_url=get_property(_1,"plans_url","");this.days_before=get_property(_1,"days_before","30");this.days_after=get_property(_1,"days_after","0");this.cal_ids_string=get_property(_1,"cal_ids","0");this.merge_days=get_property(_1,"merge_days",false);this.include_details=get_property(_1,"include_details",false);this.debug=get_property(_1,"debug",false);this.cal_ids=this.cal_ids_string.split(",");this.plans_theme_url="";this.anchor=get_property(_1,"list_element",null);this.menu_anchor=get_property(_1,"menu_element",null);this.inited=false;this.current_calendar=0;this.init=function(){if(document.getElementById(this.anchor)){this.anchor_element=document.getElementById(this.anchor);}else{alert("unable to attach upcoming_events to anchor element with id: "+this.anchor);return;}if(document.getElementById(this.menu_anchor)){this.menu_anchor_element=document.getElementById(this.menu_anchor);}this.inited=true;};this.load=function(){if(!page_loaded){this.load_later();return false;}var _2=this.plans_url+"?get_upcoming_events=1";_2+="&cal_ids="+this.cal_ids_string;_2+="&days_before="+this.days_before;_2+="&days_after="+this.days_after;_2+="&background_calendars_mode="+this.background_calendars_mode;_2+="&upcoming_events_id="+this.id;if(this.debug){debug("upcoming events url:\n"+_2);}this.new_script=document.createElement("script");this.new_script.type="text/javascript";this.new_script.id="upcoming_events_script";this.new_script.defer=true;this.new_script.src=_2;document.getElementsByTagName("head").item(0).appendChild(this.new_script);return;};this.load_later=function(){setTimeout(this.id+".load()",200);};this.menusort=function(a,b){if(!temp_cal_ids){return 0;}if(array_indexof(temp_cal_ids,a)>array_indexof(temp_cal_ids,b)){return 1;}if(array_indexof(temp_cal_ids,a)<array_indexof(temp_cal_ids,b)){return -1;}return 0;};this.show=function(){if(!this.inited){this.init();}var _5=this.generate_menu();this.menu_anchor_element.innerHTML=_5;this.draw();};this.generate_menu=function(){var _6=this;all_calendars.sort(function(a,b){if(array_indexof(_6.cal_ids,a+"")>array_indexof(_6.cal_ids,b+"")){return 1;}if(array_indexof(_6.cal_ids,a+"")<array_indexof(_6.cal_ids,b+"")){return -1;}return 0;});if(this.background_calendars_mode=="one_big_list"){return "";}var _9="";_9+="<select id=\"upcoming_events_calendar_select\" onChange=\""+this.id+".draw()\">";for(var i=0;i<all_calendars.length;i++){var _b=all_calendars[i];if(this.background_calendars_mode=="none"||this.background_calendars_mode=="list"){if(!array_contains(this.cal_ids,_b)){continue;}else{if(this.background_calendars_mode=="menu"){if(!array_contains(all_calendars,_b)){continue;}}}}var _c=calendars[_b];_9+="<option value=\""+_c.id+"\">"+_c.title+"</option>";}_9+="<select>";return _9;};this.draw=function(){var _d=document.getElementById("upcoming_events_calendar_select");if(_d&&_d.selectedIndex!=-1){this.current_calendar=_d[_d.selectedIndex].value;}else{this.current_calendar=this.cal_ids[0];}var _e=this.generate_upcoming_events();if(!this.anchor_element){alert("(draw) anchor_element not defined.");return;}if(this.anchor_element.tagName.toLowerCase()=="table"){if(this.anchor_element.outerHTML){_e="<table id=\"upcoming_events_list\" class=\"upcoming_events\">"+_e+"</table>";this.anchor_element.outerHTML=_e;this.anchor_element=document.getElementById(this.anchor);}else{this.anchor_element.innerHTML=_e;}}else{this.anchor_element.innerHTML=_e;}};this.generate_upcoming_events=function(){var _f="";upcoming_events_order.sort(upcoming_eventssort);var _10=new Array();var _11=new Array();var _12=-1;for(var _13 in upcoming_events_order){var _14=upcoming_events[upcoming_events_order[_13]];if(!_14||!_14.cal_ids){continue;}if(this.background_calendars_mode=="one_big_list"){}else{if(this.background_calendars_mode=="none"||this.background_calendars_mode=="menu"){if(!array_contains(_14.cal_ids,this.current_calendar)){continue;}}else{if(this.background_calendars_mode=="list"){var _15=false;if(array_contains(_14.cal_ids,this.current_calendar)){_15=true;}else{if(this.current_calendar.local_background_calendars){for(var i=0;i<this.current_calendar.local_background_calendars.length;i++){if(array_contains(_14.cal_ids,this.current_calendar.local_background_calendars[i])){_15=true;}break;}}}if(!_15){continue;}}}}var _17;var _18;var _19="";var _1a="";var _1b=(_14.details_url)?_14.details:"javascript:"+this.id+".display_event('"+_14.id+"')";if(_14.all_day_event){_19=nice_date(_14.start,_14.start*1+86400*(_14.days-1),true,false);_1a="";}else{_19=nice_date(_14.start,_14.end,true,false);_1a=nice_time(_14.start,_14.end);}if(this.anchor_element.tagName.toLowerCase()=="ul"){_f+="<li>";_f+="<a href=\""+_1b+"\">";_f+="<span class=\"date\">"+_19+"</span>";_f+="<span class=\"title\">";if(_14.icon&&_14.icon!="blank"){_f+="<img class=\"icon\" src=\""+this.plans_theme_url+"/icons/"+_14.icon+"_16x16.gif\"/>";}_f+=_14.title+"</span></a>";if(this.include_details){_f+=upcoming_events_format_details(_14.details);}_f+="</li>";}else{if(this.anchor_element.tagName.toLowerCase()=="table"){if(this.merge_days){var _1c=new Date(_14.start*1000).getDate();if(!_10[_1c]){_10[_1c]=new Array();_11.push(_1c);}_10[_1c].push(_14.id);}else{_f+="<tr><td class=\"date\">";_f+="<a href=\""+_1b+"\">";_f+="<span class=\"date\">"+_19+"</span>";_f+="</td><td class=\"title\">";_f+="<a href=\""+_1b+"\">";_f+="<span class=\"title\">";if(_14.icon&&_14.icon!="blank"){_f+="<img class=\"icon\" src=\""+this.plans_theme_url+"/icons/"+_14.icon+"_16x16.gif\"/>";}_f+=_1a+" "+_14.title+"</span></a>";if(this.include_details){_f+=upcoming_events_format_details(_14.details);}_f+="</td></tr>";}}}}if(this.merge_days){if(this.anchor_element.tagName.toLowerCase()=="table"){for(var _1d in _11){var _1e=upcoming_events[_10[_11[_1d]][0]];var _1f=formatDate(new Date(_1e.start*1000),"dna MNA dd");_f+="<tr><td class=\"merged_events date\">";_f+="<span class=\"date\">"+_1f+"</span>";_f+="</td><td class=\"merged_events\">";var _20=_10[_11[_1d]];for(var _21 in _20){var _22=upcoming_events[_10[_11[_1d]][_21]];var _23=(_22.all_day_event)?"":nice_time(_22.start,_22.end);var _24=(_22.details_url)?_22.details:"javascript:"+this.id+".display_event('"+_22.id+"')";_f+="<div class=\"merged_event\"><a href=\""+_24+"\">";_f+="<span class=\"title\">";if(_14.icon&&_14.icon!="blank"){_f+="<img class=\"icon\" src=\""+this.plans_theme_url+"/icons/"+_22.icon+"_16x16.gif\"/>";}_f+=_23+" "+_22.title+"</span></a>";if(this.include_details){_f+=upcoming_events_format_details(_22.details);}_f+="</div>";}}_f+="</td></tr>";}else{}}return _f;};this.display_event=function(_25){var _26=window_x()-info_window_width;var _27=window_y();if(_25.match(/^r/)){}else{var _28=this.plans_url+"?view_event=1&evt_id="+_25;info_window=window.open(_28,"info_window","resizable=yes,status=yes,scrollbars=yes,top="+_27+",left="+_26+",width="+info_window_width+",height="+info_window_height);}info_window.focus();};}function upcoming_events_format_details(_29){var _2a="<br/>"+_29;return _2a;}function upcoming_eventssort(a,b){if(upcoming_events[a].start<upcoming_events[b].start){return -1;}if(upcoming_events[a].start>upcoming_events[b].start){return 1;}return 0;}