function validate()
{	

	if (!isNaturalNumber(document.tools.finance, " for the Savings Goal."))
    {
        return false;
    }

    if (!isValueInRange(document.tools.sr, 1, 100, " for the Savings Interest rate."))
    {
        return false;
    }
         
    if (!isNaturalNumber(document.tools.y, " for the Number of Years to save."))
    {
        return false;
    }
	if(document.tools.freq.options[document.tools.freq.selectedIndex].value == "All")
	{
    	alert('Frequency of Contibution must be selected');
    	document.tools.freq.focus();
    	return false;
	}
    return true;
}

function calc1()
{
    var freq = parseFloat(document.tools.freq.options[document.tools.freq.selectedIndex].value);
    var goal = parseFloat(document.tools.finance.value);
    var cs = 0;
    var y = parseFloat(document.tools.y.value);
    var sr = parseFloat(document.tools.sr.value)/100;
    var temp = sr / freq;
    var es = parseFloat(cs * Math.pow(1 + temp, y * freq));

    var num = (goal - es) * temp;
    var den = Math.pow(1 + temp, y * freq) - 1;
    var cp = num / den;

    document.tools.cp.value = round(cp, 0);
    document.tools.y1.value = y;
   
}
