/*********************************************************
**	This script will simulate the lessons launched counter
**	as seen on HowToMaster.com
** 
**	Call the getLessonCount() method.
**	After calling the method the lessons launched will
**	be placed within the element with id=lessons.
**
**	Written By: Wesley Gilreath
**	Date: 7/19/2007
*********************************************************/

var janArray = new Array(24);
	janArray[0] = 9770;
	janArray[1] = 2421;
	janArray[2] = 1217;
	janArray[3] = 691;
	janArray[4] = 1708;
	janArray[5] = 1448;
	janArray[6] = 2041;
	janArray[7] = 5852;
	janArray[8] = 20074;
	janArray[9] = 25779;
	janArray[10] = 29674;
	janArray[11] = 37297;
	janArray[12] = 35277;
	janArray[13] = 42996;
	janArray[14] = 41115;
	janArray[15] = 38096;
	janArray[16] = 29938;
	janArray[17] = 23519;
	janArray[18] = 17169;
	janArray[19] = 15136;
	janArray[20] = 13045;
	janArray[21] = 12191;
	janArray[22] = 11153;
	janArray[23] = 8215;
var febArray = new Array(24);
	febArray[0] = 5514;
	febArray[1] = 1911;
	febArray[2] = 1091;
	febArray[3] = 727;
	febArray[4] = 1123;
	febArray[5] = 1465;
	febArray[6] = 1989;
	febArray[7] = 5383;
	febArray[8] = 14830;
	febArray[9] = 24128;
	febArray[10] = 26278;
	febArray[11] = 35112;
	febArray[12] = 33288;
	febArray[13] = 37174;
	febArray[14] = 32144;
	febArray[15] = 27595;
	febArray[16] = 21458;
	febArray[17] = 16725;
	febArray[18] = 13970;
	febArray[19] = 13469;
	febArray[20] = 11126;
	febArray[21] = 9560;
	febArray[22] = 7946;
	febArray[23] = 4933;
var marArray = new Array(24);
	marArray[0] = 4776;
	marArray[1] = 1619;
	marArray[2] = 1025;
	marArray[3] = 788;
	marArray[4] = 1106;
	marArray[5] = 1290;
	marArray[6] = 1959;
	marArray[7] = 6370;
	marArray[8] = 18736;
	marArray[9] = 20748;
	marArray[10] = 24859;
	marArray[11] = 31173;
	marArray[12] = 33321;
	marArray[13] = 31173;
	marArray[14] = 28867;
	marArray[15] = 25191;
	marArray[16] = 18817;
	marArray[17] = 13517;
	marArray[18] = 10738;
	marArray[19] = 10261;
	marArray[20] = 8709;
	marArray[21] = 8464;
	marArray[22] = 7117;
	marArray[23] = 4394;
var aprArray = new Array(24);
	aprArray[0] = 5261;
	aprArray[1] = 1787;
	aprArray[2] = 1099;
	aprArray[3] = 652;
	aprArray[4] = 1137;
	aprArray[5] = 1053;
	aprArray[6] = 1465;
	aprArray[7] = 5071;
	aprArray[8] = 14653;
	aprArray[9] = 19969;
	aprArray[10] = 28103;
	aprArray[11] = 27918;
	aprArray[12] = 26574;
	aprArray[13] = 27887;
	aprArray[14] = 29818;
	aprArray[15] = 27240;
	aprArray[16] = 21114;
	aprArray[17] = 15961;
	aprArray[18] = 11772;
	aprArray[19] = 10070;
	aprArray[20] = 9788;
	aprArray[21] = 10251;
	aprArray[22] = 9214;
	aprArray[23] = 5622;
