
//Declaration of Global Variables
var currentMonthlyRent = new Number(0);
var expectedYearlyRentIncrease = new Number(0);
var federalIncomeTaxBracket = new Number(0);
var termOfLoanInYears = new Number(0);
var loanRate = new Number(0);
var expectToBorrow = new Number(0);
var expectedPropertyPurchasePrice = new Number(0);
var estimatedAnnualAppreciation = new Number(0);
var yearlyPropertyTaxes = new Number(0);
var plannedYearsToOccupy = new Number (0);
var downPayment = new Number(0);
var discountPoints = new Number(0);
var annualMiscOwnershipFees = new Number(0.0);
var annualMiscRentalFees = new Number(0.0);

var g_oData1 = new Object();
var g_oData2 = new Object();
var g_oData3 = new Object();

var g_bInInitialize = false; 
var g_bGraphReady = false;  

var g_strChartLegend = '<div class="rentvsbuylegendcontainer"><div class="rentvsbuylegendentry"><div class="rentvsbuylegendbuy"></div>Cost of Purchase</div><div class="rentvsbuylegendentry"><div class="rentvsbuylegendrent"></div>Costs of Renting</div><div class="rentvsbuylegendentry"><div class="rentvsbuylegendnetbuy"></div>Net Cost of Purchase</div><div class="rentvsbuylegenddivider"><br></div></div>';

//Declare results variables
var estimatedCostsOfRenting, estimatedGrossCostsOfBuying, estimatedTaxRelatedSavings, estimatedIncreasedEquity, estimatedNetCostsOfBuying, estimatedTotalSavings, estimatedInvestmentRelatedSavings = "";

function PopJPLWindow()
{
   //To-Do
   alert("Glossary not yet available.");
}

function getMaxFromObject(xObj)
{

   var max = 0;
   for (var c in xObj) {
      if(!isNaN(parseInt(c))) {
         if (parseInt(xObj[c]) > max) max = parseInt(xObj[c]);
//         if (xObj[c] < 0) alert("****");
         }
      }

   return max;

}

function saveCalculatorToMyC21(pObj){
    if( g_lMyC21Account == null ) {
        if( !processMyC21Account() ){
            //not logged in, display login form
            displayMyC21Login(pObj);
            return false;
        }
    }

    var fm = document.rentvsbuy;
    if( checkForm(fm) ){

       rent          = cleanAndParseInt(fm.rent_buy_monthly_rent.value);
       loanTerm      = fm.rent_buy_loan_term.options[fm.rent_buy_loan_term.selectedIndex].value;
       loanAmount    = cleanAndParseInt(fm.rent_buy_loan_amount.value);
       purchasePrice = cleanAndParseInt(fm.rent_buy_purchase_price.value);
       propertyTaxes = cleanAndParseInt(fm.rent_buy_property_taxes.value);
       yearsInHome   = cleanAndParseInt(fm.rent_buy_years_home.value);
       rentIncrease  = fm.rent_buy_expected_increase.value;
       taxBracket    = fm.rent_buy_tax_bracket.options[fm.rent_buy_tax_bracket.selectedIndex].value;
       loanRate      = fm.rent_buy_interest_rate.value;
       appreciation  = fm.rent_buy_annual_appreciation.options[fm.rent_buy_annual_appreciation.selectedIndex].value;

       var parms = 'calctype=R&rent='+ escape(rent) +'&loanterm='+ escape(loanTerm) +'&loanamount='+ escape(loanAmount);
       parms += '&purchaseprice='+ escape(purchasePrice) +'&propertytaxes='+ escape(propertyTaxes) +'&yearsinhome='+ escape(yearsInHome);
       parms += '&rentincrease='+ escape(rentIncrease) +'&taxbracket='+ escape(taxBracket) +'&loanrate='+ escape(loanRate) +'&appreciation='+ escape(appreciation);

       displayMyC21SaveItemPopup(pObj, 'type=C&'+ parms, 'save_img');
       //dcsMultiTrack('WT.cg_n', 'Engage', 'WT.z_engage_type', 'Engage', 'WT.z_engage_event', 'Save Search');
    }
    return false;
}


