
  
  // Function is used to evaluate and calculate the budget calculator fields
  function updCalc(input)
  {
    var nttlspent = 0
    if (input.form.mtotal.value != null && input.form.mtotal.value.length != 0)
    {
            nmttl = eval(input.form.mtotal.value)
            nless = Math.round(nmttl * .28);
            nspendable = nmttl - nless;
            input.form.less.value = nless;
            input.form.mspendable.value = nspendable;
            input.form.mspendable2.value = nspendable;
    }               
    if (input.form.rent.value != null && input.form.rent.value.length != 0)
    {
            nttlspent += eval(input.form.rent.value);
    }
    if (input.form.food.value != null && input.form.food.value.length != 0) {
            nttlspent += eval(input.form.food.value);
    }
    if (input.form.util.value != null && input.form.util.value.length != 0) {
            nttlspent += eval(input.form.util.value); }
    if (input.form.med.value != null && input.form.med.value.length != 0) {
            nttlspent += eval(input.form.med.value); }
    if (input.form.savings.value != null && input.form.savings.value.length != 0) {
            nttlspent += eval(input.form.savings.value); }
    if (input.form.loans.value != null && input.form.loans.value.length != 0) {
            nttlspent += eval(input.form.loans.value); }
    if (input.form.clothing.value != null && input.form.clothing.value.length != 0) {
            nttlspent += eval(input.form.clothing.value); }
    if (input.form.misc.value != null && input.form.misc.value.length != 0) {
            nttlspent += eval(input.form.misc.value); }
    if (input.form.trans.value != null && input.form.trans.value.length != 0) {
            nttlspent += eval(input.form.trans.value); }
    if (input.form.other.value != null && input.form.other.value.length != 0) {
            nttlspent += eval(input.form.other.value); }
    if (input.form.childCare.value != null && input.form.childCare.value.length != 0) {
            nttlspent += eval(input.form.childCare.value); }
    if (input.form.ent.value != null && input.form.ent.value.length != 0) {
            nttlspent += eval(input.form.ent.value); }
  
    input.form.ttlspent.value=nttlspent;
    input.form.ttlspent2.value=nttlspent;
    input.form.ttlyear.value=nttlspent*12;
    input.form.ttlmavail.value=nspendable-nttlspent;
    input.form.ttlyravail.value=(nspendable-nttlspent)*12;                
    return true;
  }
  
  // Function clears the budget calculator when reset is requested
  function clearForm(input,from,to)
  {
    input.form.mtotal.value="";
    input.form.less.value="";
    input.form.mspendable.value="";
    input.form.rent.value="";
    input.form.food.value="";
    input.form.util.value="";
    input.form.savings.value="";
    input.form.med.value="";
    input.form.clothing.value="";
    input.form.loans.value="";
    input.form.other.value="";
    input.form.misc.value="";
    input.form.ent.value="";
    input.form.childCare.value="";
    input.form.trans.value="";
    input.form.ttlspent.value="";
    input.form.ttlyear.value="";
    input.form.mspendable2.value="";
    input.form.ttlmavail.value="";
    input.form.ttlspent2.value="";
    input.form.ttlyravail.value="";
    return true;
  }
  // Function determines and verifies the required fields are met to complete the budget calculator
  function verify() {
    var themessage = "You are required to complete the following field(s) before proceeding: \n";
    if (document.form.mtotal.value=="") {
    themessage = themessage + "   Monthly Gross Earnings \n" ;
    }
    if (document.form.rent.value==""
        && document.form.food.value==""
        && document.form.util.value==""
        && document.form.savings.value==""
        && document.form.med.value==""
        && document.form.clothing.value==""
        && document.form.loans.value==""
        && document.form.other.value==""
        && document.form.misc.value==""
        && document.form.ent.value==""
        && document.form.childCare.value==""
        && document.form.trans.value=="")
    {
    themessage = themessage + "   Expenses \n";
    }
  
    // If all fields are met, enable the Submit button to proceed to the next step
    if (themessage == "You are required to complete the following field(s) before proceeding: \n") {
    enableSubmitButton(document.GoNext.GoNextButton); 
    return false;
    }
    else {
    alert(themessage);
    
    return false;
       }
    }
  
  function cancelAction (evt) {
    return false;
    }
  // Function to call to disable the Submit Button
  function disableSubmitButton (button) {
    if (typeof button.disabled != "")
      button.disabled = true;
    else if (!button.buttonDisabled) {
      button.oldValue = button.value;
      button.oldOnclick = button.onclick;
      button.value = 'DISABLED';
      button.onclick = cancelAction;
      button.buttonDisabled = true;
      }
    }
    
  // Function to call to enable the Submit Button to focu
  function enableSubmitButton (button) {
    if (typeof button.disabled != "")
      button.disabled = false;
    else if (button.buttonDisabled) {
      button.value = button.oldValue;
      button.onclick = button.oldOnclick;
      button.buttonDisabled = false;
    }
  }
  
  // Especially designed to work with NS4 and up; Since disabling the submit,
  // this requires the user to fill the budget plan.
  // button is not possible for this version of NS, this requires the user to fill the 
  var checkobj;
  function defaultagree1(el){
    checkobj=el
    if (!document.all&&!document.getElementById)
      {
      if (document.form.mtotal.value!=""
        && (document.form.rent.value!=""
        || document.form.food.value!=""
        || document.form.util.value!=""
        || document.form.savings.value!=""
        || document.form.med.value!=""
        || document.form.clothing.value!=""
        || document.form.loans.value!=""
        || document.form.other.value!=""
        || document.form.misc.value!=""
        || document.form.ent.value!=""
				|| document.form.childCare.value!=""
        || document.form.trans.value!="")
        )
        return true
      else
      {
        alert("Please complete the budget calculator before proceeding")
        return false
          }
      }
    }

