
document.write('<script type="text/javascript" src="http://moolah.asia/calculators/js/thickboxtest.js"></script>');
document.write('<link rel="stylesheet" href="http://moolah.asia/calculators/css/thickboxtest.css" type="text/css" media="screen" />');
function Show_Popup(action, userid) {
$('#popup').fadeIn('fast');
$('#window').fadeIn('fast');
}
function Close_Popup() {
$('#popup').fadeOut('fast');
$('#window').fadeOut('fast');
}
function formValidator(){
	// Make quick references to our fields
	
	var deposit=document.getElementById('deposit');	
	var saving=document.getElementById('saving');
	var eachyr=document.getElementById('eachyr');
	var yrs=document.getElementById('yrs');

	
	
	// Check each input in the order that it appears in the form!
	if(isNumeric(deposit, "Please enter valid dollar amount of deposit")){
		if(isNumeric(saving, "Please enter only digits for your return on saving")){
			if(isNumeric(eachyr, "Please enter valid dollar amount for saving")){
				if(isNumeric(yrs, "Please  enter only digit for number of yeasrs")){ 
				
							
							calculate();
						
			}
		}
	}
	}
	
	return false;
	
}
function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		elem.style.borderColor='#f5f5f5';
		return true;
		
	}else{
		alert(helperMsg);	
		elem.focus();
		elem.style.borderColor='#e70033';
		return false;
	}
}



function show12()
{	
var msg13="<br/>Historical returns of stocks, bonds, T-Bills, and inflation from 1926 through 2008:".concat("<br/><br/>").concat("1. Large-company stocks (as measured by the S&P 500 Index): 9.6%").concat("<br/>").concat("2. Small-company stocks: 11.7%").concat("<br/>").concat("3. Intermediate-term government bonds: 5.4%").concat("<br/>").concat("4. U.S. Treasury bills: 3.7%").concat("<br/>").concat("5. Inflation: 3.0%").concat("<br/><br/>").concat("Source: 2009 Morningstar, Inc. This chart is for illustrative purposes only and does not represent the performance of any particular investment. Past performance does not guarantee future results.<br/><br/>");

document.getElementById('msgbox12').style.display="block";
document.getElementById('msgbox12').style.visibility="visible";
document.getElementById('msgbox12').innerHTML=msg13;
document.getElementById('up12').style.visibility="visible";
document.getElementById('up12').style.display="inline"
document.getElementById("down12").style.display="none";
}

function sth12()
{
	document.getElementById('msgbox12').style.display='none';
	document.getElementById('msgbox12').style.visibility='hidden';
	document.getElementById('down12').style.display='inline';
	document.getElementById('up12').style.visibility="hidden";
	document.getElementById('up12').display='none';
} 
function calculate()
{
var deposit=parseFloat(document.getElementById('deposit').value);	
var saving=parseFloat(document.getElementById('saving').value);
var eachyr=parseFloat(document.getElementById('eachyr').value);
var yrs=parseFloat(document.getElementById('yrs').value);
var rate = saving * 0.01 + 1;
var total = deposit * Math.pow(rate, yrs);

var c_years = Math.ceil(yrs);

for (var i=0; i!=c_years; ++i) {
total += eachyr * Math.pow(rate, yrs - i);

}

c_years = yrs.toString().match(/\./) ? yrs.toFixed(2) : c_years;

	
	document.getElementById('showresult').style.display="block";
	document.getElementById("showresult").style.visibility="visible";
	document.getElementById('result').innerHTML=total.toFixed(2);
	document.getElementById('finalresult').innerHTML=c_years;
	document.getElementById('cal').value='Recalculate';
	
}

document.write("<div align='center' width='500'>");
document.write("<form  id='form12' onsubmit='return formValidator()'>");
document.write("<table id='tab'>");
document.write("<tbody>");
document.write("<tr>");
document.write("<td colspan='2'>");
document.write("<h2>How Much Will My Savings Grow?</h2>");
document.write("</td");
document.write("</tr>");
document.write("<tr><td colspan='2' style='border-bottom-style:dotted;border-color:#801bbf;border-width:1px;padding-top:' class='heading'>");
document.write("Compound interest can have a dramatic effect on the growth of a series of regular savings and initial lump sum deposits. Use this calculator to determine the future value of your savings and lump sum.<br/>&nbsp;");
document.write("</td></tr>");
document.write("<tr><td width='70%'>");
document.write("Initial balance or deposit");
document.write("</td><td>");
document.write("$<input type='text' id='deposit' size='7'>");
document.write("</td></tr>");
document.write("<tr><td>");
document.write("Return on Savings (Interest Rate)");
document.write("<img src='http://moolah.asia/calculators/img/down.png' id='down12' style='visibility:visible;cursor:pointer;' onclick='show12();'>");
document.write("<img src='http://moolah.asia/calculators/img/up.png' id='up12' style='visibility:hidden;cursor:pointer;' onclick='sth12();'>");
document.write("<div id='msgbox12' style='visibility:hidden;display:none;'></div>");
document.write("</td><td valign='top'>");
document.write("&nbsp;&nbsp;<input type='text' id='saving' size='7'>%");
document.write("</td></tr>");
document.write("<tr><td>");
document.write("How much savings will you add each year?");
document.write("</td><td>");
document.write("$<input type='text' id='eachyr' size='7'>");
document.write('</td></tr>');
document.write("<tr><td>");
document.write("Number of years");
document.write("</td><td>");
document.write("&nbsp;&nbsp;<input type='text' id='yrs' size='7'>");
document.write("</td></tr>");
document.write("<tr><td colspan='2' align='right'>");
document.write("<input type='submit' id='cal'  class='btn' value='calculate'>");
document.write("</td></tr>");

document.write("<tr><td colspan='2'>");
document.write("<div style='visibility:hidden;display:none' id='showresult' name='showresult'>");
document.write("<font color='#801bbf' size='+1'><b>Results</b></font><br/>");
document.write("Based on the savings amount and interest rate you specified, compounded annually, you will accumulate  $")
document.write("<div id='result' style='display:inline;'></div>");
document.write("&nbsp;over the next ");
document.write("<div id='finalresult' style='display:inline;'></div>&nbsp;years.* <br/><br/>*Please note, you will be taxed on interest earnings.");
document.write("</div>");

document.write("</tbody></table>");

document.write("<div id='foot'>");
document.write("<a href='http://moolah.asia' target='_blank' id='hyper'>Powered By Moolah.asia</a>");
document.write("<a href='http://moolah.asia/disclaimer.php' style='padding-left:30px;' id='hyper'>Disclaimer</a>");
document.write("<a href='#' style='padding-left:30px;' onmouseover='Show_Popup();' id='hyper'>Embed this Calculator</a>");
document.write("</div>");
document.write("</form>");
document.write("</div>");
document.write("<center><div id='popup' style='background-image:url(http://moolah.asia/calculators/img/bg.png);display:none;width:450px;height:200px;background-repeat:no-repeat;align:center'><div style='padding-top:18px;padding-left:420px;' ><a href='#' onclick='Close_Popup();' style='text-decoration:none' ><img src='http://moolah.asia/calculators/img/x.png' border='0'></a></div><div style='padding-left:10px;text-align:left;padding-left:15px;padding-right:15px;'>To embed this calculator into your site copy the following text and paste it into your HTML page:<br/><br/><textarea cols='50' rows='2'><script language='javascript' src='http://moolah.asia/calculators/savinggrow.js'></script></textarea></div></div></center>");

