// --// Define the report object. This object enables us to package the // entire result of the RSP calculation as one for easy manipulation.////  @author  Ayinde Yakubu//  @version $Revision: 1.3.30.1 $////  Copyright (c) 2003, Unisen Inc. Canada
//


var result;

//function beginHTMLBody()
//{
//  document.write("<BODY BGCOLOR='#ffffff' MARGINWIDTH='0' MARGINHEIGHT='0' LEFTMARGIN='0' TOPMARGIN='0'>");
//  document.write("<TABLE WIDTH='759' CELLPADDING='0' CELLSPACING='0' BORDER='0' ALIGN='center'>");
//  document.write("<TR>");
//  document.write("</TR>");
//  document.write("<TR>");
  //document.write("<TD><DIV CLASS='navlocation'><A CLASS='underline' HREF='#'>Home</A> : <A CLASS='underline' HREF='index.html'>Investor Tools</A> : Calculators : RIF Illustrator</DIV></TD>");
//  document.write("</TR>");
//  document.write("<TR>");
//  document.write("<TD WIDTH='759'><IMG SRC='image/dot.gif' WIDTH='3' HEIGHT='1' ALT='' BORDER='0'>");
//  document.write("<TABLE CELLSPACING='0' CELLPADDING='0' BORDER='0'>");
//}

//function endHTMLBody()
//{
//  document.write("</TD>");
//  document.write("</TR>");
//  document.write("</TABLE>");
//  document.write("</TD>");
//  document.write("</TR>");
//  document.write("<TR>");
//  document.write("<TD WIDTH='780' colspan='3'>");
//  document.write("<TABLE WIDTH='600' CELLSPACING='0' CELLPADDING='0' BORDER='0' ALIGN='center'>");
//  document.write("<TR>");
//  document.write("<TD COLSPAN='13'><IMG SRC='image/dot.gif' WIDTH='1' HEIGHT='40' ALT='' BORDER='0'></TD>");
//  document.write("</TR>");
//  document.write("<TR>");
//  document.write("</TR>");
//  document.write("<TR>");
//  document.write("<TD COLSPAN='13'><IMG SRC='image/dot.gif' WIDTH='1' HEIGHT='10' ALT='' BORDER='0'></TD>");
//  document.write("</TR>");
//  document.write("</TABLE>");
//  document.write("</TD>");
//  document.write("</TR>");
//  document.write("</TABLE>");
 // document.write("</BODY>");
//}

