
function calc1(form) 
{
        var fullName = document.form1.fullName.value ;
	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;
        var address = document.form1.address.value.toUpperCase() ;
	//netscape fix for drop down menu
		//month
		var moDropDown= document[form].mm.selectedIndex;
		var moDropValue= document[form].mm.options[moDropDown].value;
		var mo = eval(moDropValue)
		//day
		var dyDropDown= document[form].dd.selectedIndex;
		var dyDropValue= document[form].dd.options[dyDropDown].value;
		var dy = eval(dyDropValue)
		//yr
		var yrDropDown= document[form].yy.selectedIndex;
		var yrDropValue= document[form].yy.options[yrDropDown].value;		
		var yr = eval(yrDropValue)
	//end fix
	
	actualDate = new Date(yr,mo,dy) 
	days1 = new Date(yr,mo,dy + 44)
	days2 = new Date(yr,mo,dy + 179)
        var days45 ="";
        var days180="";
	var month1 = days1.getMonth();
	var day1 = days1.getDate();
	var year1 = days1.getYear();
	//NS year display workaround
		if (year1<2000)
		{
			year1 = parseInt("20" + String(year1).substring(1,3))
		}
	//end workaround	

	var month2 = days2.getMonth();
	var day2 = days2.getDate();
	var year2 = days2.getYear();
	
	//NS year display workaround
		if (year2<2000)
		{
			year2 = parseInt("20" + String(year2).substring(1,3))
		}
	//end workaround	

	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();

	//BEGIN 45 DAY EXCEPTION
	
		//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++
			}
		}
		
		//february workaround for 28 days and leap year exception
		if (months[month1]=="February")
		{
			var allowedDays = 28
			//leap year workaround
			if (eval(year1 % 4)==0)
			{
				allowedDays = 29
			}
			
			//day overage workaround
			if (days[day1]>allowedDays)
			{
				var remainder = days[day1] - allowedDays;
				month1++
				day1 = remainder - 1;		
			}
		}
		days45 = (months[month1] + ", " + days[day1] + ", " + year1);
		
	//END 45 DAY EXCEPTION
	
	
	//BEGIN 180 DAY EXCEPTION
	
		//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++
			}
		}
		
		//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;
	

Calc = window.open("day.html","new_window")

Calc.document.write("<html><head><title>Computation For 180 and 45 Days Calculator</title></head><body><center><b>45 Day and 180 Day Calculator</b><br>"); 
Calc.document.write("<b>Equity 1031, LLC -- (408) 916-5829 or (866) 679-1031</b><br>");
Calc.document.write("<b>Exchanger(s) " + fullName.toUpperCase() + "</b><br>");
Calc.document.write("<b>Property address " + address + "</b><hr>");
Calc.document.write("<p><b>Initial sale date " + month3 +", "+ day3 + ", " + year3 + "</b><p>");
Calc.document.write("<p><b>*** 45 Days Indentification Period Ends On:  " +days45+"<p>");
Calc.document.write(" *** 180 Days Completion Period Ends On: " +days180+"<p><b></center>");
Calc.document.write("I/We hereby acknowledge that this calculation is offered as a courtesy<b>");
Calc.document.write(" of Equity 1031, LLC.   I/We hereby acknowledge that we take full<b>");
Calc.document.write(" responsibility to verify and confirm that the above dates are correct.  <b>");
Calc.document.write("  I/We hereby acknowledge that we have received a copy of this form<b>");
Calc.document.write(" and understand the implication of these dates with respect to our exchange.<p><b>");
Calc.document.write("<p>Exchanger_________________________________ Date_____________<p>");
Calc.document.write("<p>Exchanger_________________________________ Date_____________<p>");
Calc.document.write("<p>Exchanger_________________________________ Date_____________<p>");
Calc.document.write('</body></html>');

	//END 180 DAY EXCEPTION
}
