dateFormat.masks.day = 'dddd'
dateFormat.masks.date = 'mmmm d, yyyy'
dateFormat.masks.month = 'mmmm'
dateFormat.masks.dayNum = 'd'
dateFormat.masks.year = 'yyyy'
dateFormat.masks.time = 'h:MM TT'

//FORMATS:
//singletime - shows the time of startDate
//bothtimes - shows the time of each date
//bothdays - shows the day of each date
//rangedaysinmonth - shows a range of the days, assumes all days in the same month
function Event(id, startDate, endDate, title, description, format) {
	this.getID = function() {
		return id;
	}

	this.getStartDate = function() {
		return startDate;
	};
	
	this.getEndDate = function() {
		return endDate;
	};
	
	this.getTitle = function() {
		return title;
	};
	
	this.getDescription = function() {
		return description;
	};
	
	this.getFormat = function() {
		return format;
	};
	
	this.containsDate = function(date) {
		var day = new Date(date.getTime());
		day.setHours(0,0,0,0);
		
		var startDay = new Date(startDate.getTime());
		startDay.setHours(0,0,0,0);
		var endDay = new Date(endDate.getTime());
		endDay.setHours(0,0,0,0);
		
		return startDay.getTime() <= day.getTime() && endDay.getTime() >= day.getTime();
	}
	
	this.compareTo = function(event) {
		return startDate.getTime() - event.getStartDate().getTime();
	}
	
	this.isSingleDay = function(date1, date2){
		return startDate.getFullYear() == endDate.getFullYear() &&
			startDate.getMonth() == endDate.getMonth() &&
			startDate.getDate() == endDate.getDate();
	}

	this.isSingleTime = function(){
		return startDate.getTime() == endDate.getTime();
	}
	
	this.isComing = function() {
		return new Date().getTime() < endDate.getTime();
	}
	
	this.isPast = function() {
		return !(this.isComing());
	}
	
	this.getStartDateString = function() {
		return startDate.format("date");
	}
	
	this.getDateString = function() {
		var value = "";
		switch(this.getFormat()) {
			case 'singletime':
				value += startDate.format("date");
				value += " at ";
				value += startDate.format("time");
				break;
			case 'bothtimes':
				value += startDate.format("date");
				value += " From "
				value += startDate.format("time");
				value += " to ";
				value += endDate.format("time");
				break;
			case 'bothdays':
				value += startDate.format("day");
				value += " ";
				value += startDate.format("date");
				value += " - ";
				value += endDate.format("day");
				value += " ";
				value += endDate.format("date");
				break;
			case 'rangedaysinmonth':
				value += startDate.format("month");
				value += " ";
				value += startDate.format("dayNum");
				value += "-";
				value += endDate.format("dayNum");
				value += ", ";
				value += startDate.format("year");
				break;
		}
		
		return value;
	}
	
	this.toHTML = function() {
		var item = "<h2>";
		item += this.getTitle();
		item += "</h2>";
		
		var startDate = this.getStartDate();
		var endDate = this.getEndDate();
		var format = this.getFormat();
		
		item += "<h3>";
		item += this.getDateString();
		item += "</h3>";
		
		item += "<p>";
		item += this.getDescription();
		item += "</p>";
		
		return item;
	}
}