function calculate()
{

   //Set variables to current values, overstate Numbers (parseInt or parseFloat) as .value is a string
   currentMonthlyRent = parseInt(cleanInput(document.rentvsbuy.rent_buy_monthly_rent.value));

   termOfLoanInYears = parseInt(document.rentvsbuy.rent_buy_loan_term.options[document.rentvsbuy.rent_buy_loan_term.selectedIndex].value);
   expectToBorrow = parseInt(cleanInput(document.rentvsbuy.rent_buy_loan_amount.value));
   expectedPropertyPurchasePrice = parseInt(cleanInput(document.rentvsbuy.rent_buy_purchase_price.value));
   yearlyPropertyTaxes = parseInt(cleanInput(document.rentvsbuy.rent_buy_property_taxes.value));
   plannedYearsToOccupy = parseInt(cleanInput(document.rentvsbuy.rent_buy_years_home.value));
   downPayment = expectedPropertyPurchasePrice - expectToBorrow;

   //set these next few to decimals
   expectedYearlyRentIncrease = parseFloat((document.rentvsbuy.rent_buy_expected_increase.value)/100);
   federalIncomeTaxBracket = parseFloat((document.rentvsbuy.rent_buy_tax_bracket.options[document.rentvsbuy.rent_buy_tax_bracket.selectedIndex].value)/100);
   loanRate = parseFloat((document.rentvsbuy.rent_buy_interest_rate.value)/100);
   estimatedAnnualAppreciation = parseFloat((document.rentvsbuy.rent_buy_annual_appreciation.options[document.rentvsbuy.rent_buy_annual_appreciation.selectedIndex].value)/100);

   var RBCalc = new RentVsBuyCalculator();

   g_oData1 = new Object();
   g_oData2 = new Object();   
   g_oData3 = new Object();   

//--- Loop through various scenarios
   var c = 1;
   var d = plannedYearsToOccupy;
   var inc = 1;
   if (d > 15) inc = 2;
   for (c = 0; (c <= d); c += inc) {
      RBCalc = RBCalc.calculate(expectedPropertyPurchasePrice, loanRate, expectToBorrow, termOfLoanInYears*12, PMICalculator(expectToBorrow,downPayment), federalIncomeTaxBracket, estimatedAnnualAppreciation, discountPoints, c, currentMonthlyRent, expectedYearlyRentIncrease, yearlyPropertyTaxes, annualMiscOwnershipFees, annualMiscRentalFees);

      estimatedGrossCostsOfBuying = (floor(RBCalc.getGrossCosts()).toString());
      estimatedCostsOfRenting = (floor(RBCalc.getRentingCost()).toString());
      estimatedTaxRelatedSavings = (floor(RBCalc.getTaxSavings()).toString());
      estimatedIncreasedEquity = (floor(RBCalc.getEquityEarned()).toString());
      estimatedNetCostsOfBuying = (floor(estimatedGrossCostsOfBuying - estimatedTaxRelatedSavings - estimatedIncreasedEquity).toString());
      estimatedTotalSavings = (floor(RBCalc.getOwnershipBenefit()).toString());
      estimatedInvestmentRelatedSavings = (floor(RBCalc.getPotentialSavings()).toString());
      closingCosts = (floor(RBCalc.getClosingCosts()).toString());

      g_oData1[c / inc] = estimatedGrossCostsOfBuying;
      g_oData2[c / inc] = estimatedCostsOfRenting;
      g_oData3[c / inc] = estimatedNetCostsOfBuying
      }
      
//--- Done Scenerio Processing
   RBCalc = RBCalc.calculate(expectedPropertyPurchasePrice, loanRate, expectToBorrow, termOfLoanInYears*12, PMICalculator(expectToBorrow,downPayment), federalIncomeTaxBracket, estimatedAnnualAppreciation, discountPoints, plannedYearsToOccupy, currentMonthlyRent, expectedYearlyRentIncrease, yearlyPropertyTaxes, annualMiscOwnershipFees, annualMiscRentalFees);


   estimatedGrossCostsOfBuying = (floor(RBCalc.getGrossCosts()).toString());
   estimatedCostsOfRenting = (floor(RBCalc.getRentingCost()).toString());
   estimatedTaxRelatedSavings = (floor(RBCalc.getTaxSavings()).toString());
   estimatedIncreasedEquity = (floor(RBCalc.getEquityEarned()).toString());
   estimatedNetCostsOfBuying = (floor(estimatedGrossCostsOfBuying - estimatedTaxRelatedSavings - estimatedIncreasedEquity).toString());
   estimatedTotalSavings = (floor(RBCalc.getOwnershipBenefit()).toString());
   estimatedInvestmentRelatedSavings = (floor(RBCalc.getPotentialSavings()).toString());
   closingCosts = (floor(RBCalc.getClosingCosts()).toString());

}

