function loan_calculator(c){var ba=strip_common_elements(document.getElementById(c).loan_amount.value);var bg=strip_common_elements(document.getElementById(c).apr_amount.value);var bz=strip_common_elements(document.getElementById(c).loan_period.value);var aj=0;var aC=0;var aP=0;var be=0;var bC=0;var bA=0;var d=new Array;var e=0;if(!check_number_valid(ba)){d[e]="\tThe loan amount field";e++;}if(!check_number_valid(bg)){d[e]="\tThe APR amount field";e++;}if(!check_number_valid(bz)){d[e]="\tThe loan period";e++;}if(d.length>0){var f;f=(d.length>1)?"The following fields are incorrect. Please check the fields and try again:\n\n":"The following field is incorrect. Please check the fields and try again:\n\n";for(i=0;i<d.length;i++){f+=d[i];f+="\n";}alert(f);document.getElementById(c).number_payments.value='';document.getElementById(c).monthly_amount.value='';document.getElementById(c).total_to_pay.value='';document.getElementById(c).total_interest.value='';return false;}bg/=100;bA=12*(Math.pow(bg+1,1/12)-1);bC=bA/12;aj=12*bz;var q=1/(1+bC);aC=(ba*(q-1))/(q*((Math.pow(q,aj))-1));aP=(aj*aC);be=(aP-ba);document.getElementById(c).number_payments.value=format_number_output(aj,0,',');document.getElementById(c).monthly_amount.value=format_number_output(aC,2,',','£');document.getElementById(c).total_to_pay.value=format_number_output(aP,2,',','£');document.getElementById(c).total_interest.value=format_number_output(be,2,',','£');return false;};function apr_calculator(c){var aV=strip_common_elements(document.getElementById(c).apr_nom_int.value);var aY=0;if(!check_number_valid(aV)){alert("You must fill out the nominal interest form field to calculate the APR. Please try again.");return false;}aV/=100;aY=(Math.pow((1+(aV/12)),12))-1;aY*=100;document.getElementById(c).apr_apr_int.value=format_number_output(aY,2,',');return false;};function nominal_calculator(c){var aU=strip_common_elements(document.getElementById(c).nom_apr_int.value);var aX=0;if(!check_number_valid(aU)){alert("You must fill out the APR form field to calculate the nominal interest rate. Please try again.");return false;}aU/=100;aX=(12*((Math.pow(aU+1,1/12))-1));aX*=100;document.getElementById(c).nom_nom_int.value=format_number_output(aX,2,',');return false;}