﻿// JScript File

// ********************** DISPLAY CONTEXT-SENSITIVE HELP *************************

//Create Help window
function jsCreateHelpWindow(title,message,windowFeatures,replace)
{
    //Define window features, based on function parameters
    var features=windowFeatures;
    
    if (features == "")
    {
        //Use default features
        features = "width=600,dependent=yes";
    }
    
    var HelpWindow = window.open("","",features,false);
    
    if ( HelpWindow != null )
    {
    //Set head
    var WinHtml = "<html><head><title>" + title + "</title>";
    WinHtml += "<link href='../Styles/Style1.css' rel='stylesheet' type='text/css' />";
    WinHtml += "</head>";
    
    //Set body
    WinHtml += "<body><table style='font-size: 9pt;'>";
    //Row 1
    WinHtml += "<tr>";
    WinHtml += "<tr><td width='15px'>&nbsp;</td>";              //Add column separator
    WinHtml += "<td></td>";                                     //Add empty column
    WinHtml += "<td width='15px'>&nbsp;</td>";                  //Add column separator
    WinHtml += "<td></td>";                                     //Add empty column
    WinHtml += "<td width='15px'>&nbsp;</td></tr>";             //Add column separator
    
    //Row2
    WinHtml += "<tr><td width='15px'>&nbsp;</td>";              //Add column separator
    WinHtml += "<td><img src='../Images/Diploma.gif' /></td>";  //Add image 
    WinHtml += "<td width='15px'>&nbsp;</td>";                  //Add column separator
    WinHtml += "<td>" + message + "</td>";                      //Add message 
    WinHtml += "<td width='15px'>&nbsp;</td></tr></table>";     //Add column separator
    WinHtml += "<center><form><br /><br />";
    WinHtml += "<input type='button' value='Close' onClick='self.close()'";
    WinHtml += "</form></center></body></html>";
    
    //Write to window
    HelpWindow.document.write(WinHtml);
    HelpWindow.focus();
    return;    
    }
}

//Main goal help
function jsHelpIcon()
{
    //Define help message (M) 
    var M = "";
    M += "Help icons are the little buttons with question marks that ";
    M += "appear in the right-most column of the mortgage calculator.";
    M += "\n\nFor an explanation of the meaning of any calculator input field, ";
    M += "click the help icon to its right.";
    
    //Display help message
    alert(M);
    return;
}

//Main goal help
function jsMainGoalHelp()
{
    //Define help message (M) 
    var M = "";
    M += "Choose the main goal of your analysis from the \"Main Goal\" dropdown ";
    M += "box.";
    M += "\n\nThe calculator configures itself to address the goal that you select.  ";
    M += "It only asks for input that is needed to accomplish your goal, ";
    M += "and it produces a report focused on your goal.";
    
    //Display help message
    alert(M);
    return;
}