//Browsercheck
var ie = document.all?1:0;
var n = document.layers?1:0;
//This checks for Netscape 6.2 or Greater
var gecko = ((navigator.appName == "Netscape")&&((navigator.appVersion.substring(0,3)==5)||(navigator.appVersion.substring(0,3)>5)))?1:0;

function makeChangeResultsObj(obj)
{
   this.writeref = (n) ? eval('document.'+ obj +'.document') : eval(obj);
   this.writeIt = b_writeIt;
}

function b_writeIt(text)
{
   if (n) {
      this.writeref.write(text);
      this.writeref.close();
   } else if (ie) {
      this.writeref.innerHTML=text;
   }

   //ADDED FOR 6.X COMPLIANCE - NEW CHANGE METHOD
   else if (gecko) {
      this.innerHTML=text;
   }
}

function showResults()
{

   var strEstimatedCostsOfRenting = commasDecimals(estimatedCostsOfRenting);
   var strEstimatedGrossCostsOfBuying = commasDecimals(estimatedGrossCostsOfBuying);
   var strEstimatedTaxRelatedSavings = commasDecimals(estimatedTaxRelatedSavings);
   var strEstimatedIncreasedEquity = commasDecimals(estimatedIncreasedEquity);
   var strEstimatedNetCostsOfBuying = commasDecimals(estimatedNetCostsOfBuying);
   var strEstimatedTotalSavings = commasDecimals(estimatedTotalSavings);
   var strEstimatedInvestmentRelatedSavings = commasDecimals(estimatedInvestmentRelatedSavings);
   var strClosingCosts = commasDecimals(closingCosts);





   //BUILDS RESULTS
   var changeMsg = 
   "<B>Results</B><br>" +
   "Based on the information you provided, the following represents your costs and savings over the next 30 years." +
   "<TABLE CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"0\">" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\">Estimated costs of renting:</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedCostsOfRenting + "</FONT></TD>" +
   "  </TR>" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\">Estimated gross costs of buying: (includes $" + strClosingCosts + " in closing costs)</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedGrossCostsOfBuying + "</FONT></TD>" +
   "  </TR>" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\">Estimated amount of tax related savings:</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedTaxRelatedSavings + "</FONT></TD>" +
   "  </TR>" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\">Estimated amount in increased equity:</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedIncreasedEquity + "</FONT></TD>" +
   "  </TR>" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\">Estimated net costs of buying:</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedNetCostsOfBuying + "</FONT></TD>" +
   "  </TR>" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><B>Estimated total savings:</B> (not including investment related savings)</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedTotalSavings + "</FONT></TD>" +
   "  </TR>" +
   "  <TR VALIGN=\"top\">" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\">Estimated investment related savings:</FONT></TD>" +
   "    <TD COLSPAN=\"1\" VALIGN=\"MIDDLE\"><FONT CLASS=\"basic\"><IMG SRC=\"/images/spacer.gif\" WIDTH=\"10\" HEIGHT=\"2\">" + "$" + strEstimatedInvestmentRelatedSavings + "</FONT></TD>" +
   "  </TR>" +
   "</TABLE>";


   var objResults = document.getElementById('objResults');
   if( objResults != null ) {
      objResults.innerHTML = g_strChartLegend + changeMsg;
   }   

   DrawChart();
}

