
var agendaStatus=0;var dateRegExp=/^date([0-9]{1,2})$/;var eventRegExp=/^date[0-9]{1,2}(\w[0-9]+)$/;var monthNameTable=[{short:'jan',long:'January'},{short:'feb',long:'February'},{short:'mar',long:'March'},{short:'apr',long:'April'},{short:'may',long:'May'},{short:'jun',long:'June'},{short:'jul',long:'July'},{short:'aug',long:'August'},{short:'sep',long:'September'},{short:'oct',long:'October'},{short:'nov',long:'November'},{short:'dec',long:'December'}];$(document).ready(function(){$('#summary').append('<a id="dynamic-agenda-close">Close</a>');$('#dynamic-agenda-close').live("click",removeAgenda);$('#navigation-previous-month, #navigation-next-month').click(function(event){event.preventDefault();if($(this).attr('id')=='navigation-next-month'){if(curYear==2009&&curMonth==2){$('<a></a>').prependTo('#navigation-previous-month');}
else if(curYear==2014&&curMonth==11){$('#navigation-next-month a').remove();}
else if(curYear==2014&&curMonth==12){return;}
var newMonthOffset=620;var newSlideEndPoint=0;var oldSlideEndPoint=-620;var newYear=curYear;var newMonth=curMonth+1;if(curMonth==12){newMonth=1;newYear=curYear+1;}}
else{if(curYear==2014&&curMonth==12){$('<a></a>').prependTo('#navigation-next-month');}
else if(curYear==2009&&curMonth==3){$('#navigation-previous-month a').remove();}
else if(curYear==2009&&curMonth==2){return;}
var newMonthOffset=-620;var newSlideEndPoint=0;var oldSlideEndPoint=620;var newYear=curYear;var newMonth=curMonth-1;if(curMonth==1){newMonth=12;newYear=curYear-1;}}
curMonth=newMonth;curYear=newYear;var oldMonthTitle=$('#navigation-month-window');var newMonthTitle=oldMonthTitle.clone();newMonthTitle.css('left',newMonthOffset);$('h3',newMonthTitle).attr('class','');$('h3',newMonthTitle).addClass(monthNameTable[newMonth-1].long.toLowerCase());$('.month',newMonthTitle).text(monthNameTable[newMonth-1].long);$('h3 span:last',newMonthTitle).attr('class','');$('h3 span:last',newMonthTitle).addClass('year year'+newYear);$('h3 span:last',newMonthTitle).text(newYear);newMonthTitle.insertBefore(oldMonthTitle);newMonthTitle.animate({left:newSlideEndPoint});oldMonthTitle.animate({left:oldSlideEndPoint},{complete:function(){$(this).remove();}});var tableView=$('<div id="dynamic-calendar-wrapper"></div>').load('/calendar/scripts/apis/calendar/show/'+newYear+monthNameTable[newMonth-1].short+'/',{},function(){$('#calendar table').remove();$('#dynamic-calendar-wrapper').remove();$(this).insertAfter('#navigation-month');var numCalendarEvents=count(calendarEvents);$('#navigation-month-window em').text(numCalendarEvents
+' item'
+((numCalendarEvents!=1)?'s':'')
+' this month');setupCalendar();});});function setupCalendar(){$('#calendar td .date span').each(function(index,element){dateRegExp.exec($(this).attr('class'));var curDate=new Date(curYear+'/'+curMonth+'/'+RegExp.lastParen);$(this).closest('td').data('date',curDate);});$('#calendar table li').each(function(index,element){$(element).click(function(event){event.preventDefault();window.location.hash='content';var urlToLoad=$('a:last',this).attr('href').replace('calendar/show','calendar/scripts/apis/calendar/show');if($('#calendar').data('visible-agenda')!=urlToLoad&&agendaStatus==0){agendaStatus=1;removeAgenda();var agendaView=$('<div id="dynamic-agenda-wrapper"></div>').load(urlToLoad,{},function(){$('#calendar').data('visible-agenda',urlToLoad);$(this).hide().insertAfter('#date-today').slideDown('medium');$('#summary').append('<a id="dynamic-agenda-close">Close</a>');$('#content').append($('#key').clone().attr('id','key-alt'));agendaStatus=0;});}}).bind('mouseenter',function(event){var curEvent=new Object();eventRegExp.exec($(this).closest('li').attr('id'));curEvent['id']=RegExp.lastParen;curEvent['json']=calendarEvents[curEvent['id']];curEvent['type']=curEvent['json']['type'].replace('other events','').replace(' and ',' ').replace(/ /g,'-');var infoTooltipWrapper=$("<div id='event-tooltip-wrapper'>"
+"<div id='event-tooltip' class='"
+curEvent['type']
+"'></div>"
+"</div>").hide();var infoTooltip=$('#event-tooltip',infoTooltipWrapper);if(($(this).closest('td').data('date').getDay()==1)||($(this).closest('td').data('date').getDay()==2)){infoTooltipWrapper.addClass('alt');}
if(typeof(curEvent['json']['event_id'])==='undefined'){if(curEvent['json']['college-status']){infoTooltip.addClass(curEvent['json']['college-status']);}
infoTooltip.append('<h4>Announcement</h4>');infoTooltip.append('<p class="details">'+curEvent['json']['text']+'</p>');if(curEvent['json']['type']=='academics'){infoTooltip.append('<p class="details"><a href="http://www4.wccnet.edu/academicinfo/academic-dates/">'
+'View all academic dates</a></p>');}}
else{infoTooltip.append('<h4>'+curEvent['json']['event_title']+'</h4>');if(curEvent['json']['event_duration']>1){infoTooltip.append('<span class="multi-day">, '
+curEvent['json']['event_duration']
+' day event</span>');}
if(curEvent['json']['event_canceled']=='1'){infoTooltip.append('<strong class="canceled">&nbsp;Canceled</strong>');}
if(curEvent['json']['event_sold_out']=='1'){infoTooltip.append('<strong class="sold-out">&nbsp;Sold Out</strong>');}
if(curEvent['json']['event_all_day']=='1'){infoTooltip.append('<span class="time">All day</span>');}
else{infoTooltip.append('<span class="time">'
+curEvent['json']['event_start_time_formatted']
+'&ndash;'
+curEvent['json']['event_end_time_formatted']
+'</span>');}
if(curEvent['json']['event_location']){var location_text=curEvent['json']['event_location'];if(curEvent['json']['event_oncampus']=='1'){location_text='WCC main campus, '+location_text;}
infoTooltip.append('<span class="location">'+location_text+'</span>');}
infoTooltip.append('<div class="details">'
+curEvent['json']['event_desc']
+'</div>');if(curEvent['json']['event_price_employees']||curEvent['json']['event_price_general']||curEvent['json']['event_price_seniors']||curEvent['json']['event_price_students']||curEvent['json']['event_price_includes']||curEvent['json']['event_restrictions']||curEvent['json']['event_limit']){var detailsList=$('<ul class="details"></ul>');if(curEvent['json']['event_price_employees']||curEvent['json']['event_price_general']||curEvent['json']['event_price_seniors']||curEvent['json']['event_price_students']){var costsList=$('<li class="cost"><em>Cost:</em> <ul></ul></li>');var priceNameArray=['students','employees','general','seniors'];var priceHTMLArray=[];for(var name in priceNameArray){var price=curEvent['json']['event_price_'+priceNameArray[name]];if(price){if(priceNameArray[name]=='general'){priceHTMLArray.push('<li>$'+price+'/General Public</li>');}
else if(priceNameArray[name]=='seniors'){priceHTMLArray.push('<li>$'+price+'/Seniors</li>');}
else{priceHTMLArray.push('<li>$'
+price
+'/<acronym title="Washtenaw Community College">WCC</acronym> '
+priceNameArray[name].charAt(0).toUpperCase()
+priceNameArray[name].substr(1).toLowerCase()
+'</li>');}}}
$('ul',costsList).append(priceHTMLArray.join(''));$('ul li:not(:last)',costsList).each(function(index,element){$(element).text($(element).text()+', ');});detailsList.append(costsList);}
if(curEvent['json']['event_price_includes']){detailsList.append('<li class="includes"><em>Includes:</em> '
+curEvent['json']['event_price_includes']
+'</li>');}
if(curEvent['json']['event_limit']){detailsList.append('<li class="limit"><em>Limit:</em> '
+curEvent['json']['event_limit']
+'</li>');}
if(curEvent['json']['event_restrictions']){detailsList.append('<li class="restrictions">'
+curEvent['json']['event_restrictions']
+'</li>');}
infoTooltip.append(detailsList);}
var linksList=$('<ul class="links"></ul>');if(curEvent['json']['event_file']){var extension=(curEvent['json']['event_file_name'].indexOf('.zip')!=-1)?'zip':'pdf';linksList.append('<li class="file"><a class="'
+extension
+'" href="'
+curEvent['json']['event_file']
+'">Download '
+curEvent['json']['event_file_name']
+'</a></li>');}
if(curEvent['json']['event_contact_email']){linksList.append('<li class="contact"><a class="email" href="mailto:'
+curEvent['json']['event_contact_email']
+'">Contact '
+curEvent['json']['event_contact_name']
+'</a></li>');}
if(curEvent['json']['event_link']){var linkClass=(curEvent['json']['event_link'].indexOf('wccnet.edu')!=-1)?'':'external';linksList.append('<li class="link"><a class="'
+linkClass
+'" href="'
+curEvent['json']['event_link']
+'">'
+curEvent['json']['event_link_text']
+'</a></li>');}
linksList.append('<li><a class="view-entire-day" href="/calendar/show/'
+curYear
+monthNameTable[curMonth-1].short
+$(this).closest('td').data('date').getDate()
+'/#content">View entire day</a></li>');infoTooltip.append(linksList);}
$(this).prepend(infoTooltipWrapper);if(!jQuery.browser.msie){infoTooltipWrapper.fadeIn('fast');}
else{infoTooltipWrapper.show();}
$('a',infoTooltipWrapper).each(function(index,element){$(element).click(function(event){event.stopPropagation();});});$('.view-entire-day').click(function(event){event.preventDefault();$(this).parent('table .active ul:first li:first').click();});if($(this).closest('td div').length){$(this).closest('td div').addClass('active');}
else{$(this).closest('td').addClass('active');}
if(jQuery.browser.msie){$('#summary td.title').each(function(index,element){$(element).html($(element).html());});}}).bind('mouseleave',function(event){if(!jQuery.browser.msie){$('#event-tooltip-wrapper',this).fadeOut('fast',function(){$(this).remove();});}
else{$('#event-tooltip-wrapper',this).remove();}
if($(this).closest('td div').length){$(this).closest('td div').removeClass('active');}
else{$(this).closest('td').removeClass('active');}
if(jQuery.browser.msie){$('#summary td.title').each(function(index,element){$(element).html($(element).html());});}});});$('#calendar table span.more').each(function(index,element){$(element).click(function(event){event.preventDefault();$(this).prev('ul').find('li:first').click();});});};setupCalendar();function removeAgenda(){$('#calendar').data('visible-agenda',null);$('#summary').slideUp('fast',function(){$('#dynamic-agenda-wrapper').remove();});$('#key-alt').remove();}
function count(obj){var count=0;for(var item in obj){count++;}
return count;}});