//Options help
function jsOptionsHelp()
{
    //Identify current goal and mortgage
    var Goal = document.getElementById("ddlGoal");
    var Comparison = "";
    
    //Define comparison
    if (Goal.selectedIndex==2){
        Comparison = "with and without prepayment. ";
    }
    if (Goal.selectedIndex==3){
        Comparison = "for two loans. ";
    }
    if (Goal.selectedIndex==4){
        Comparison = "with and without refinancing. ";
    }
    
    //Define help message (M) 
    var M = "";
    M += "In addition to a standard analysis (based on the main goal that you ";
    M += "select), the calculator will produce the following optional analyses:";
    
    if (Goal.selectedIndex==0 || Goal.selectedIndex==1 || Goal.selectedIndex==5 ) {
    M += "\n\n\u2022  Amortization table. ";
    M += "The amortization table (aka, amortization schedule) shows ";
    M += "principal, interest, and other costs incurred in each payment period. ";
    M += "It also shows the current loan balance in each payment period. ";
    M += "And it shows the total cost to pay off the mortgage in each payment ";
    M += "period.";    
    }if (Goal.selectedIndex==5 ) {
    M += "\n\n\Note: ";
    M += "When you choose to 'Display Amortization Table' as the main goal ";
    M += "of your analysis, the amortization option is automatically checked ";    
    M += "and cannot be unchecked.";
    }
    
    if ((Goal.selectedIndex==2) || (Goal.selectedIndex==3) || (Goal.selectedIndex==4)) 
    {
    M += "\n\n\u2022  Amortization table. ";
    M += "The table compares financial outcomes ";
    M += Comparison;
    M += "For each payment period, it shows ";
    M += "principal, interest, and ";
    M += "current loan balance.  ";
    M += "And it shows the total cost to pay off the mortgage in each payment ";
    M += "period.";        
    }
    
    M += "\n\n\u2022  Mortgage insurance. ";
    M += "The final report shows monthly mortgage payment with and without ";
    M += "mortgage insurance (aka, private mortgage insurance or PMI). ";
    M += "Computations for total mortgage cost include fees paid for PMI.";

    M += "\n\n\u2022  Hazard insurance. ";
    M += "The final report shows monthly mortgage payment with and without ";
    M += "hazard insurance (aka, homeowner's insurance). ";
    
    M += "\n\n\u2022  Property tax. ";
    M += "The final report shows monthly mortgage payment with and without ";
    M += "property tax.";
    
    M += "\n\n\u2022  Prepayments. ";
    M += "The final report shows the effect of mortgage prepayments on loan ";
    M += "cost and loan duration.";
    
    if ((Goal.selectedIndex==1) || (Goal.selectedIndex==3) ) 
    {
    M += "\n\n\u2022  Tax deductions. ";
    M += "The final report shows total mortgage cost before tax and after tax.  ";
    M += "After-tax results are based on potential deductions for discount ";
    M += "points and interest expense.";    
    }
    
    M += "\n\n\To include an optional analysis as part of the final report, ";
    M += "click the appropriate check box.";
    
    //Display help message
    alert(M);
    return;
}

//Mortgage type help
function jsMortgageTypeHelp()
{
    //Identify current goal and mortgage
    var Goal = document.getElementById("ddlGoal");
    
    //Define help message (M) 
    var M = "";
    M += "Choose the type of mortgage that you want to evaluate from the ";
    M += "\"Mortgage Type\" dropdown box.";
    M += "\n\nYou can choose from 10 different types of mortgage: four kinds of ";
    M += "fixed-rate mortgage and six kinds of adjustable-rate mortgage.  ";
    M += "The calculator configures itself automatically to work with the type of ";
    M += "mortgage that you select.";
    
    if (Goal.selectedIndex==3)  
    {
    M += "\n\n\If you wish, you can choose the same type of mortgage for Loan 1 and ";    
    M += "Loan 2; or you can choose different mortgage types for each loan.";
    }
    
    if (Goal.selectedIndex==4)  
    {
    M += "\n\n\If you wish, you can choose the same type of mortgage for your ";    
    M += "current loan and your new loan; or you can choose different mortgage ";
    M += "types for each loan.";
    }
    
    //Display help message
    alert(M);
    return;
}

//Loan term help
function jsLoanTermHelp()
{
    //Declare variables 
    var Goal = document.getElementById("ddlGoal");
    var Mort = document.form1.ddlMort.selectedIndex;
    var Mort1 = -1;
    var IsBalloon = false;
    var M = "";
    
    //Update Mort1
    if (Goal.selectedIndex==3 || Goal.selectedIndex==4) { Mort1 = document.form1.ddlMort1.selectedIndex; }
    
    //Update IsBalloon
    if ( Mort==2 || Mort==7 ||Mort1==2 || Mort1==7) {
        IsBalloon = true;
    }
     
    //Define help message when neither loan is a balloon loan
    if (!IsBalloon) {
    M += "\"Loan term\" refers to the number of years that it will take ";
    M += "to fully amortize a loan.  Normally, this is equal to the time a ";
    M += "borrower can take to repay the loan.";
    M += "\n\n\For example, a 30-year fixed-rate ";
    M += "mortgage would have a \"loan term\" of 30 years.  And a 15-year ";
    M += "adjustable-rate mortgage would have a \"loan term\" of 15 years.";
    }
    
    //Define help message for a balloon loan
    if ( IsBalloon )  
    {
    M += "\"Loan term\" refers to the number of years that it will take ";
    M += "to fully amortize a loan.";
    M += "\n\n\For example, a 30-year fixed-rate ";
    M += "mortgage would have a \"loan term\" of 30 years.  And a 15-year ";
    M += "adjustable-rate mortgage would have a \"loan term\" of 15 years.";
    M += "\n\n\Some people are confused about the loan term of a ";
    M += "balloon loan, particularly about the difference between ";
    M += "the \"Loan term\" and \"Months before note must be paid\". ";
    M += "An example will make things clear. ";
    M += "Suppose you get a 30-year balloon ";
    M += "note, with the balloon payment due in 5 years.  The \"Loan term\" ";  
    M += "would be 30 years, and the \"Months before note must be paid\" ";
    M += "would be 60 months (i.e., 5 years).";
    }
    
    //Display help message
    alert(M);
    return;
}