function checkForm(form)
{
   var errorMsg = "";
   var i;
   var message = new Array();
   var inputs = new Array(form.length);

   var rent, annualincrease, interestrate, loanamount, purchaseprice, propertytax,
   yearsinhome = "";

   for (i = 0; i < form.length; i++) {
      inputs[i] = form.elements[i].name;
   }

   for (i = 0; i < form.length; i++) {
      if (inputs[i] == "rent_buy_monthly_rent")
         rent = i;
      else if (inputs[i] == "rent_buy_expected_increase")
         annualincrease = i;
      else if (inputs[i] == "rent_buy_interest_rate")
         interestrate = i;
      else if (inputs[i] == "rent_buy_loan_term")
         loanterm = i;
      else if (inputs[i] == "rent_buy_loan_amount")
         loanamount = i;
      else if (inputs[i] == "rent_buy_purchase_price")
         purchaseprice = i;
      else if (inputs[i] == "rent_buy_property_taxes")
         propertytax = i;
      else if (inputs[i] == "rent_buy_years_home")
         yearsinhome = i;
   }


   message[0] = "Please enter your monthly rent.\n";
   message[1] = "Your monthly rent should be free of special characters or letters.\n";
   message[2] = "Your monthly rent should be greater than $0 and less than $1,000,000,000.\n";
   message[3] = "Please enter your expected annual rent increase.\n";
   message[4] = "The value for expected annual rent increase should be free of special characters or\n" +
                "letters.\n";
   message[5] = "Your expected annual rent increase should be between 0% and 10%.\n";
   message[6] = "Please enter an interest rate.\n";
   message[7] = "Your interest rate value should be free of special characters or letters.\n";
   message[8] = "Your interest rate value should be greater than 0% and less than 51%.\n";
   message[9] = "Please enter a value for loan amount.\n";
   message[10] = "Your loan amount should be free of special characters or letters.\n";
   message[11] = "Your loan amount should be greater than $20000.\n";
   message[12] = "Please enter a value for purchase price.\n";
   message[13] = "Your purchase price should be free of special characters or letters.\n";
   message[14] = "Your purchase price should be greater than or equal to \n" +
                 "your loan amount and less than $1,000,000,000.\n";
   message[15] = "Your purchase price should be greater than or equal to your loan amount.\n";
   message[16] = "Your proposed property taxes should be free of letters and special characters.\n";
   message[17] = "The value of your proposed property taxes must be a minimum of $0 and\n" +
                 "less than or equal to $1,000,000,000.\n";
   message[18] = "Please enter the number of years you plan to be in your home.\n";
   message[19] = "The number of years you plan to be in this home should be\n" +
                 "free of letters or special characters.\n";
   message[20] = "The number of years you plan to be in this home should be greater\n" +
                 "than 0 and less than or equal to the term of the loan.\n";

   var rentValue           = cleanInput(form.elements[rent].value);
   var annualIncreaseValue = cleanInput(form.elements[annualincrease].value);
   var interestRateValue   = cleanInput(form.elements[interestrate].value);
   var loanAmountValue     = cleanInput(form.elements[loanamount].value);
   var purchasePriceValue  = cleanInput(form.elements[purchaseprice].value);
   var propertyTaxValue    = cleanInput(form.elements[propertytax].value);
   var yearsInHomeValue    = cleanInput(form.elements[yearsinhome].value);
   var loanTermValue       = form.elements[loanterm].options[form.elements[loanterm].selectedIndex].value;

   errorMsg += validateRangedNumberValue(rentValue,           message[0],  message[1],  message[2],  0,     1000000);
   errorMsg += validateRangedNumberValue(annualIncreaseValue, message[3],  message[4],  message[5],  0,     10);
   errorMsg += validateRangedNumberValue(interestRateValue,   message[6],  message[7],  message[8],  1,     50);
   errorMsg += validateRangedNumberValue(loanAmountValue,     message[9],  message[10], message[11], 20000, 1000000000);
   errorMsg += validateRangedNumberValue(purchasePriceValue,  message[12], message[13], message[14], 20000, 1000000000);
   errorMsg += validateEmptyOrRangedNumberValue(propertyTaxValue,    message[16], message[17], 0, 1000000000);
   errorMsg += validateRangedNumberValue(yearsInHomeValue,  message[18], message[19], message[20], 1, loanTermValue);

   var lamount = new Number(loanAmountValue);
   var pprice  = new Number(purchasePriceValue);
   var yrsinhome = new Number(yearsInHomeValue);

   if ((isBlank(loanAmountValue) == 0)&&
       (isNaN(loanAmountValue) == false)&&
       (lamount > 0)&&
       (lamount < 1000000000)&&
       (isBlank(purchasePriceValue) == 0)&&
       (isNaN(purchasePriceValue) == false)&&
       (pprice >= 20000)&&
       (pprice <= 1000000000)&&
       (lamount > pprice))
      errorMsg += message[15];


   //No need to return anything here
   if (errorMsg.length == 0) {
      //If there's no error message, calculate
      clearResults();
      calculate();
      showResults();
      return true;
   } else {
      //If there's an error message, just show it
      alert("Before continuing, the following fields require attention:\n\n" + errorMsg);
   }
   return false;
}

