
function calc1(form) 
{
      
	var SECOND = 1000; // the number of milliseconds in a second
	var MINUTE = SECOND * 60; // the number of milliseconds in a minute
	var HOUR = MINUTE * 60; // the number of milliseconds in an hour
	var DAY = HOUR * 24; // the number of milliseconds in a day
	var WEEK = DAY * 7; // the number of milliseconds in a week
	var actualDate; // the date the property was actually sold
        
	
		var moDropDown= document[form].mm.selectedIndex;
		var moDropValue= document[form].mm.options[moDropDown].value;
		var mo = eval(moDropValue)
		
		var dyDropDown= document[form].dd.selectedIndex;
		var dyDropValue= document[form].dd.options[dyDropDown].value;
		var dy = eval(dyDropValue)
		
		var yrDropDown= document[form].yy.selectedIndex;
		var yrDropValue= document[form].yy.options[yrDropDown].value;		
		var yr = eval(yrDropValue)
	
	
	actualDate = new Date(yr,mo,dy) 
        // starting with day of sale being day 1 + 44 & 179 = 45 & 180
	days1 = new Date(yr,mo,dy + 44) // jump ahead 44 days
	days2 = new Date(yr,mo,dy + 179) // jump ahead 179 days
        var days45 ="";
        var days180="";
	var month1 = days1.getMonth();
	var day1 = days1.getDate();
	var year1 = days1.getYear();
	
		if (year1<2000)
		{
			year1 = parseInt("20" + String(year1).substring(1,3))
		}
	

	var month2 = days2.getMonth();
	var day2 = days2.getDate();
	var year2 = days2.getYear();
	
	
		if (year2<2000)
		{
			year2 = parseInt("20" + String(year2).substring(1,3))
		}
	// note days start at 0

	var days = new Array();
	days[0] = "01";
	days[1] = "02";
	days[2] = "03";
	days[3] = "04";
	days[4] = "05";
	days[5] = "06";
	days[6] = "07";
	days[7] = "08";
	days[8] = "09";
	days[9] = "10";
	days[10] = "11";
	days[11] = "12";
	days[12] = "13";
	days[13] = "14";
	days[14] = "15";
	days[15] = "16";
	days[16] = "17";
	days[17] = "18";
	days[18] = "19";
	days[19] = "20";
	days[20] = "21";
	days[21] = "22";
	days[22] = "23";
	days[23] = "24";
	days[24] = "25";
	days[25] = "26";
	days[26] = "27";
	days[27] = "28";
	days[28] = "29";
	days[29] = "30";
	days[30] = "31";


	var months = new Array();
	months[0] = "January";
	months[1] = "February";
	months[2] = "March";
	months[3] = "April";
	months[4] = "May";
	months[5] = "June";
	months[6] = "July";
	months[7] = "August";
	months[8] = "September";
	months[9] = "October";
	months[10] = "November";
	months[11] = "December";
	
	var month3 = months[actualDate.getMonth()];
	var day3 = actualDate.getDate();
	var year3 = actualDate.getYear();

	
	
		//workaround for months which are 30 days - april, june, september, november
		if (months[month1]=="April"||months[month1]=="June"||months[month1]=="September"||months[month1]=="November")
		{
			if (days[day1]==31)
			{
				month1++
				day1 = 0
			}
		}
		
		//Year crossover
		if (months[month1]=="December")
		{
			if (day1==31)
			{
				day1 = 0
				month1 = 0
				year1++
			}
		}
		if (day1==31)
		{
			day1 = 0
			month1++
		}
		//check for leap year exception
		if (months[month1]=="February")
		{
			var allowedDays = 28
			//leap year workaround
			if (eval(year1 % 4)==0)
			{
				allowedDays = 29
			}
			
			//day overage allowedDays workaround
			if (days[day1]>allowedDays)
			{
				var remainder = days[day1] - allowedDays;
				month1++
				day1 = remainder - 1;		
			}
		}
		days45 = (months[month1] + ", " + days[day1] + ", " + year1);
		
	
	
		//workaround for months which are 30 days - april, june, september, november
		if (months[month2]=="April"||months[month2]=="June"||months[month2]=="September"||months[month2]=="November")
		{
			if (days[day2]==31)
			{
				month2++
				day2 = 0
				
			}
		}
		
		//Year crossover
		if (months[month2]=="December")
		{
			if (day2==31)
			{
				day2 = 0
				month2 = 0
				year2++
			}
		}
		if (day2==31)
		{
			day2 = 0
			month2++
		}
		//february workaround for 28 days and leap year exception
		if (months[month2]=="February")
		{
			var allowedDays = 28
			//leap year workaround

			if (eval(year2 % 4)==0)
			{
				allowedDays = 29
			}
			
			//day overage workaround
			if (days[day2]>allowedDays)
			{
				var remainder = days[day2] - allowedDays;
				month2++
				day2 = remainder - 1;
			}
		}
		 days180 = months[month2] + ", " + days[day2] + ", " + year2;

calcDate.innerHTML = "<p class='contenttxt'><b>Initial sale date<br></b> " + month3 +", "+ day3 + ", " + year3 + "<br><br><b>45 day indentification period ends </b><br>" +days45+"<br><br><b> 180 day purchase date ends </b><br>" +days180+"<br><br></p>";

	//END 180 DAY EXCEPTION
}


