function instalments()
{
  	var price = $("#priceHidden").val();
  	var deliveryPrice = $("#deliveryPriceHidden").val();
  	var accessoriesPrice = $("#accessoriesPrice").val();
  	var instalmentCount = $("#instalmentCount").val();
  	var ownPayment = $("#ownPayment").val();

	//resetujemy pola wyników
	$("#estimateInstalment").val('');
	$("#fullInstalmentPrice").val('');
	$("#fullPrice").val('');	
	
	if(!isNumber(price))
	{
		alert("Cena produktu jest nieprawidłowa");
		return false;
	}
	if(!isNumber(deliveryPrice))
	{
		alert("Cena transportu jest nieprawidłowa");
		return false;
	}
	if(accessoriesPrice)
	{
		if(!isNumber(accessoriesPrice))
		{
			alert("Cena dodatkowych akcesoriów jest nieprawidłowa");
			$("#estimateInstalment").val('Błąd danych');
			$("#fullInstalmentPrice").val('Błąd danych');
			$("#fullPrice").val('Blad danych');
			return false;
		}
		
		accessoriesPrice = accessoriesPrice.replace(',', '.');
		accessoriesPrice = parseFloat(accessoriesPrice).toFixed(2);
		
		if(accessoriesPrice < 0)
		{
			alert("Cena dodatkowych akcesoriów jest nieprawidłowa");
			$("#estimateInstalment").val('Błąd danych');
			$("#fullInstalmentPrice").val('Błąd danych');
			$("#fullPrice").val('Błąd danych');
			return false;
		}

	}
	else
	{
		accessoriesPrice = '0.00';
	}
    $("#accessoriesPrice").val(accessoriesPrice.replace('.', ','));
    
   	price = parseFloat(price);
	deliveryPrice = parseFloat(deliveryPrice);
	accessoriesPrice = parseFloat(accessoriesPrice);
    var sum = price + deliveryPrice + accessoriesPrice;
	sum = sum.toFixed(2);
	$("#fullPrice").val(sum.replace('.', ',')+ " zł");
    
    if(ownPayment)
    {
		if(!isNumber(ownPayment))
		{
			alert("Wpłata własna jest nieprawidłowa");
			$("#estimateInstalment").val('Błąd danych');
			$("#fullInstalmentPrice").val('Błąd danych');
			return false;
		}
		ownPayment = ownPayment.replace(',', '.');
		ownPayment = parseFloat(ownPayment).toFixed(2);		

		if(ownPayment < 0)
		{
			alert("Wpłata własna jest nieprawidłowa");
			$("#estimateInstalment").val('Błąd danych');
			$("#fullInstalmentPrice").val('Błąd danych');
			return false;
		}

    }
    else
    {
    	ownPayment = '0.00';
    }
	$("#ownPayment").val(ownPayment.replace('.', ','));
	if(instalmentCount)
	{
		if(!isNumber(instalmentCount))
		{
			alert('Nieprawidłowa liczba rat');
			return false;
		}
	}
	else
	{
		instalmentCount = 0;
	}

	if(instalmentCount <= 0)
	{
		alert("Liczba rat jest nieprawidłowa");
		return false;
	}
	
	instalmentCount = parseInt(instalmentCount);
	
	var	fullValue = price + deliveryPrice + accessoriesPrice - ownPayment;
	fullValue = fullValue.toFixed(2);
	if(price > 0 && ownPayment > sum - 100)
	{
		alert('Za wysoka kwota wpłaty własnej. Kwota kredytu musi być większa od 100 zł');
		$("#estimateInstalment").val('Błąd danych');
		$("#fullInstalmentPrice").val('Błąd danych');
		return false;
	}
	
	var estimateInstalment = (fullValue / instalmentCount) + (fullValue * 1/100);
	estimateInstalment = estimateInstalment.toFixed(2);
	$("#estimateInstalment").val(estimateInstalment.replace('.', ',')+ " zł");
	
	var fullInstalmentPrice = (estimateInstalment * instalmentCount) - fullValue;
	fullInstalmentPrice = fullInstalmentPrice.toFixed(2);
	$("#fullInstalmentPrice").val(fullInstalmentPrice.replace('.', ',') + " zł");
}
