function Logo( startDate, endDate, imgSrc ) 
{
	var dateString = startDate.split( " " );
	this.startDate = startDate;
	this.startMonth = dateString[1]-1;
	this.startDay = Number(dateString[2]);
	
	dateString = endDate.split( " " );
	this.endDate = endDate;
	this.endMonth = dateString[1]-1;
	this.endDay = Number(dateString[2])+1;

	this.imgSrc = imgSrc;
}
/*
	Returns true if the current month and day fall within the range of
	the run of this logo.
*/
Logo.prototype.isWithinRelativeDateRange = function ( thisMonth, today ) {
	var shift = 12 - this.startMonth;
	var startMonthRel = (shift + this.startMonth) % 12;
	var endMonthRel = (shift + this.endMonth) % 12;
	var thisMonthRel = (shift + thisMonth) % 12;
	var result = false;

	if ( thisMonthRel >= startMonthRel && thisMonthRel <= endMonthRel ) {
		result = true;

		if ( thisMonthRel == startMonthRel && today < this.startDay ) {
			result = false;
		}
		else if ( thisMonthRel == endMonthRel && today >= this.endDay ) {
			result = false;
		}
	}

	return result;
}
/*
	Returns true if this logo expires before another logo.
*/
Logo.prototype.compareDates = function ( anotherLogo, thisMonth ) {
	var shift = 12 - thisMonth;
	var thisLogoEndMonthRel = (shift + this.endMonth) % 12;
	var anotherLogoEndMonthRel = (shift + anotherLogo.endMonth) % 12;

	var result = 0; // default case is same end date

	if (thisLogoEndMonthRel < anotherLogoEndMonthRel) {
		result = 1; // other logo ends after this logo
	}
	else if (thisLogoEndMonthRel > anotherLogoEndMonthRel) {
		result = -1; // other logo ends before this logo
	}
	else { // same month
		if (this.endDay < anotherLogo.endDay) {
			result = 1;
		}
		else if (this.endDay > anotherLogo.endDay) {
			result = -1;
		}
	}
	
	return result;
}

getCurrentLogoIndex = function ( logos ) {
	var myDate = new Date();
	var today = myDate.getDate();
	var thisMonth = myDate.getMonth();
	var result = -1;

	for ( var i = 0; i < logos.length; i++ )
	{
		if ( logos[i].isWithinRelativeDateRange(myDate.getMonth(), myDate.getDate())) {
			if ( result < 0 ) {
				result = i;
			}
			else {
				var shift = 12 - thisMonth;
				var thisLogoEndMonthRel = (shift + logos[i].endMonth) % 12;
				var anotherLogoEndMonthRel = (shift + logos[result].endMonth) % 12;

				if (thisLogoEndMonthRel < anotherLogoEndMonthRel) {
					result = i; // this logo ends sooner
				}
				else if (thisLogoEndMonthRel == anotherLogoEndMonthRel) { // same month
					if (logos[i].endDay < logos[result].endDay) {
						result = i; // this logo ends sooner
					}
					else if (logos[i].endDay == logos[result].endDay && logos[i].startDay > logos[result].startDay) {
						result = i; // both end times are the same, this logo started later
					}
				}
			}
		}
	}
	
	return result;
}