function clearResults()
{
   var objResults = document.getElementById('objResults');
   if( objResults != null ) {
      objResults.innerHTML = "";
   }
   ProxySimpleLineGraph_Clear();
   ProxySimpleLineGraph_ShowImage(true);
}

/////////////////
// 

function SimpleLineGraph_Ready()
{
   ProxySimpleLineGraph_SetImage('/images/calculator/default_rentvsbuy.jpg');
   ProxySimpleLineGraph_ShowImage(true);

   g_bGraphReady = true;
}

function getMultiplier(num)
{
   var len = num.toString().length;
   if (len > 2) {
      return  Math.pow(10, len-2);
      }
   return 10;

}

function getTopNum(num)
{
//   if (num <= 100) num = 1000;
   var mult = getMultiplier(num) * 10;
   var topNum = num / mult;
   var dec = topNum - parseInt(topNum);
   
   if ((dec < 0.5) && (dec > 0)) dec = topNum += 0.5 - dec;
   else topNum = Math.ceil(topNum);

   topNum *= mult;

   return topNum;

}

function getNumDivs(num)
{
   var yTop = getTopNum(num);
   var yMult = getMultiplier(yTop)

   var iTmp = yTop / yMult;
   var yNumDiv = iTmp;
   var iCnt = 0;
   while (iTmp > 9) {
      iTmp = Math.ceil(iTmp / 5);
      iCnt++;
      }

   var yInc = yMult * Math.pow(5, iCnt);
   yNumDiv = iTmp;

   while (yNumDiv < 4) {
      yNumDiv *= 2;
      yInc /= 2;
      }

   yNumDiv++;
   
   return yNumDiv;
}

function getIncrement(num)
{
   var yTop = getTopNum(num);
   var yMult = getMultiplier(yTop)

   var iTmp = yTop / yMult;
   var yNumDiv = iTmp;
   var iCnt = 0;
   while (iTmp > 9) {
      iTmp = Math.ceil(iTmp / 5);
      iCnt++;
      }

   var yInc = yMult * Math.pow(5, iCnt);
   yNumDiv = iTmp;

   while (yNumDiv < 4) {
      yNumDiv *= 2;
      yInc /= 2;
      }

   return yInc;
}