//Loan amount help
function jsAmtHelp()
{
    //Declare variables 
    var Goal = document.getElementById("ddlGoal");
    var M = "";
    
     //Define help message for new loan (NOT refinancing)
    if (Goal.selectedIndex!=4)  {
    M += "\"Loan amount\" refers to the total loan amount borrowed for this ";
    M += "mortgage.";
    M += "\n\n\For example, if you borrow $100,000, the \"loan amount\" would ";
    M += "be $100,000.";
    }
    //Define help message for loan refinancing
    if (Goal.selectedIndex==4)  {
    M += "For the current loan, \"unpaid principal\" refers to the amount ";
    M += "on the original mortgage that still remains to be paid";
    M += "\n\n\For the new loan, \"unpaid principal\" refers to the amount ";
    M += "borrowed when the new loan is refinanced.";
    }
    
    //Display help message
    alert(M);
    return;
}

//Loan amount help
function jsStartRateHelp()
{
    //Declare variables 
    var Goal = document.getElementById("ddlGoal");
    var Mort = document.form1.ddlMort.selectedIndex;
    var Mort1 = Mort;
    var M = "";
    
    //Define Loan 2, if necessary
    if (Goal.selectedIndex==3 || Goal.selectedIndex==4)   {
        Mort1 = document.form1.ddlMort1.selectedIndex;
    }
    
     //Define help message for two fixed rate loans
    if ( Mort<4 && Mort1<4 )  
    {
    //Define help message for two fixed rate loans
    M += "\"Interest rate\" refers to the interest rate on this mortgage, ";
    M += "expressed as a percentage.";
    M += "\n\n\For example, if you have a 7 percent interest rate, the ";    
    M += "\"interest rate\" would be 7.";
    }
    else
    {
    //Define help message for 1 or more loans is adjustable
    M += "Starting interest rate\" refers to the initial interest rate of the ";
    M += "mortgage, expressed as a percentage.";
    M += "\n\n\Note: The interest rate for an adjustable-rate mortgage ";    
    M += "changes over the life of the loan.  The \"starting interest rate\" ";
    M += "refers to the rate in effect on Day 1 of the mortgage."
    }
    
    //Display help message
    alert(M);
    return;
}

//Payoff term help
function jsPayoffTermHelp()
{
    //Declare variables 
    var Goal = document.form1.ddlGoal.selectedIndex;
    var Mort = document.form1.ddlMort.selectedIndex;
    var Mort1 = Mort;
    var M = "";
    
    //Define Loan 2, if necessary
    if (Goal==3 || Goal==4)   {
        Mort1 = document.form1.ddlMort1.selectedIndex;
    }
    
    //Define help message for a balloon loans
    if ( (Mort==2) || (Mort1==7) )  
    {
    //Define help message for two fixed rate loans
    M += "\"Months before note must be paid\" refers to the amount of time ";
    M += "a borrower has to pay off a balloon loan."
    M += "\n\n\Some people are confused about the difference between ";
    M += "the \"Loan term\" and \"Months before note must be paid\". ";
    M += "An example will make things clear. ";
    M += "Suppose you get a 30-year balloon ";
    M += "note, with the balloon payment due in 5 years.  The \"Loan term\" ";  
    M += "would be 30 years, and the \"Months before note must be paid\" ";
    M += "would be 60 months (i.e., 5 years).";
    }
    
    //Display help message
    alert(M);
    return;
}

