var smallcalc = {};
smallcalc.ir = 0.05;
smallcalc.init = function ()
{
	var tmp_price = document.getElementById('smallcalc_hypo');
	event_handler.add(tmp_price, 'keyup', smallcalc.recompute);

	var tmp_length = document.getElementById('smallcalc_doba');
	event_handler.add(tmp_length, 'keyup', smallcalc.recompute);

	var tmp_payment = document.getElementById('smallcalc_mesicne');
	event_handler.add(tmp_payment, 'keyup', smallcalc.recompute);
};
smallcalc.recompute = function ()
{
	var tmp_price = document.getElementById('smallcalc_hypo');
	num_price = new Number(calc.getComputerNumbers(tmp_price.value)).valueOf();
	if (tmp_price.value.length > 0)
	{
		tmp_price.value = calc.getHumanNumbers(num_price);
	}

	var tmp_length = document.getElementById('smallcalc_doba');
	num_length = new Number(calc.getComputerNumbers(tmp_length.value)).valueOf();
	if (tmp_length.value.length > 0)
	{
		tmp_length.value = calc.getHumanNumbers(num_length);
	}

	var tmp_payment = document.getElementById('smallcalc_mesicne');

	if (tmp_price.value.length <= 0 || tmp_length.value.length <= 0)
	{
		tmp_payment.value = '';
		return;
	}

	if (num_length < 3 || num_length > 40)
	{
		tmp_payment.value = '';
		return;
	}

	if (num_price < 250000 || num_price > 99000000)
	{
		tmp_payment.value = '';
		return;
	}

	var tmp_ir = smallcalc.ir/12;
	tmp_payment.value = calc.getHumanNumbers(Math.round((num_price*(tmp_ir*365.25/360))/(1-Math.pow(1+tmp_ir*365.25/360, -(num_length*12)))));
};
