











var mediatisSimulator_ppr = {

  data:{
    amountSliceList:[


	{amountMin:0,
	 amountMax:500,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		15.0
       	
	
	,
	
		20.0
       	
	
	,
	
		25.0
       	
	]}


,

	{amountMin:501,
	 amountMax:1000,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		30.0
       	
	
	,
	
		40.0
       	
	
	,
	
		50.0
       	
	]}


,

	{amountMin:1001,
	 amountMax:1500,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		45.0
       	
	
	,
	
		60.0
       	
	
	,
	
		75.0
       	
	]}


,

	{amountMin:1501,
	 amountMax:2000,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		60.0
       	
	
	,
	
		80.0
       	
	
	,
	
		100.0
       	
	]}


,

	{amountMin:2001,
	 amountMax:2500,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		75.0
       	
	
	,
	
		100.0
       	
	
	,
	
		125.0
       	
	]}


,

	{amountMin:2501,
	 amountMax:3000,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		85.0
       	
	
	,
	
		110.0
       	
	
	,
	
		135.0
       	
	]}


,

	{amountMin:3001,
	 amountMax:3500,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		100.0
       	
	
	,
	
		125.0
       	
	
	,
	
		150.0
       	
	]}


,

	{amountMin:3501,
	 amountMax:4000,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		115.0
       	
	
	,
	
		140.0
       	
	
	,
	
		165.0
       	
	]}


,

	{amountMin:4001,
	 amountMax:10000,
	 teg:18.950000762939453,
	 monthlyPaymentList:[
	
	
		0.028999999999999998
       	
	
	,
	
		0.035
       	
	
	,
	
		0.042
       	
	]}
	
    ]
  },

  // --------------------------------------------------------
  amountList:[
  500.0, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 3500.0, 4000.0, 4500.0, 5000.0, 5500.0, 6000.0, 6500.0, 7000.0, 7500.0, 8000.0, 8500.0, 9000, 9500, 10000.0
  ],
  amountIndex:0,
  amountSliceIndex:0,
  monthlyPaymentIndex:0,
  isInitState:true,
  // --------------------------------------------------------
  getAmountCount:function(){return this.amountList.length;},
  getAmountMax:function(){return this.amountList[this.amountList.length-1];},
  getAmountMin:function(){return this.amountList[0];},
  getAmount:function(){return this.amountList[this.amountIndex];},
  getAmountSlice:function(){return this.data.amountSliceList[this.amountSliceIndex];},
  getTeg:function(){return this.data.amountSliceList[this.amountSliceIndex].teg;},
  getMonthlyPaymentCount:function(){return this.data.amountSliceList[this.amountSliceIndex].monthlyPaymentList.length;},
  getMonthlyPaymentMin:function(){return this.getMonthlyPaymentList()[0];},
  getMonthlyPaymentMax:function(){return this.getMonthlyPaymentList()[this.getMonthlyPaymentCount()-1];},
  getSelectedMonthlyPayment:function(){return this.getMonthlyPaymentList()[this.monthlyPaymentIndex];},
  getMonthlyPaymentList:function(){
      var mpValues = this.data.amountSliceList[this.amountSliceIndex].monthlyPaymentList;
      var res = new Array();
      for(var i in mpValues)
          if(mpValues[i] < 1.0)
              res[i] = mpValues[i] * this.getAmount();
          else
              res[i] = mpValues[i];
      return res;
  },
  setMonthlyPaymentListForAmount:function(a){
      for (var i=0; i<this.data.amountSliceList.length;i++) {
       if (a >= this.data.amountSliceList[i].amountMin && a <= this.data.amountSliceList[i].amountMax) {
          this.amountSliceIndex = i;
          break;
       }
    }
  },
  setAmount:function(val){
      var currentVal = this.getAmount();
      var smallestInterval = Math.abs(val - currentVal);

      for(var i=0;i<this.amountList.length;i++){
          currentVal = this.amountList[i];
          if(Math.abs(val - currentVal) < smallestInterval){
              smallestInterval = Math.abs(val - currentVal);
              this.amountIndex = i;
          }
      }
      this.setMonthlyPaymentListForAmount(this.getAmount());
  },
  setAmountIndex:function(i){
      if(i>=0 && i<=(this.getAmountCount()-1)){
         this.amountIndex = i;
         this.setMonthlyPaymentListForAmount(this.getAmount());
      }
  },
  setMonthlyPaymentIndex:function(i){
  	if(i>=0 && i<=(this.getMonthlyPaymentCount()-1))
  	   this.monthlyPaymentIndex = i;
  },
  setPlusAmount:function()
  {
      if(this.amountIndex < this.amountList.length-1)
          this.setAmountIndex(this.amountIndex+1);
  },
  setMinusAmount:function()
  {
      if(this.amountIndex > 0)
          this.setAmountIndex(this.amountIndex-1);
  }
};

