$(document).ready(function() {
	var emailerText = '';	
	$('#emailcontent ul > li .date').each(function(index) {
		emailerText = validateEmailerDate($(this).text());
		//alert(index + ': ' + $(this).text() );
		if (emailerText != 'valid')
			$(this).parent().hide();
	});	
	$('#emailcontent ul').show();
});

function daysInPreviousMonth() {
	var t_date = new Date();
	//alert(t_date.getDate()+'-'+t_date.getMonth()+'-'+t_date.getFullYear());
	//t_date.setMonth(t_date.getMonth()-1);
	
	var dd = new Date(t_date.getFullYear(), t_date.getMonth(), 0);
	//alert('dd:'+' '+dd.getDate());
	return dd.getDate();
}

function validateEmailerDate(dateString){
	var emailerDate = new Date(dateString);//date of the emailer
	var today = new Date();//sets the today date
	
	dif = today - emailerDate;//difference in milliseconds
	dif = Math.ceil(dif/1000/60/60/24);//difference in days
		
	num = daysInPreviousMonth()+today.getDate();
	//alert('daysInPreviousMonth():'+daysInPreviousMonth()+'\n\ntoday.getDate():'+today.getDate()+'\n\ndif:'+dif+ ' ' +'num:'+num);
	if (dif > num)
		return 'invalid';
	else
		return 'valid';
}