//Months before first rate adjustment help
function jsRateTermHelp()
{
    //Declare variables 
    var Goal = document.form1.ddlGoal.selectedIndex;
    var Mort = document.form1.ddlMort.selectedIndex;
    var Mort1 = Mort;
    var M = "";
    
    //Define Loan 2, if necessary
    if (Goal==3 || Goal==4)   {
        Mort1 = document.form1.ddlMort1.selectedIndex;
    }
    
    //Define general message for most ARMs
    M += "With an adjustable-rate mortgage (ARM), the interest rate is ";
    M += "initially fixed for a period of ";
    M += "time, and then \"adjusted\". "; 
    
    if ( (Mort==6) || (Mort1==6) )
    {
    //Define message for two-step mortgage
    M += "\n\nWith a two-step mortgage, there is only one rate adjustment. ";
    M += "The \"Months before first rate adjustment\" refers to the number of ";
    M += "months before that adjustment occurs.";
    }
    else
    {
    //Define message for ARMs other than two-step mortgage
    M += "\n\nThe \"Months before first rate adjustment\" refers to the number of ";
    M += "months when the rate is initially fixed. With a 10\\1 ARM, for example, the ";
    M += "rate is initially fixed for 10 years.  With a 10\\1 ARM, therefore, ";
    M += "\"Months before first rate adjustment\" would be 120 months ";
    M += "(i.e., 10 years).";
    }
    
    //Display help message
    alert(M);
    return;
}

//Payoff term help
function jsPerCapHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "Most adjustable-rate mortgages have limits on rate changes. ";
    M += "The \"Periodic rate cap\" refers to the maximum change ";
    M += "in interest rate from one adjustment period to the next.";
    M += "\n\n\Common periodic rate caps are in the range of 2 percent. ";
    M += "Periodic rate caps protect borrowers from ";
    M += "big jumps in monthly payment; and lenders, from big drops.";
    
    //Display help message
    alert(M);
    return;
}

//Payoff term help
function jsLifeCapHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "Most adjustable-rate mortgages have limits on the maximum interest ";
    M += "rate.  The \"Maximum lifetime interest rate\" refers to the maximum ";
    M += "interest rate that can be charged over the life of the loan."
    
    //Display help message
    alert(M);
    return;
}

//Payoff term help
function jsNumOfAdjustmentPeriodsHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "With a graduated payment loan, the interest rate rises periodically ";
    M += "for a specified number of years, and then remains fixed.";
    M += "\n\n\"Number of rate adjustments\" refers to the number of times that ";
    M += "the rate is adjusted during the life of the loan. Suppose, for example, ";
    M += "that a graduated payment loan called for rate adjustments every ";
    M += "6 months for the first 3 years.  There would be 6 rate adjustments ";
    M += "(2 per year) over the ";
    M += "life of the loan; so \"Number of rate adjustments\" would be 6.";
    
    //Display help message
    alert(M);
    return;
}

//Months between rate adjustments help
function jsAdjustMosHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "With an adjustable-rate mortgage (ARM), the interest rate changes ";
    M += "periodically.";  
    M += "\n\n\"Months between rate adjustments\" refers to the adjustment ";
    M += "interval, expressed in months. Suppose, for example, ";
    M += "that the interest rate for a mortgage changed every 6 months. ";
    M += "Then, \"Months between rate adjustments\" would be 6.";
    
    //Display help message
    alert(M);
    return;
}