var mayArray = new Array(24);
	mayArray[0] = 5298;
	mayArray[1] = 2355;
	mayArray[2] = 1464;
	mayArray[3] = 792;
	mayArray[4] = 1583;
	mayArray[5] = 1198;
	mayArray[6] = 1585;
	mayArray[7] = 5027;
	mayArray[8] = 16796;
	mayArray[9] = 19150;
	mayArray[10] = 25579;
	mayArray[11] = 26931;
	mayArray[12] = 26818;
	mayArray[13] = 27311;
	mayArray[14] = 30410;
	mayArray[15] = 29527;
	mayArray[16] = 22498;
	mayArray[17] = 16442;
	mayArray[18] = 12107;
	mayArray[19] = 9794;
	mayArray[20] = 8866;
	mayArray[21] = 10402;
	mayArray[22] = 9428;
	mayArray[23] = 6611;
var junArray = new Array(24);
	junArray[0] = 7159;
	junArray[1] = 3737;
	junArray[2] = 2442;
	junArray[3] = 1957;
	junArray[4] = 1706;
	junArray[5] = 1740;
	junArray[6] = 2216;
	junArray[7] = 2941;
	junArray[8] = 8310;
	junArray[9] = 12421;
	junArray[10] = 16736;
	junArray[11] = 18208;
	junArray[12] = 16914;
	junArray[13] = 17252;
	junArray[14] = 18366;
	junArray[15] = 19795;
	junArray[16] = 18267;
	junArray[17] = 14206;
	junArray[18] = 10478;
	junArray[19] = 8900;
	junArray[20] = 7996;
	junArray[21] = 8059;
	junArray[22] = 7948;
	junArray[23] = 6486;
var julArray = new Array(24);
	julArray[0] = 4864;
	julArray[1] = 1333;
	julArray[2] = 866;
	julArray[3] = 534;
	julArray[4] = 515;
	julArray[5] = 542;
	julArray[6] = 1060;
	julArray[7] = 1724;
	julArray[8] = 3623;
	julArray[9] = 5778;
	julArray[10] = 8293;
	julArray[11] = 9838;
	julArray[12] = 9254;
	julArray[13] = 9733;
	julArray[14] = 10705;
	julArray[15] = 10457;
	julArray[16] = 8923;
	julArray[17] = 6910;
	julArray[18] = 5283;
	julArray[19] = 4614;
	julArray[20] = 4276;
	julArray[21] = 4220;
	julArray[22] = 3923;
	julArray[23] = 2793;
var augArray = new Array(24);
	augArray[0] = 9353;
	augArray[1] = 957;
	augArray[2] = 669;
	augArray[3] = 405;
	augArray[4] = 612;
	augArray[5] = 578;
	augArray[6] = 794;
	augArray[7] = 1385;
	augArray[8] = 4982;
	augArray[9] = 6852;
	augArray[10] = 9279;
	augArray[11] = 10223;
	augArray[12] = 9915;
	augArray[13] = 12420;
	augArray[14] = 13685;
	augArray[15] = 12243;
	augArray[16] = 8948;
	augArray[17] = 6172;
	augArray[18] = 5296;
	augArray[19] = 5023;
	augArray[20] = 4382;
	augArray[21] = 3981;
	augArray[22] = 3450;
	augArray[23] = 2156;
var sepArray = new Array(24);
	sepArray[0] = 3833;
	sepArray[1] = 770;
	sepArray[2] = 465;
	sepArray[3] = 433;
	sepArray[4] = 4867;
	sepArray[5] = 2949;
	sepArray[6] = 6155;
	sepArray[7] = 5808;
	sepArray[8] = 11188;
	sepArray[9] = 18050;
	sepArray[10] = 23826;
	sepArray[11] = 21723;
	sepArray[12] = 20842;
	sepArray[13] = 21028;
	sepArray[14] = 18521;
	sepArray[15] = 12847;
	sepArray[16] = 9857;
	sepArray[17] = 6227;
	sepArray[18] = 5180;
	sepArray[19] = 4869;
	sepArray[20] = 4380;
	sepArray[21] = 4180;
	sepArray[22] = 3048;
	sepArray[23] = 1842;
