
document.write("<script>  \n");

function repay_calc(){
	
	var repay = document.repay.p.value;
	var threshold_rate  = document.repay.i.value;
	var threshold_limit 	  = document.repay.threshold_limit.value;
	
	if (repay == '') { repay = '0'; }
	if (threshold_rate == '')  { threshold_rate = '0'; }
	if (threshold_limit == '') { threshold_limit = '0'; }
	
	if (repay == "0"){ 
		var display = '<b style="color:red">Please enter "Salary Value" field.</b>'; 
		document.getElementById("status").innerHTML = display; 
		}
		
	if (threshold_rate == "0"){ 
		var display = '<b style="color:red">Please enter "Threshold Rate" field.</b>'; 
		document.getElementById("status").innerHTML = display; 
		}
	
	if (threshold_limit == "0"){ 
		var display = '<b style="color:red">Please enter "Threshold Limit" field.</b>'; 
		document.getElementById("status").innerHTML = display; 
		}
		
	if (repay != "0" && threshold_rate != "0" && threshold_limit != "0" ){ 
		var str = repay 
		var a = (str.replace(/,/, "")) 
		var str = threshold_limit
		var b = (str.replace(/,/, "")) 
		var t_threshold_rate = eval(threshold_rate/1200); 
		var t = eval(a-b); 
			
			if(t < 0){ 
				var repayment = 0;
			} else { 
				var repayment = eval((a-b)*(t_threshold_rate));
			} 
			
			
			if (t < 0){
				var texta = "because your salary is less than the current threshold";
			} else {var texta = "calculated at 9% of the amount of your salary above the current threshold";
			} 

		var total = repayment.toFixed(2); 
		var display ='Your monthly repayment is <b style="color:#FF7F2A">&pound; '+total+'</b> '+texta+'';
		document.getElementById("status").innerHTML = display; 
	
	}
		
}
document.write("</script>  \n");
 document.write("<form id=\"repay\" name=\"repay\" method=\"post\" action=\"\"> \n ");
 document.write("<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"220px\" style=\"font-size: 1em; font-family: Arial, Helvetica, sans-serif; border: 2px solid #37abc8; font-size: 1.0em;\"> \n ");
 document.write("<tr> \n ");
 document.write("<td colspan=2 id=\"header\"><a href=\"http://www.118student.co.uk/finance/loan-calculator.html\"><img src=\"http://www.118student.co.uk/calc-header.gif\" alt=\"Student Loan Repayment Calculator\"  border=\"0\" /></a></td> \n ");
 document.write("</tr><tr><td colspan=2 style=\"background-color: #37abc8; font-weight: 600; color: #fff;\">Input Information</td> \n ");
 document.write("</tr><tr> \n ");
 document.write("<td width=\"70%\"><b>Enter Your Salary (&pound;)</b></td><td>  \n ");
 document.write("<input name=\"p\" type=\"text\" id=\"p\" value=\"25,000\" size=\"8\" onchange=\"javascript:repay_calc();\" /> \n ");
 document.write("</td></tr><tr> \n ");
 document.write("<td width=\"70%\"><b>Threshold Rate (%)</b></td><td>  \n ");
 document.write("<input name=\"i\" type=\"text\" id=\"i\" value=\"9.00\" size=\"3\" onchange=\"javascript:repay_calc();\" /> \n ");
 document.write("</td></tr><tr> \n ");
 document.write("<td width=\"70%\"><b>Threshold Limit</b></td><td>  \n ");
 document.write("<input name=\"threshold_limit\" type=\"text\" id=\"threshold_limit\" value=\"15,000\" size=\"8\" maxlength=\"8\" onchange=\"javascript:repay_calc();\" /> \n ");
 document.write("</td></tr><tr> \n ");
 document.write("<td colspan=2> \n ");
 document.write("<input type=\"button\" name=\"button\" id=\"btn\" value=\"Calculate\" onclick=\"javascript:repay_calc();\" /> \n ");
 document.write("</td></tr><tr> \n ");
 document.write("<td colspan=2><div id=\"status\">Your monthly repayment is calculated at 9% of the amount of your salary above the current threshold</div></td> \n ");
 document.write("</tr> </table></form> \n ");