//Ending interest rate help
function jsEndRateHelp()
{
    //Declare variables
    var Goal = document.form1.ddlGoal.selectedIndex;
    var Mort = document.form1.ddlMort.selectedIndex;
    var Mort1 = Mort;
    var M = "";
    
    //Define help message for convertible ARM
    if ( Mort==5 )
    {
    M += "With a convertible ARM, the initial adjustable interest rate ";
    M += "can be converted to a fixed-rate mortgage. ";
    M += "The \"Ending interest rate\" is the interest rate in effect ";
    M += "after the borrower converts to a fixed-rate loan.";
    }
    
    //Define help message for graduated payment mortgage
    if ( Mort==6 )
    {
    M += "\n\nWith a two-step mortgage, the loan starts out as a fixed-rate mortgage ";
    M += "for a period of time. After that period, the loan is adjusted to a ";
    M += "new interest rate. ";
    M += "The \"Ending interest rate\" is the interest rate in effect ";
    M += "after the loan is adjusted.";
    }
    
    //Define help message for graduated payment mortgage
    if ( Mort==9 )
    {
    M += "\n\nWith a graduated payment mortgage, the interest rate increases ";
    M += "over a period of time, and then levels off. ";
    M += "The \"Ending interest rate\" is the interest rate in effect ";
    M += "after the rate levels off.";
    }
    
    //Define Loan 2, if necessary
    if (Goal==3 || Goal==4)   {
        Mort1 = document.form1.ddlMort1.selectedIndex;
        
        //Define help message for convertible ARM
        if ( Mort1==5 )
        {
        M += "\n\nWith a convertible ARM, the adjustable-rate mortgage can be ";
        M += "converted to a fixed-rate mortgage. ";
        M += "The \"Ending interest rate\" is the interest rate in effect ";
        M += "if the borrower chooses to convert to a fixed-rate loan.";
        }
        
        //Define help message for graduated payment mortgage
        if ( Mort1==6 )
        {
        M += "\n\nWith a two-step mortgage, the loan starts out as a fixed-rate mortgage ";
        M += "for a period of time. After that period, the loan is adjusted to the ";
        M += "current interest rate. ";
        M += "The \"Ending interest rate\" is the interest rate in effect ";
        M += "when the loan is adjusted.";
        }
        
        //Define help message for graduated payment mortgage
        if ( Mort1==9 )
        {
        M += "\n\nWith a graduated payment mortgage, the interest rate increases ";
        M += "over a period of time, and then levels off. ";
        M += "The \"Ending interest rate\" is the interest rate in effect ";
        M += "when the rate levels off.";
        }
    }    
    
    //Display help message
    alert(M);
    return;
}

//Cost to convert help
function jsCostToConvertHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "A convertible mortgage is an adjustable rate mortgage (ARM) that may be ";
    M += "converted to a fixed-rate mortgage.  ";  
    M += "Often, lenders impose a fee when borrowers exercise their option to ";
    M += "convert.  This fee is called the \"Cost to convert\".";
    
    //Display help message
    alert(M);
    return;
}

//Months before fixed rate begins help
function jsConvertMosHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "A convertible mortgage is an adjustable rate mortgage (ARM) that may be ";
    M += "converted to a fixed-rate mortgage.";  
    M += "\n\nThe \"Months before fixed rate begins\" refers to the time period, ";
    M += "during which the adjustable rate is in effect.  ";
    M += "For example, suppose a borrower converts to a fixed-rate mortgage, ";
    M += "beginning in the 25th month.  ";
    M += "The entry for \"Months before fixed rate begins\" would be 24, because ";
    M += "the interest rate was adjustable for the first 24 months.";
    
    //Display help message
    alert(M);
    return;
}

//Down payment help
function jsDownHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "The \"Down payment\" is the difference between the ";
    M += "sale price of the home and the loan amount.  ";
    M += "The down payment is usually paid at closing by the home ";
    M += "buyer. ";
    
    //Display help message
    alert(M);
    return;
}

//Points help
function jsPointsHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "\"Points\" represent a fee paid to the lender to get ";
    M += "a mortgage at a specified interest rate.  ";
    M += "\n\nPoints are expressed as percentages, with one point equal to ";
    M += "one percent of the loan amount.  ";
    M += "For example, suppose you got a $200,000 loan with 2 points.  ";
    M += "The number of points is 2, and the fee for points is $200,000 x 0.02 ";
    M += "or $4,000.  ";
    M += "\n\nNote: To describe points using this calculator, enter a ";
    M += "percentage, not a dollar amount.  For the above example, you would ";
    M += "enter \"2\" for points, not \"$4,000\".  (The calculator will ";
    M += "compute the dollar figure for you.)";
    
    //Display help message
    alert(M);
    return;
}