var octArray = new Array(24);
	octArray[0] = 3209;
	octArray[1] = 904;
	octArray[2] = 570;
	octArray[3] = 393;
	octArray[4] = 3263;
	octArray[5] = 2060;
	octArray[6] = 3904;
	octArray[7] = 6595;
	octArray[8] = 11073;
	octArray[9] = 20466;
	octArray[10] = 25489;
	octArray[11] = 24414;
	octArray[12] = 21273;
	octArray[13] = 23050;
	octArray[14] = 24154;
	octArray[15] = 17101;
	octArray[16] = 13373;
	octArray[17] = 9041;
	octArray[18] = 7230;
	octArray[19] = 7252;
	octArray[20] = 7065;
	octArray[21] = 6497;
	octArray[22] = 4842;
	octArray[23] = 2595;
var novArray = new Array(24);
	novArray[0] = 4609;
	novArray[1] = 1002;
	novArray[2] = 608;
	novArray[3] = 505;
	novArray[4] = 2365;
	novArray[5] = 1699;
	novArray[6] = 2866;
	novArray[7] = 6389;
	novArray[8] = 14731;
	novArray[9] = 20168;
	novArray[10] = 27316;
	novArray[11] = 28031;
	novArray[12] = 22311;
	novArray[13] = 24748;
	novArray[14] = 22944;
	novArray[15] = 21666;
	novArray[16] = 16326;
	novArray[17] = 12167;
	novArray[18] = 8978;
	novArray[19] = 8413;
	novArray[20] = 7717;
	novArray[21] = 6949;
	novArray[22] = 5808;
	novArray[23] = 3987;
var decArray = new Array(24);
	decArray[0] = 6688;
	decArray[1] = 1534;
	decArray[2] = 695;
	decArray[3] = 319;
	decArray[4] = 544;
	decArray[5] = 605;
	decArray[6] = 1067;
	decArray[7] = 5192;
	decArray[8] = 12981;
	decArray[9] = 15340;
	decArray[10] = 18797;
	decArray[11] = 21950;
	decArray[12] = 20083;
	decArray[13] = 23391;
	decArray[14] = 18420;
	decArray[15] = 18222;
	decArray[16] = 14846;
	decArray[17] = 11717;
	decArray[18] = 7652;
	decArray[19] = 5980;
	decArray[20] = 5552;
	decArray[21] = 5385;
	decArray[22] = 4664;
	decArray[23] = 3282;
var months = new Array(12);
	months[0] = janArray;
	months[1] = febArray;
	months[2] = marArray;
	months[3] = aprArray;
	months[4] = mayArray;
	months[5] = junArray;
	months[6] = julArray;
	months[7] = augArray;
	months[8] = sepArray;
	months[9] = octArray;
	months[10] = novArray;
	months[11] = decArray;

var baseLessons = 11625725;  // LESSON COUNT AS OF 7/17/2007 14:41:00
var startDate = new Date("7/17/2007 14:41:00");
var estimatedLessons = estimateLessons(startDate,new Date()) + baseLessons;
	
function getDateDiff(startDate,endDate) {

	var startYear = startDate.getFullYear();
	
	var endYear = endDate.getFullYear();

	var days = 0;
	var hours = 0;
	var minutes = 0;
	var seconds = 0;
	
	var day = (1000 * 60 * 60 * 24);
	var hour = (1000 * 60 * 60);
	var minute = (1000 * 60);
	var second = 1000;

	var diff = new Date();
	diff.setTime(Math.abs(endDate.getTime() - startDate.getTime()));

	var timediff = 0;
	timediff = diff.getTime();

	days = Math.floor(timediff / day); 
	timediff -= days * day;
	
	hours = Math.floor(timediff / hour); 
	timediff -= hours * hour;
	
	minutes = Math.floor(timediff / minute); 
	timediff -= minutes * minute;
	
	seconds = Math.floor(timediff / second); 
	timediff -= seconds * second;

//alert("DateDiff for " + startDate + " - " + endDate +"\ndays: " + days + "\nhours: " + hours + "\nminutes: " + minutes + "\nseconds: " + seconds);

	var dateDiff = new Array(4);
	dateDiff[0] = days;
	dateDiff[1] = hours;
	dateDiff[2] = minutes;
	dateDiff[3] = seconds;
	
	return dateDiff;

}

