function CalendarTable(f,a){var h=function(q){var s=(0<q.border.length)?"border: 1px solid "+q.border:"border-width: 1px; border-style: solid";var t="padding: 5px 10px 5px 10px; ";var v=(0<q.dateForeground.length)?"color: "+q.dateForeground+"; ":"";var u=(0<q.dateBackground.length)?"background-color: "+q.dateBackground+"; ":"";var r={tableOpen:'<table style="border-collapse: collapse; '+s+'">',tableClose:"</table>",rowOpen:"<tr>",rowClose:"</tr>",colLeftOpen:'<td style="text-align: right; '+t+s+'">',colLeftClose:"</td>",colCenterOpen:'<td style="text-align: center; '+t+v+u+s+'">',colCenterClose:"</td>",colRightOpen:'<td style="text-align: left; '+t+s+'">',colRightClose:"</td>",secondaryRowOpen:'<br /><span style="font-size: smaller">',secondaryRowClose:"</span>"};return r};var o=function(u){if(u!=null){var q=u.getElementsByTagName("CalendarItem");for(var s=1;s<q.length;s++){var t=c(q,s);var r=m(t);if(0<r.xhtml.length){d[s-1]=r}}}return};var c=function(r,s){var q={name:e(r,s,"Event"),startDate:e(r,s,"StartDate"),endDate:e(r,s,"EndDate"),time:e(r,s,"Time"),place:e(r,s,"Place"),category:e(r,s,"Category"),description:e(r,s,"Description"),link:e(r,s,"Link"),url:e(r,s,"Url"),target:e(r,s,"Target")};return q};var e=function(r,t,s){var w="";var v=null;var q=r[t].getElementsByTagName(s);try{v=q[0].firstChild.nodeValue}catch(u){v=w}return v};var m=function(r){var q={xhtml:j(r),date:Date.parse(r.startDate),category:r.category};return q};var j=function(r){var s="";if(0<r.name.length&&0<r.startDate.length){s+=p.rowOpen;var q=g(r);s+=p.colLeftOpen+q;if(0<r.description.length){s+=p.secondaryRowOpen+r.description+p.secondaryRowClose}s+=p.colLeftClose;s+=p.colCenterOpen+b(r.startDate);if(0<r.endDate.length){s+=p.secondaryRowOpen+"through "+b(r.endDate)+p.secondaryRowClose}s+=p.colCenterClose;s+=p.colRightOpen+r.place;if(0<r.time.length){s+=p.secondaryRowOpen+r.time+p.secondaryRowClose}s+=p.colRightClose}return s};var g=function(r){var q=r.name;if(0<r.url.length){var s=(0<r.target.length)?r.target:"_top";q='<a href="'+r.url+'" target="'+s+'" title="Click for more information">'+q+"</a>"}return q};var b=function(q){var r=q.indexOf(",");if(0<r){q=q.substr(0,r)}return q};var k=function(q){return p.tableOpen+q+p.tableClose};var l=function(s,r){var q=Date.parse(s);return isFinite(q)?q:r};var n=function(r,s){var q=0;if(s=="all"){q=1}else{var t=s.length;for(i=0;i<t&&!q;i++){if(r==s[i]){q=1}}}return q};var p=h(a);var d=new Array();this.events=function(s){var u="";var q=l(s.startDate,Date.parse(today()));var t=l(s.endDate,0);for(var r=0;r<d.length;r++){if(q<=d[r].date&&(0==t||d[r].date<=t)&&n(d[r].category,s.category)){u+=d[r].xhtml}}u=(0<u.length)?k(u):"<p>No events found.</p>";return u};if(f!=null){o(f.responseXML)}}function Calendar(g,a,b,j,c){var h=function(){for(var k=1;k<c.length;k++){if(0<c[k].length){clear(c[k])}}if(2<=b.length){b[0].disabled=0;b[0].focus();b[0].value=d.startDate;b[0].blur();b[0].disabled=1;b[1].disabled=0;b[1].focus();b[1].value=d.endDate;b[1].blur();b[1].disabled=1}document.getElementById(c[0]).innerHTML=f.events(d)};var e=function(l,n){var k="<p style='margin: 10px 0 0px 0; color: #ff9933'>";var m="</p>";document.getElementById(n).innerHTML=k+l+m};var f=new CalendarTable(g,a);var d={category:new Array(),startDate:today(),endDate:""};this.selectEvents=function(l,m,n){if(m=="Select All"){for(k=0;k<l.length;k++){l[k].checked=1}}else{if(m=="Clear All"){for(k=0;k<l.length;k++){l[k].checked=0}}}if(!n.length||n==m){d.category=new Array();for(var k=0;k<l.length;k++){if(l[k].checked){d.category[d.category.length++]=l[k].value}}}h()};this.submitDates=function(l){if(2<=b.length){var k=b[0].value.length?b[0].value:today();if(isNaN(Date.parse(k))){var m='Starting date entry is invalid: "'+b[0].value+'".';e(m,l)}else{var n=b[1].value;if(n.length&&isNaN(Date.parse(n))){var m='Ending date entry is invalid: "'+b[1].value+'".';e(m,l)}else{d.startDate=k;d.endDate=n;h()}}}};for(i=0;i<j.length;i++){j[i].checked=1;d.category[i]=j[i].value}h()}var today=function(){var b=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var a=new Date();return b[a.getMonth()]+" "+a.getDate()+", "+a.getFullYear()};function clear(a){document.getElementById(a).innerHTML=""};
