<!--
	/* THIS SPAGHETTI WAS SERVED UP WITH SORBET ON OCTOBER 21, 2006 */
	/* BY MONIQUE O'REILLY */


function writeSomething()  
{

     /* BELOW INITIALIZING VARIABLES */
var insBirthYear = null;
var insBirthDay = null;
var insBirthMonth = null;
var insAmount = null;
var insBirthYear = null;
var insBirthDay = null;
var insBirthMonth = null;
var insAmount = null;
var currentAge = null;
programA = 12.00;
programB = 25.00;
programC = 35.00;
programD = 45.00;
var insPay = 0;

     /* BELOW PULLS THE INPUT FROM FORM AND ASSIGNING NAMES TO THEM */
insBirthYear = document.form1.birthYear.value;
insBirthDay = document.form1.birthDay.value;
insBirthMonth = document.form1.birthMonth.value;
insAmount = document.form1.insuranceAmount.value;

     /* BELOW SEPARATES THE SYSTEM DATE INTO DAY, MONTH, AND YEAR */
theCurrentDate = new Date();
systemDay = theCurrentDate.getDate();
systemMonth = theCurrentDate.getMonth() +1;
systemYear = theCurrentDate.getFullYear();
selectedDate = (insBirthMonth+"\/"+insBirthDay+"\/"+insBirthYear); 
systemDate = (systemMonth+"\/"+systemDay+"\/"+systemYear);


function isEmpty(systemYear) {
var empty = (systemYear == null || systemYear == "") ? true: false
return empty}


    /* BELOW TESTS TO SEE IF ALL FIELDS HAVE BEEN SELECTED */
if 
(document.form1.birthDay.value == " " || document.form1.birthMonth.value == " " || 
document.form1.birthYear.value  == " " || document.form1.insuranceAmount.value  == " ")
	{ alert("You did not select all of the fields.  Please try again.");
	form1.birthYear.focus();		
	return false;	}

    /* IF ALL FIELDS HAVE BEEN COMPLETED BY USER, CONTINUE. */

else

{


    /* BELOW TESTS FOR BIRTHDAY. */
if ((systemDay == insBirthDay) && (systemMonth == insBirthMonth)) 
{alert("Happy Birthday!") }

    /* ONCE BIRTHDAY GREETING HAS BEEN ADDRESSED, CALC THE DIFFERENCE BETWEEN BIRTHDATE AND THE SYSTEM DATE TO DETERMINE THE AGE. */
IDate = Date.UTC(insBirthYear,insBirthMonth,insBirthDay,0, 0,0);
SDate = Date.UTC(systemYear,systemMonth,systemDay,0,0,0);
age=IDate-SDate;
age = ( (age / (24 * 60 * 60 * 1000)/365.25 ) );
currentAge = Math.abs(age);
currentAge = Math.floor(currentAge*100)/100;



    /* IF THE AGE IS OUT OF RANGE FOR A QUOTE RETURN A NOTICE TO THE USER. */
if ((currentAge<2) || (currentAge>=90.99))
{alert("Your age is "+Math.floor(currentAge)+" and is not within the age range of 2-90yrs.  We\'re sorry, but you are not eligible for our insurance."); return false;}

    /* IF THE AGE IS WITHIN RANGE, CONFIRM THE AGE AND WRITE TOP PORTION OF QUOTE. */

    { 

document.write("<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">");
document.write("<html xmlns=\"http:\/\/www.w3.org/1999/xhtml\">");
document.write("<head><meta http-equiv=\"Content-Type\" content=\"text\/html\; charset=iso-8859-1\" />");
document.write("<title>Life Insurance Quoter<\/title>");
document.write("<link href=\"\/assets\/style.css\" rel=\"stylesheet\" type=\"text\/css\" />");
document.write("<script type=\"text\/javascript\" src=\"scripts\/greatday.js\"></\script><\/head>");
document.write("<body style=\"color: #1D3E22\; padding: 5%\; background-color: #ffffcd\; height: auto\;\">");
document.write("<p><a href='lab06.shtml'>return to Quote Form<\/a></p>");
document.writeln("<h1>Here is your Quote!</h1>");
document.writeln("<strong>Today\'s date "+systemDate+"</strong><br /><br />");
document.writeln("<strong>Your birth date "+selectedDate+"</strong><br /><br />");
document.writeln("<strong>You selected $"+insAmount+" worth of life insurance. </strong><br /><br /><br /><hr style='margin-left: -5px;'/><br />"); 


    /* IF THE AGE IS 2 THROUGH 18 CALCULATE PROGRAM A INSURANCE. */

if ((currentAge>=2) && (currentAge<=18)) {
insPay = ((programA * insAmount)/10000);
document.writeln("<strong>Your current age is "+Math.floor(currentAge)+". You are eligible for Program A.</strong><br /><br />"); document.writeln("<p style='font-family: italic'>Your monthly payments will be only $"+insPay+".00\/month!</p>"); insPay=0;  }

    /* IF THE AGE IS BETWEEN 18 AND 40 CALCULATE PROGRAM B INSURANCE. */

else if ((currentAge>18) && (currentAge<=40)) {
insPay = ((programB * insAmount)/10000);
document.writeln("<strong>Your current age is "+Math.floor(currentAge)+". You are eligible for Program B.</strong><br /><br />"); document.writeln("<p style='font-family: italic'>Your monthly payments will be only $"+insPay+".00\/month!</p>"); insPay=0;  }

    /* IF THE AGE IS BETWEEN 40 AND 62 CALCULATE PROGRAM C INSURANCE. */

else if ((currentAge>40) && (currentAge<=62)) {
insPay = ((programC * insAmount)/10000);
document.writeln("<strong>Your current age is "+Math.floor(currentAge)+". You are eligible for Program C.</strong><br /><br />"); document.writeln("<p style='font-family: italic'>Your monthly payments will be only $"+insPay+".00\/month!</p>"); insPay=0;  }


   /* IF THE AGE IS BETWEEN 62 THROUGH 90 CALCULATE PROGRAM D INSURANCE. */

else if ((currentAge>62) && (currentAge<=90.99)) {
insPay = ((programD * insAmount)/10000);
document.writeln("<strong>Your current age is "+Math.floor(currentAge)+". You are eligible for Program D.</strong><br /><br />"); document.writeln("<p style='font-family: italic'>Your monthly payments will be only $"+insPay+".00\/month!</p>"); insPay=0;  }


else

   /* CODE NOT WORKING ALERT. THIS COMES UP IF I'VE SCREWED UP CODING AND UNAWARE OF IT. */

{

alert("IF YOU ARE READING THIS, SOMETHING IS OUTTA WACK.");  }


}

}

	
}

//-->