function getDaysPerYear(year) {
	
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	
	if (isleap) {
		return 366;
	}
	else {
		return 365;
	}
	
}

function getDaysPerMonth(month,year) {

	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	
	var monthDays = new Array(12);
		monthDays[0] = 31;
		monthDays[1] = 28;
		monthDays[2] = 31;
		monthDays[3] = 30;
		monthDays[4] = 31;
		monthDays[5] = 30;
		monthDays[6] = 31;
		monthDays[7] = 31;
		monthDays[8] = 30;
		monthDays[9] = 31;
		monthDays[10] = 30;
		monthDays[11] = 31;
	
	if (isleap) {
		monthDays[1] = 29;
	}
	
	return monthDays[month];
		
}

// RETURN THE AVERAGE LESSONS LAUNCHED FOR A SELECT DATE
function getAverageLessons(date,precision) {

	var date = new Date(date);
	var lessons = 0;
	
	switch (precision)
	{
		case "month":
			lessons = getArrayTotal(months[date.getMonth()]);
			break;
		case "day":
			lessons = getArrayTotal(months[date.getMonth()]) / 30;
			break;
		case "hour":
			lessons = months[date.getMonth()][date.getHours()] / 30;
			break;
		case "minute":
			lessons = (months[date.getMonth()][date.getHours()] / 30) / 60;
			break;
		case "second":
			lessons = ((months[date.getMonth()][date.getHours()] / 30) / 60) / 60;
			break;
		default:
			lessons = months[date.getMonth()][date.getHours()];
			break;
	}
	
	return lessons;

}

// SUM THE CONTENTS OF AN ARRAY AND RETURN THE SUM
function getArrayTotal(array) {

	var total = 0;
	
	for(i=0;i<array.length;i++) {
		total += array[i];
	}
	
	return total;

}

// TOTAL THE APPROXIMATED LESSONS LAUNCHED SINCE 7/17/2007 14:41:00
function getLessonCount() {

	showLessons();
	
	setInterval(showLessons, 3000);
	
}

// RECALCULATE THE ESTIMATED LESSONS AND DISPLAY NEW TOTAL
function showLessons() {

	var lessonsText = document.getElementById("lessons");
	var totalLessons = estimateLessons(startDate,new Date()) + baseLessons;
	
	estimatedLessons = new String(totalLessons).split("");
	totalLessons = "";
	var counter = 1;
	
	for (z=estimatedLessons.length-1;z>=0;z--){
		if (counter % 3 != 0){
			totalLessons = estimatedLessons[z] + "" + totalLessons;
		}
		else{
			totalLessons = "," + estimatedLessons[z] + "" + totalLessons;
		}
		counter += 1;
	}

	lessonsText.innerHTML = totalLessons;
	
}

// CALCULATE THE ESTIMATED LESSONS LAUNCHED
function estimateLessons(start,end) {

	var startDate = start;
	var startYear = startDate.getFullYear();
	var startMonth = startDate.getMonth();
	var startDay = startDate.getDate();
	var startHour = startDate.getHours();
	var startMinute = startDate.getMinutes();
	var startSecond = startDate.getSeconds();
	
	var endDate = end;
	var endYear = endDate.getFullYear();
	var endMonth = endDate.getMonth();
	var endDay = endDate.getDate();
	var endHour = endDate.getHours();
	var endMinute = endDate.getMinutes();
	var endSecond = endDate.getSeconds();
	
	var months = 0;
	var days = 0;
	var hours = 0;
	var minutes = 0;
	var seconds = 0;

	var estimatedLessons = 0;
	var tempDate = new Date(startDate);
	
	if ((endYear - startYear) > 0) {
		for (c=startDay;c<=getDaysPerMonth(startMonth,startYear);c++) {
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(c));
			days += 1;
		}// end for
		for (d=startHour;d<=23;d++) {
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(d));
			hours += 1;
		}// end for
		for (e=startMinute;e<=59;e++) {
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(e));
			minutes += 1;
		}// end for
		for (f=startSecond;f<=59;f++) {
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(f));
			seconds += 1;
		}// end for
		tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds() + 1));
		
		var dateDiff = getDateDiff(tempDate,endDate);
		
		for (c=1;c<=dateDiff[0];c++){
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(tempDate.getDate()+1));
			days += 1;
		}
		for (d=1;d<=dateDiff[1];d++){
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(tempDate.getHours()+1));
			days += 1;
		}
		for (e=1;e<=dateDiff[2];e++){
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(tempDate.getMinutes()+1));
			days += 1;
		}
		for (f=1;f<=dateDiff[3];f++){
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds()+1));
			days += 1;
		}
