/**
 * @author buenger
 */
var LeasingInterest = {
	
	carInterests: [
		{minPrice: 0, maxPrice: 500000, nomInterest: 5.4}
	],
		
	bikeInterests: [
		{minPrice: 0, maxPrice: 500000, nomInterest: 6.9}
	],
		
	vanInterests: [
		{minPrice: 0, maxPrice: 500000, nomInterest: 5.4}
	],
	
	getInterest: function (a_productId, a_price, a_deposit) {
		var interests, ratio, comparePrice, l, interest;
		
		interests = this.getInterestsByProductId(a_productId);
		ratio = a_price/a_deposit;
		
		comparePrice = (ratio > 3.33333 || !isFinite(ratio)) ? a_price: a_price - a_deposit;
		l = interests.length;
		while (l--) {		
			if (comparePrice < interests[l].minPrice || comparePrice > interests[l].maxPrice) {
				continue;	
			}
			interest = interests[l].nomInterest;
		}
		return interest;
	},
	
	getInterestsByProductId: function (a_productId) {
		var interests;
		switch(a_productId) {
			case Const.VAN: case Const.CAMPER:
				interests = this.vanInterests;
				break;
			
			case Const.BIKE:
				interests = this.bikeInterests;
				break;
				
			case Const.CAR:
				interests = this.carInterests;
				break;
		}
		return interests;
	}	
}

