$(function() {
	$('.home #flash_push').flash(
		{src:"flash/HalfmoonSpa_home.swf",
		 width:378,
		 height:361,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});
	
	var monthWrapper = $('#month-wrapper');
	if (monthWrapper.length) {
		var daysList = $('.days-list'), 
	    currentDay = currentDay || 'monday', 
	    daysAnchors = $('.days-list li a'), 
	    dayCells = $('td.' + currentDay),
	    activeRows=[];
	    //hideEmptyCells();

	    function addZebraStripes() {
		$('table.special-calendar tr:even').addClass('odd');
	    }
	    addZebraStripes();
		
		function hideEmptyCells() {
			var tableCells = $('td.' + currentDay);
			tableCells.each(function() {
				// this regex matches a pattern that starts and ends with a whitespace character.
				// if a match is found, it hides the table row ($(this.parent()), if not it shows the table row (and some may be hidden)
				var whiteSpaceRegex = /^\s*$/;
				if (whiteSpaceRegex.test( $(this).text()) ) {
				$(this).parent().hide();
				} else {
				$(this).parent().show();
				activeRows.push($(this).parent());
				}
			});
			addZebraStripes();
	    };

		
	    daysAnchors.click(function() {
		// check if the anchor you just clicked on has a class of current
			if (($(this).parent().hasClass('current')) ) { 
				return false;//dont follow the link
			}
			else {		//else if it doesn't proceed with the rest of this functon
				// hide the current day cells
				dayCells.hide();
				// take the value of the parent elements class attribute (since the mcc doesnt allow id attributes on lis) and extract the remaining chars after 'days-' via String.prototype.slice
				var classAttribute = $(this).parent().attr('class');
				currentDay = classAttribute.slice(5,classAttribute.length);
				dayCells = $('td.' + currentDay);	
				// show the new current day cells
				dayCells.show();
					
				// update the current state
				$('ul.days-list .current').removeClass('current');
				$(this).parent().addClass('current');
				// commented out for now: hideEmptyCells(); 
				addZebraStripes();
		
				return false;
			}
	    });
	}


});

  
		