/*
		for (a=tempDate.getFullYear();a<=endYear;a++){
			if (a != endYear){
				for (b=tempDate.getMonth();b<12;b++){
					estimatedLessons += getAverageLessons(tempDate,"month");
					tempDate = new Date(tempDate.setMonth(tempDate.getMonth()+1));
					months += 1;
				}// end for
			}// end if (a != endYear)
			else {
				for (b=tempDate.getMonth();b<endMonth;b++){
					if (b != endMonth){
						estimatedLessons += getAverageLessons(tempDate,"month");
						tempDate = new Date(tempDate.setMonth(tempDate.getMonth()+1));
						months += 1;
					}
					else{
						for (c=startDay;c<=endDay;c++) {
							if (c != endDay){
								estimatedLessons += getAverageLessons(tempDate,"day");
								tempDate = new Date(tempDate.setDate(c));
								days += 1;
							}
							else{
								for (d=startHour;d<=endHour;d++) {
									if (d != endHour){
										estimatedLessons += getAverageLessons(tempDate,"hour");
										tempDate = new Date(tempDate.setHours(d));
										hours += 1;
									}
									else{
										for (e=startMinute;e<=endMinute;e++) {
											if (e != endMinute){
												estimatedLessons += getAverageLessons(tempDate,"minute");
												tempDate = new Date(tempDate.setMinutes(e));
												minutes += 1;
											}
											else{
												for (f=startSecond;f<=endSecond;f++) {
													estimatedLessons += getAverageLessons(tempDate,"second");
													tempDate = new Date(tempDate.setSeconds(f));
													seconds += 1;
												}// end for
											}// end else (e == endMinute)
										}// end for
									}// end else (d == endHour)
								}// end for
							}// end else (c == endDay)
						}// end for
					}// end else (b == endMonth)
				}// end for
			}// end else (a == endYear)
		}// end for
*/
	}// end	if ((endYear - startYear) > 0)
	else if ((endMonth - startMonth) > 0){
		for (c=startDay;c<=getDaysPerMonth(startMonth,startYear);c++) {
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(c));
			days += 1;
		}// end for
		for (d=startHour;d<=23;d++) {
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(d));
			hours += 1;
		}// end for
		for (e=startMinute;e<=59;e++) {
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(e));
			minutes += 1;
		}// end for
		for (f=startSecond;f<=59;f++) {
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(f));
			seconds += 1;
		}// end for
		tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds() + 1));

		var dateDiff = getDateDiff(tempDate,endDate);
		
		for (c=1;c<=dateDiff[0];c++){
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(tempDate.getDate()+1));
			days += 1;
		}
		for (d=1;d<=dateDiff[1];d++){
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(tempDate.getHours()+1));
			days += 1;
		}
		for (e=1;e<=dateDiff[2];e++){
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(tempDate.getMinutes()+1));
			days += 1;
		}
		for (f=1;f<=dateDiff[3];f++){
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds()+1));
			days += 1;
		}
