/**
 * calculation for iva, dmp comparison
 */

$(document).ready(function() {
	
	// stop form submitting
	$('#dmp-to-iva-form').submit( function() {
		return false;
	});

	$('#dmp-to-iva-submit').click(function() {
		var lcMinMonthlyFee = 500;
		var lcMaxMonthlyFee = 100;
		var lcFeePercentage = 5;
		var amount = $('#debt-amount').val() * 1;
		var payment = $('#debt-payment').val() * 1;
		
		/* calculate dmp figure */
		var monthly_fee = $('#debt-payment').val() * lcFeePercentage;
		if ( monthly_fee < lcMinMonthlyFee ) {
			monthly_fee = lcMinMonthlyFee;
        }
		else if ( monthly_fee > lcMaxMonthlyFee ) {
			monthly_fee = lcMaxMonthlyFee;
        }
		
        var tmp_answer1 = amount + ( payment * 2);
        //var tmp_answer2 = monthly_fee * Math.round(amount / ( payment - monthly_fee));
        var dmp_answer  = tmp_answer1 + monthly_fee * Math.round(amount / ( payment - monthly_fee));
		
		$('#dmp-answer').html('&pound;' + dmp_answer); 
		$('#iva-answer').html('hello');

		
		//if ( $("#dmp-to-iva").valid() ) {
			/* $("#content #calc").html(ajax_load); */

			// send data to callback process
			/*
			$.post(
					"/wp-content/cal",
					{    "total_debt": $("#debt_level_calc").val()
					}
					//,function(responseText) { alert(responseText) }
					//,"html"
				);

			$('#calc_form').submit();
			*/
			//return true; // now send the page off to the form action
		//}
		//else {
			return false;
		//}
	}); // click
}); // ready

