function sliderInit(rates,maxValue,postfix){
	
	sliderRates = rates;
	
	$('#formIncome').accessibleUISlider({width: 390, onChange: update});
	$('#formBalance').accessibleUISlider({width: 390, onChange: update});
	$('#formTransferNo').accessibleUISlider({width: 390, onChange: update});
	$('#formRate').accessibleUISlider({width: 390, onChange: update});

	
	var maxRate = maxValue;
	var sliderWidth = 176;
	
	var handle = $('#new-interest-rate-handle')
	var rateContainer = $('#new-interest-rate');

	function update() {
		var v1 = $('#formIncome').attr('value');
		var v2 = $('#formBalance').attr('value');
		var v3 = $('#formTransferNo').attr('value');
		
		var rate = getSliderRate(v1, v2, v3);
        var r = +(rate.replace(",", "."));		
		var handlePos = 0;
        if (rate != null && 'null' != rate) {
             handlePos = (r*sliderWidth)/maxRate;
        }
        handle.css('left', handlePos);
		
		//ustawiana pozycja spana z aktualna wartoscia w zaleznosci od wartosci tak by span nie wychodzil poza box
		//wartosc wstawiana do inputa (nastepnego po span#new-interest-rate)
	    if (rate != null && rate != 'null') {
            rateContainer.css('left', -40*(r/maxRate)).text(rate + ' ' + postfix).next('input').attr('value', rate);
		} else {
            rateContainer.css('left', 0).text(' ').next('input').attr('value', ' ');
		}
	}
	
	update();
}

function getSliderRate(income, balance, freePayments){
	if (income != null && balance != null && freePayments != null) { 
		return sliderRates[income][balance][freePayments];
	} else {
		return "";
	}
}

