jQuery(document).ready(function(){
    initCalc();
});


function calcCred()
{
	if(typeof(creditRate) == 'undefined')
	{
        return false;
    }
    
    var cena = document.getElementById('cena');
	var termins = document.getElementById('termins');
	var procenti = document.getElementById('firstPayment');
	var maksajums = document.getElementById('amount');
    c = parseFloat(cena.value);
	t = parseFloat(termins.value);
	p = parseFloat(procenti.value);
    r = parseFloat(creditRate);
    
	if(t > 0)
	{
		ikm = ((c - p) * r) / t; 
        maksajums.innerHTML = Math.round(ikm * 100) / 100;
	} else {
		maksajums.innerHTML = '0.00';
	}
}



function initCalc()
{
    jQuery('#manda input').bind('click',calcCred);
}