/*
		for (b=startMonth;b<=endMonth;b++){
			if (b != endMonth){
				estimatedLessons += getAverageLessons(tempDate,"month");
				tempDate = new Date(tempDate.setMonth(tempDate.getMonth()+1));
				months += 1;
			}// end if (b != endMonth)
			else{
				for (c=startDay;c<=endDay;c++) {
					if (c != endDay){
						estimatedLessons += getAverageLessons(tempDate,"day");
						tempDate = new Date(tempDate.setDate(c));
						days += 1;
					}
					else{
						for (d=startHour;d<=endHour;d++) {
							if (d != endHour){
								estimatedLessons += getAverageLessons(tempDate,"hour");
								tempDate = new Date(tempDate.setHours(d));
								hours += 1;
							}
							else{
								for (e=startMinute;e<=endMinute;e++) {
									if (e != endMinute){
										estimatedLessons += getAverageLessons(tempDate,"minute");
										tempDate = new Date(tempDate.setMinutes(e));
										minutes += 1;
									}
									else{
										for (f=startSecond;f<=endSecond;f++) {
											estimatedLessons += getAverageLessons(tempDate,"second");
											tempDate = new Date(tempDate.setSeconds(f));
											seconds += 1;
										}// end for
									}// end else (e == endMinute)
								}// end for
							}// end else (d == endHour)
						}// end for
					}// end else (c == endDay)
				}// end for
			}// end else (b == endMonth)
		}// end for
*/
	}// end if ((endMonth - startMonth) > 0)
	else if ((endDay - startDay) > 0){
		for (d=startHour;d<=23;d++) {
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(d));
			hours += 1;
		}// end for
		for (e=startMinute;e<=59;e++) {
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(e));
			minutes += 1;
		}// end for
		for (f=startSecond;f<=59;f++) {
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(f));
			seconds += 1;
		}// end for
		tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds() + 1));
		
		var dateDiff = getDateDiff(tempDate,endDate);
		
		for (c=1;c<=dateDiff[0];c++){
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(tempDate.getDate()+1));
			days += 1;
		}
		for (d=1;d<=dateDiff[1];d++){
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(tempDate.getHours()+1));
			days += 1;
		}
		for (e=1;e<=dateDiff[2];e++){
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(tempDate.getMinutes()+1));
			days += 1;
		}
		for (f=1;f<=dateDiff[3];f++){
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds()+1));
			days += 1;
		}
/*		
		for (c=startDay;c<=endDay;c++) {
			if (c != endDay){
				estimatedLessons += getAverageLessons(tempDate,"day");
				tempDate = new Date(tempDate.setDate(c));
				days += 1;
			}
			else{
				for (d=startHour;d<=endHour;d++) {
					if (d != endHour){
						estimatedLessons += getAverageLessons(tempDate,"hour");
						tempDate = new Date(tempDate.setHours(d));
						hours += 1;
					}
					else{
						for (e=startMinute;e<=endMinute;e++) {
							if (e != endMinute){
								estimatedLessons += getAverageLessons(tempDate,"minute");
								tempDate = new Date(tempDate.setMinutes(e));
								minutes += 1;
							}
							else{
								for (f=startSecond;f<=endSecond;f++) {
									estimatedLessons += getAverageLessons(tempDate,"second");
									tempDate = new Date(tempDate.setSeconds(f));
									seconds += 1;
								}// end for
							}// end else (e == endMinute)
						}// end for
					}// end else (d == endHour)
				}// end for
			}// end else (c == endDay)
		}// end for
*/
	}// end else if ((endDay - startDay) > 0)
	else if ((endHour - startHour) > 0){
		for (e=startMinute;e<=59;e++) {
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(e));
			minutes += 1;
		}// end for
		for (f=startSecond;f<=59;f++) {
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(f));
			seconds += 1;
		}// end for
		tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds() + 1));

		var dateDiff = getDateDiff(tempDate,endDate);
		
		for (c=1;c<=dateDiff[0];c++){
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(tempDate.getDate()+1));
			days += 1;
		}
		for (d=1;d<=dateDiff[1];d++){
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(tempDate.getHours()+1));
			days += 1;
		}
		for (e=1;e<=dateDiff[2];e++){
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(tempDate.getMinutes()+1));
			days += 1;
		}
		for (f=1;f<=dateDiff[3];f++){
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds()+1));
			days += 1;
		}
