
// Main routine to set the Java Applet parameters and trigger a re-calculation
// of the analysis.  Once the calculation is done, then this routine will
// also retrieve calculated variables and strings to be dislayed back in the
// HTML/Ajax UI.

function java_recalc(child) {

}


function unfmt(amt) {    //remove dollar signs, commas, spaces, trailing decimals
        var re1 = /[ $,]/g;
        var re2 = /\.*/;
        var myval = amt.replace(re1, "");
        myval = myval.replace(re2, "");
        if (myval < 0) {
            return 0;
        }

        return myval;
    }  

function numfmt(amt) {      //add commas to a number for display
        var i = parseInt(amt,10);
        var minus = '';

        if (isNaN(i)) return '';
        if (i < 0) minus = '-';
        i = Math.abs(i);
        var n = new String(i);
        var a = [];
        while (n.length > 3) {
            var nn = n.substr(n.length-3);
            a.unshift(nn);
            n = n.substr(0,n.length-3);
        }
        if (n.length > 0) a.unshift(n);
        n = a.join(",");
        amt = minus + n;

        return amt;

    }  //numfmt()



// Open and display the Applet Report window
function openNote(sType) {
  var OpenWindow=window.open("","newwin","toolbar=yes,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=380");
  var s = " ";

  if (navigator.appName == "Netscape")
     s=document.applets["calculator"].sJavaScriptReport(sType);
  else
     s=document.calculator.sJavaScriptReport(sType);

  OpenWindow.document.write(s);
  OpenWindow.document.close();

}


// Show/Hide the College Search Name row
function shownamerow(child) {
    document.getElementById('avgrow' + child).style.display="none";
    document.getElementById('namerow' + child).style.display="";
    document.getElementById('staterow' + child).style.display="none";
}

// Show/Hide the College Search State row
function showstaterow(child) {
    document.getElementById('avgrow' + child).style.display="none";
    document.getElementById('namerow' + child).style.display="none";
    document.getElementById('staterow' + child).style.display="";
}

// Show/Hide the College Search National Average row
function showavgrow(child) {
    document.getElementById('avgrow' + child).style.display="";
    document.getElementById('namerow' + child).style.display="none";
    document.getElementById('staterow' + child).style.display="none";
}

function reset_editassumptions() {

	    //
	    // Re-Set the Edit Assumptions fields to their original values
	    // if the user clicked Cancel.
	    //
	child = document.getElementById("currentchild").value;
	//alert("in reset_editassumptions(" + child + ")");

	document.getElementById("num_years" + child).value=document.accordform.disp_num_years.value;
	document.getElementById("age_of_education" + child).value=document.accordform.disp_age_of_education.value;

	var tmpstr;
	tmpstr = document.accordform.disp_college_cost_inflation.value;
	document.getElementById("college_cost_inflation" + child).value=tmpstr.replace("%", "");
	tmpstr = document.accordform.disp_savepct.value;
	document.getElementById("savepct" + child).value=tmpstr.replace("%", "");

	tmpstr = document.accordform.disp_rate_of_return.value;
	document.getElementById("rate_of_return" + child).value=tmpstr.replace("%", "");

}


function open_editassumptions() {


	    //
	    // Set the Edit Assumptions fields 
	    //
	child = document.getElementById("currentchild").value;
	java_recalc(child);


	    // trigger the opening of the edit assumptions modal window
	bpc.trigger("open", document.getElementById(document.accordform.edit.value));

}

function showObj (id) {
    //alert('attemping to hide ' + id)
    body = document.getElementById(id);
    try {
        body.style.display = 'table-row';
    } catch (e) {
        body.style.display = 'block';
    }
} //showObj

function hideObj (id) {
      //alert('attemping to hide ' + id)
  body = document.getElementById(id);
  body.style.display = 'none';
} //hideObj