//Other costs help
function jsOtherCostsHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "\"Other costs\" refer to any other upfront mortgage costs, other ";
    M += "than down payment and points.";
    M += "\n\nFor example, other costs could include settlement fees ";
    M += "(legal expenses, termite inspection, title insurance, ";
    M += "document fees, etc.).";
    
    //Display help message
    alert(M);
    return;
}

//Number of prepayments help
function jsNumPrepayHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "Along with your regular mortgage payment, you can make a prepayment - an ";
    M += "extra payment which reduces the loan principal.  Use the dropdown box to ";
    M += "indicate the number of prepayments that you will make in a year.";
    
    //Display help message
    alert(M);
    return;
}

//Prepayment amount help
function jsPrepayAmtHelp()
{
    //Declare variables 
    var M = "";
    
    //Define help message 
    M += "Indicate the size of each individual prepayment.  If you plan to make ";
    M += "prepayments of different sizes during the year, enter the dollar ";
    M += "amount of an average prepayment.";
    M += "\n\nFor example, suppose you make three prepayments during the year - ";
    M += "$100, $200, and $300. ";
    M += "The average size of a prepayment is $200, so you would enter ";
    M += "$200 as the \"Amount per prepayment\".";
    
    //Display help message
    alert(M);
    return;
}

//Private property tax help
function jsTaxHelp()
{
    //Declare variables 
    var M = "";
     
    //Define help message 
    M += "For \"Annual property tax\", enter the dollar amount that you ";
    M += "would spend each year for property tax.";
    M += "\n\nMany lenders expect borrowers to make a prorated contribution toward ";
    M += "property tax, along with their monthly mortgage payment. ";
    M += "As part of its summary report, the calculator shows the effect of ";
    M += "property tax on the monthly mortgage payment.";
    
    //Display help message
    alert(M);
    return;
}

//Private hazard insurance help
function jsHazardHelp()
{
    //Declare variables 
    var M = "";
     
    //Define help message 
    M += "For \"Annual hazard insurance\", enter the dollar amount that you ";
    M += "would spend each year for hazard insurance (aka, homeowner's ";
    M += "insurance).";
    M += "\n\nMany lenders expect borrowers to make a prorated contribution toward ";
    M += "hazard insurance, along with their monthly mortgage payment. ";
    M += "As part of its summary report, the calculator shows the effect of ";
    M += "hazard insurance on the monthly mortgage payment.";
    
    //Display help message
    alert(M);
    return;
}

//Private mortgage insurance help
function jsPMIHelp()
{
    //Declare variables 
    var M = "";
     
    //Define help message 
    M += "For \"Annual mortgage insurance\", enter the dollar amount that you ";
    M += "would pay each year for private mortgage insurance (PMI).";
    M += "\n\nThe actual charge for PMI varies from location to location and ";
    M += "from lender to lender.  Nationwide, the average annual charge is about ";
    M += "$660 per $100,000 borrowed.";
    M += "\n\nMany lenders require borrowers to pay for PMI until their loan balance ";
    M += "falls below 80% of the fair market value of the home.  The calculator ";
    M += "updates the loan balance with each mortgage payment, and only includes a ";
    M += "PMI charge while the loan balance exceeds 80% of the home value.";
    
    //Display help message
    alert(M);
    return;
}

//Fair market value help
function jsFMVHelp()
{
    //Declare variables 
    var M = "";
     
    //Define help message 
    M += "For \"Appraised value of the home\", enter the dollar amount that ";
    M += "represents the fair market value of the home.";
    M += "\n\nIn the absence of a formal appraisal, the sale price of the ";
    M += "home is a good estimate of its fair market value.";
    
    //Display help message
    alert(M);
    return;
}

//Fair market value help
function jsIncomeTaxRateHelp()
{
    //Declare variables 
    var M = "";
     
    //Define help message 
    M += "For \"Income tax rate\", enter your marginal tax rate for the current ";
    M += "year.";
    M += "\n\nYour marginal tax rate is the tax rate that will be applied to ";
    M += "your next dollar of income.";
    
    //Display help message
    alert(M);
    return;
}