// ---
// Run the RIF summary extraction and display code
// ---
function runRIFSummary(str)
{ 
    var params = extractParams(str);
   
	var txtDeductWithTax = params[0];
	//alert(txtDeductWithTax);
	
	var txtQuebecResident = params[1];
	//alert(txtQuebecResident);

	var txtNewFunds1992 = params[2]
	//alert(txtNewFunds1992);

	var txtCurrentPlanValue = params[3]
	var txtPaymentType = params[4]
	var txtAnnualROR   = params[5]
	var txtBirthDate  = params[6]
	var txtIssueDate  = params[7]
	var txtToAge      = params[8]
	var txtWithPercentage = params[9]
	var txtGrossInc   = params[10]
	var txtWithholdTax   = params[11]
	var txtNetIncome     = params[12]
	var txtLastAge       = params[13]
	var txtLastRIF       = params[14]

	//beginHtml("RIF Illustrator");
	//beginHTMLBody();
	//show("<strong>Result Summary</strong><br><br>");
	//show("This is a summary of the data you entered into AGF's RIF Illustrator.");
	//beginBody();
	beginTable(" ");
	
	beginRow();
	//Display assumptions
	beginRowDataLeft();
	show("<strong>Key Assumptions</strong><br><br>");
	endRowData();
	
	beginRowData();
	show("");
	endRowData();
	endRow();
	
	beginRow();
	document.write("<td align='left' bgcolor='#ffffff' width='30%'>");
	show("Deduct Withholding Tax:");
	endRowData();
	
	beginRowResultData();
	show(txtDeductWithTax);
	show("<br>");
	endRowData();
	endRow();
	
	beginRow();
	beginRowDataLeft();
	show("Quebec Resident: ");
	endRowData();
	
	beginRowResultData();
	show(txtQuebecResident);
	show("<br>");
	endRowData();
	endRow();

    beginRow();
    beginRowDataLeft();
	show("New Funds After 1992: ");
	endRowData();
	
	beginRowResultData();
	show(txtNewFunds1992);
	endRowData();
	endRow();
	
	beginRow();
    beginRowDataLeft();
	show("  ");
	endRowData();
	
	beginRowResultData();
	show(" ");
	endRowData();
	endRow();
	
    beginRow();
    beginRowDataLeft();
	show("<b>Plan Details:</b> ");
	endRowData();
	
	beginRowResultData();
	show(" ");
	endRowData();
	endRow();
	
	//show("<br>");
    beginRow();
    beginRowDataLeft();
	show("Current Plan Value: ");
	endRowData();
	
	beginRowResultData();
	var planval = convertToMoney(txtCurrentPlanValue, 2);
	show(planval);
	endRowData();
	endRow();
	
	show("<br>");
 
    beginRow();
    beginRowDataLeft();
	show("Payment Type: ");
	endRowData();
	
	beginRowResultData();
	show(txtPaymentType);
	endRowData();
	endRow();
	
	show("<br>");

    beginRow();
    beginRowDataLeft();
	show("Annual Rate of Return: ");
	endRowData();

	beginRowResultData();
	var ror = toPercent(txtAnnualROR);
	show(ror);
	endRowData();
	endRow();

    beginRow();
    beginRowDataLeft();
	show("Birth Date: ");
	endRowData();
	
	beginRowResultData();
	show(formatDate(txtBirthDate));
	endRowData();
	endRow();

    beginRow();
    beginRowDataLeft();
	show("Issue Date: ");
	endRowData();
    beginRowResultData();
	show(formatDate(txtIssueDate));
	endRowData();
	endRow();
	
	beginRow();
	beginRowDataLeft();
	show("To Age: ");
	endRowData();
	
	beginRowResultData();
	show(txtToAge);
	endRowData();
	endRow();
	
	
	beginRow();
	beginRowDataLeft();
	show("Withdrawal Percentage: ");
	endRowData();
	
	beginRowResultData();
	var withP = toPercent(txtWithPercentage);
	show(withP);
	endRowData();
	endRow();
	
	
	beginRow();
	beginRowResultData();

	//beginRowData();

	show("<tr><td colspan='2'>");
	show("&nbsp;<p>");
	show("<strong>Projected Needs</strong><br><br>");
	show("Based on the information you entered, a gross income totalling ");
	show(txtGrossInc);
	show(" will be earned over the life of the plan.");
	show(" Withholding taxes of ");
	show(txtWithholdTax);
	show(" will be deducted at source, resulting in a total net income of ");
	show(txtNetIncome);
	show("</p>");
	show("<p>");
	show("The remaining balance of the plan at age ");
	show(txtLastAge);
	show(" will be ");
	
	//Convert to numeric values and set to zero if less amount is negative
	var tLastRIF = prepareNumber(txtLastRIF);
	if ( tLastRIF < 0 )
	{
	   txtLastRIF = "(0.0)";
	}
	
	show(txtLastRIF);
	show("</p>");
	show("<p>");
	show("<strong>Disclaimers</strong><br><br>");
	show("The information contained herein is based on certain assumptions and is for ");
	show("illustrative purposes only. While care is taken in the preparation of this document,");
	show("no warranty is made as to the accuracy of applicability in any particular case.");
	show(" will be ");
	show("</p>");
	show("<p>");
	show("These calculators are provided for general illustrative purposes only. All ");
	show("examples are hypothetical. They are provided only as educational tools and do not ");
	show("constitute investment advice. To take into account your specific circumstances,");
	show(" you should obtain professional investment/legal and/or tax possible, as appropriate.");
	show("</p>");
	endRowData();
	endRow();

    //Show the print label
	beginRow();
	beginRowResultData();
    //show("<a href=\'javascript:printReport()\'> Print</a> ");
	endRowData();
	endRow();

	//Close all tags
	endTable();
//	endHTMLBody();
//	endHtml();
	
	// In FireFox/Safari, reload() function does not work. This is a workaround until the application is rewriten.
   	if ((/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) || (/Safari/.test(navigator.userAgent))) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits) and Safari;	
		//window.location.reload();
	} else {
		window.location.reload();
	}
}