function DrawChart()
{
   ProxySimpleLineGraph_Clear();
   ProxySimpleLineGraph_ShowImage(true);
   
   if ( !g_bGraphReady ) {
      return;
   }
   fm = document.forms.rentvsbuy;

   var yMax = Math.max(getMaxFromObject(g_oData1), getMaxFromObject(g_oData2));
   var yInc = getIncrement(yMax);
   var yNumDiv = getNumDivs(yMax);


//   alert("yMax:" + yMax + "  yInc:" + yInc + "  yNumDiv:" + yNumDiv);

   var xInc = 1
   var xNumDiv = plannedYearsToOccupy;

   if (xNumDiv > 15) {
      xInc *= 2;
      xNumDiv /= 2;
      }

   xNumDiv += 1;

   
   var oVert = new Object();
   oVert['padding'] = 30;
   oVert['offset'] = 10;
   oVert['min'] = 0; //iPaymentMin;
   oVert['increment'] = yInc; // iPaymentIncrement;
   oVert['legend'] = '<font color="#FFFFFF" size="13" face="ARIAL"><b>Monthly Payment</b></font>';
   oVert['label_prefix'] = '$';
   oVert['ticks'] = yNumDiv;
   oVert['grid'] = true;
   oVert['css'] = ".label { font-family: Arial; font-size: 12; font-weight: bold; color: #FFFFFF; text-align: right;}";

   var oHorz = new Object();
   oHorz['padding'] = 10;
   oHorz['offset'] = 0;
   oHorz['min'] = 0; // aLoanPrices[0];
   oHorz['legend'] = '<font color="#000000" size="13" face="ARIAL"><b>Years</b></font>';
   oHorz['label_prefix'] = '';
   oHorz['increment'] = xInc; //fLoanPriceIncrement;
   oHorz['ticks'] = xNumDiv;
   oHorz['grid'] = false;
   oHorz['css'] = ".label { font-family: Arial; font-size: 12; font-weight: bold; color: #000000; text-align: center;}";
   ProxySimpleLineGraph_Setup( oHorz, oVert );

   g_oData1['color'] = 0xFFFB01;
   g_oData1['width'] = 2;
                   
   g_oData2['color'] = 0xFF9600;
   g_oData2['width'] = 2;

   g_oData3['color'] = 0xFFFFFF;
   g_oData3['width'] = 2;


   ProxySimpleLineGraph_Plot( g_oData1 );
   ProxySimpleLineGraph_Plot( g_oData2 );
   ProxySimpleLineGraph_Plot( g_oData3 );

   

/*
   alert( "ValuesFoo: " + 
   "\n   estimatedCostsOfRenting=            " + estimatedCostsOfRenting           +
   "\n   estimatedGrossCostsOfBuying=        " + estimatedGrossCostsOfBuying       +
   "\n   estimatedTaxRelatedSavings=         " + estimatedTaxRelatedSavings        +
   "\n   estimatedIncreasedEquity=           " + estimatedIncreasedEquity          +
   "\n   estimatedNetCostsOfBuying=          " + estimatedNetCostsOfBuying         +
   "\n   estimatedTotalSavings=              " + estimatedTotalSavings             +
   "\n   estimatedInvestmentRelatedSavings=  " + estimatedInvestmentRelatedSavings);
*/

   ProxySimpleLineGraph_ShowImage(false);


   var iPrice = cleanInput(document.rentvsbuy.rent_buy_purchase_price.value);
   var iTop = getTopNum(iPrice);   
   var iMult = getMultiplier(iTop);
   var iMax = iTop + (4 * iMult);
   var iMin = iTop - (4 * iMult);
   setSearchRanges(iMin, iMax);

}