/*
		for (d=startHour;d<=endHour;d++) {
			if (d != endHour){
				estimatedLessons += getAverageLessons(tempDate,"hour");
				tempDate = new Date(tempDate.setHours(d));
				hours += 1;
			}
			else{
				for (e=startMinute;e<=endMinute;e++) {
					if (e != endMinute){
						estimatedLessons += getAverageLessons(tempDate,"minute");
						tempDate = new Date(tempDate.setMinutes(e));
						minutes += 1;
					}
					else{
						for (f=startSecond;f<=endSecond;f++) {
							estimatedLessons += getAverageLessons(tempDate,"second");
							tempDate = new Date(tempDate.setSeconds(f));
							seconds += 1;
						}// end for
					}// end else (e == endMinute)
				}// end for
			}// end else (d == endHour)
		}// end for
*/
	}// end else if ((endHour - startHour) > 0)
	else if ((endMinute - startMinute) > 0){
		for (f=startSecond;f<=59;f++) {
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(f));
			seconds += 1;
		}// end for
		tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds() + 1));

		var dateDiff = getDateDiff(tempDate,endDate);
		
		for (c=1;c<=dateDiff[0];c++){
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(tempDate.getDate()+1));
			days += 1;
		}
		for (d=1;d<=dateDiff[1];d++){
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(tempDate.getHours()+1));
			days += 1;
		}
		for (e=1;e<=dateDiff[2];e++){
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(tempDate.getMinutes()+1));
			days += 1;
		}
		for (f=1;f<=dateDiff[3];f++){
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds()+1));
			days += 1;
		}
/*
		for (e=startMinute;e<=endMinute;e++) {
			if (e != endMinute){
				estimatedLessons += getAverageLessons(tempDate,"minute");
				tempDate = new Date(tempDate.setMinutes(e));
				minutes += 1;
			}
			else{
				for (f=startSecond;f<=endSecond;f++) {
					estimatedLessons += getAverageLessons(tempDate,"second");
					tempDate = new Date(tempDate.setSeconds(f));
					seconds += 1;
				}// end for
			}// end else (e == endMinute)
		}// end for
*/
	}// end else if ((endMinute - startMinute)
	else if ((endSecond - startSecond) > 0){
		var dateDiff = getDateDiff(tempDate,endDate);
		
		for (c=1;c<=dateDiff[0];c++){
			estimatedLessons += getAverageLessons(tempDate,"day");
			tempDate = new Date(tempDate.setDate(tempDate.getDate()+1));
			days += 1;
		}
		for (d=1;d<=dateDiff[1];d++){
			estimatedLessons += getAverageLessons(tempDate,"hour");
			tempDate = new Date(tempDate.setHours(tempDate.getHours()+1));
			days += 1;
		}
		for (e=1;e<=dateDiff[2];e++){
			estimatedLessons += getAverageLessons(tempDate,"minute");
			tempDate = new Date(tempDate.setMinutes(tempDate.getMinutes()+1));
			days += 1;
		}
		for (f=1;f<=dateDiff[3];f++){
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(tempDate.getSeconds()+1));
			days += 1;
		}
/*
		for (f=startSecond;f<=endSecond;f++) {
			estimatedLessons += getAverageLessons(tempDate,"second");
			tempDate = new Date(tempDate.setSeconds(f));
			seconds += 1;
		}// end for
*/
	}// end else if ((endSecond - startSecond)

//alert(tempDate + " - " + endDate);
//alert("months: " + months +"\ndays: " + days + "\nhours: " + hours + "\nminutes: " + minutes + "\nseconds: " + seconds + "\nEstimated Lessons: " + estimatedLessons);
//alert("total lessons added: " + estimatedLessons);

	estimatedLessons = new String(estimatedLessons);
	estimatedLessons = parseInt(estimatedLessons.split(".")[0]);
	
	return estimatedLessons;

}
