var dd = new Date(); var year = dd.getFullYear(); var month = dd.getMonth(); var cyear = year; var cmonth = month; var calendarloaded = 0; var shortmonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var fullmonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var category = ''; var categoryOverridesDate = true; var startMonth = 5; var startYear = 2014; var click = ''; $(document).ready(function(){ mainhtml = '

M
T
W
T
F
S
S
'; $('.calendar').html( mainhtml ); $('.calendar .prev').on( 'click', previousMonth ); $('.calendar .next').on( 'click', nextMonth ); $('.filter a').on( "click", function() { category = $( this ).attr('class'); selectCategory(); }); makeCalendar( year, month, category ); calendarloaded = 1; }); function custom_onChangeMonth() { $.ajax({ type: "POST", url: "http://www.museumofcomedy.com/ajax/custom_calendardate.php", data: { month: month, year: year } }).done(function( msg ) { }); } function previousMonth() { click = 'previous'; if( !$(this).hasClass('disabled') ) { if( categoryOverridesDate ) { category = ''; } if( month-1 == -1 ) { month = 11; year -= 1; } else { month --; } makeCalendar(); } }; function nextMonth() { click = 'next'; if( !$('.next').hasClass('disabled') ) { if( categoryOverridesDate ) { category = ''; } if( month+1 == 12 ) { month = 0; year += 1; } else { month++; } makeCalendar(); } }; function selectCategory() { if( category == 'All' || category == 'Any' ) { category = 'All'; } makeCalendar(); }; function makeCalendar() { if( year < startYear || ( year == startYear && month < startMonth ) ) { dd.setMonth( startMonth ); dd.setYear( startYear ); month = dd.getMonth(); year = dd.getFullYear(); makeCalendar(); return( false ); } if (typeof( custom_onChangeMonth ) === 'function') { custom_onChangeMonth(); } if( ( year == startYear && month == startMonth ) || ( year == cyear && month == cmonth ) ) { $('.prev').addClass('disabled'); } else { $('.prev').removeClass('disabled'); } ddd = new Date( year, month+1, 1 ); emonth = ddd.getMonth(); eyear = ddd.getFullYear(); dddd = new Date( year, month+2, 1 ); eemonth = dddd.getMonth(); eeyear = dddd.getFullYear(); if( !eventMonths[String(emonth+1)+eyear] && !eventMonths[String(eemonth+1)+eeyear] ) { $('.next').addClass('disabled'); } else { $('.next').removeClass('disabled'); } var html = ''; var d = new Date( year, month, 1 ); var dim = new Date( year, month+1, 0 ); var daysInMonth = dim.getDate(); var categoryText = ''; $('.feature').hide(); if( category && categoryOverridesDate ) { categoryText = category; $( '.feature' + ((category!='All')?'.'+category:'') ).show(); } else if( category ) { categoryText = ', '+category; $('.feature' + ((category!='All')?'.'+category:'') + '.'+fullmonths[month] + year).show(); } else { $('.feature.'+fullmonths[month] + year).show(); } $('.calendarmonth').html( shortmonths[month] + ' ' + year ); $('.calendarmonth').attr( 'data-month', fullmonths[month] + year ); $('.calendarmonth').attr( 'data-month-display', fullmonths[month] + ' ' + year ); if( category && categoryOverridesDate ) { $('.calendarfullmonth').html( categoryText ); } else { $('.calendarfullmonth').html( fullmonths[month] + ' ' + year + categoryText ); } if( $( '.main > .content > .col1' ).height() <= 350 ) { if( click == 'next' ) { nextMonth(); } else if( click == 'previous' ) { previousMonth(); } return; } var firstday = d.getDay(); if( firstday == 0 ) { firstday = 7; } for( a = 1; a < firstday; a++ ) { html += '
'; } for( a = 1; a <= daysInMonth; a++ ) { if( a < 10 ) { aa = '0' + a; } else { aa = a; } if( eventDates[aa+String(month+1)+year] ) { title = eventDates[aa+String(month+1)+year]; cssclass = 'current'; } else { title = ''; cssclass = ''; } if( emonth == 0 ) { emonth = 12; eyear -= 1; } html += '
'+aa+'
'; } html += '
'; $('.dates').html( html ); $(document).on( 'click', '.current', function() { $('.feature').hide(); $('.Day-'+$(this).attr('data-day')).show(); $('.calendarfullmonth').html( $(this).attr('data-day-display') ); }); $(document).on( 'click', '.calendarmonth', function() { $('.feature').hide(); $('.'+$(this).attr('data-month')).show(); $('.calendarfullmonth').html( $(this).attr('data-month-display') ); }); }