var roi_c = function()
{
	this.afschrijving_per_km = 0.2;
	this.kosten_trackjack = 150;
	this.inbouwkosten = 79;

	this.loon_uren_besparing = 7;
	this.loon_kosten_besparing = 280;
	this.besparing_loonkosten = 0;
	this.partimepercentage = 0;
	this.pensioengrondslag = 0;

	this.getBesparingLoonkosten = function()
	{
		this.besparing_loonkosten = parseFloat(document.roi_calculatie.input_employee_effective_i.value) + parseFloat(document.roi_calculatie.input_employee_overtime_i.value) + parseFloat(document.roi_calculatie.input_employee_save_hour_i.value);
		return (this.besparing_loonkosten*21)/60;
	}

	this.getBesparingLoonkostenPerMaand = function()
	{
		return (this.getBesparingLoonkosten() * parseFloat(document.roi_calculatie.input_hour_amount_i.value));
	}

	this.getBesparingLoonkostenPerJaar = function()
	{
		return (this.getBesparingLoonkostenPerMaand() * parseFloat(document.roi_calculatie.input_car_amount_i.value) * parseFloat(document.roi_calculatie.input_employee_amount_i.value) * 12);
	}

	this.getBesparingBrandstofInPercentage = function()
	{
		this.BesparingBrandstofInPercentage = (((parseFloat(document.roi_calculatie.input_milage_amount_i.value) / parseFloat(document.roi_calculatie.input_besparing_per_voertuig_i.value)) * parseFloat(document.roi_calculatie.input_besparing_per_liter_i.value)) / 100) * 1;
		return Math.round(this.BesparingBrandstofInPercentage);
	}

	this.getBesparingOnderhoud = function()
	{
		return Math.round(parseFloat(document.roi_calculatie.input_besparing_onderhoud_i.value) * 5);
	}

	this.getBesparingMinderKilometers = function()
	{
		return Math.round(parseFloat(document.roi_calculatie.input_besparing_minder_kilometers_i.value) * parseFloat(document.roi_calculatie.input_afschrijvingskosten_amount_i.value));
	}

	this.getBesparingPerVoertuig = function()
	{
		return this.getBesparingBrandstofInPercentage() + this.getBesparingOnderhoud() + this.getBesparingMinderKilometers();
	}

	this.getBesparingAlleVoertuigen = function()
	{
		return this.getBesparingPerVoertuig() * parseFloat(document.roi_calculatie.input_car_amount_i.value);
	}

	this.getTotaalBesparing = function()
	{
		return this.getBesparingLoonkostenPerJaar() + this.getBesparingAlleVoertuigen();
	}

	this.getTotaalAbonnementskosten = function()
	{
		return Math.round((8.193 * 12)* parseFloat(document.roi_calculatie.input_car_amount_i.value));
	}

	this.getTotaalExtraRendement = function()
	{
		return this.getTotaalBesparing() - this.getTotaalAbonnementskosten();
	}

	this.getTotaalExtraRendementPerMaand = function()
	{
		return Math.round(this.getTotaalExtraRendement() / 12);
	}

	this.getTotaalInvestering = function()
	{
		return (parseFloat(document.roi_calculatie.input_cost_trackjack_i.value) + parseFloat(document.roi_calculatie.input_cost_inbouw_i.value)) * parseFloat(document.roi_calculatie.input_car_amount_i.value);
	}

	this.getTerugverdientijd = function()
	{
		return Math.round((this.getTotaalInvestering() / this.getTotaalExtraRendementPerMaand())*10) / 10;
	}
};

function formatNumber (number)
{
	number = '' + number;
	numberParts = new Array();
	numberParts = number.split(".");

	number = numberParts[0];

	if (number.length > 3)
	{
	  var mod = number.length%3;
	  var output = (mod > 0 ? (number.substring(0,mod)) : '');
	  for (i=0 ; i < Math.floor(number.length/3) ; i++)
	  {
	    if ((mod ==0) && (i ==0)) {
	      output+= number.substring(mod+3*i,mod+3*i+3);
	    } else {
	      output+= '.' + number.substring(mod+3*i,mod+3*i+3);
	    }
	  }

	  if (numberParts.length == 2)
	  {
	    output = output + "," + numberParts[1];
	  }
	  return (output);
	}
	else
	{
	  if (numberParts.length == 2)
	  {
	    number = number + "," + numberParts[1];
	  }
	  return number;
	}
}

function stripAlphaChars(pstrSource)
{
var m_strOut = new String(pstrSource);
    m_strOut = m_strOut.replace(/[^0-9]/g, '');

    return m_strOut;
}

function stripBad(value_s)
{
	output = value_s;
	output = value_s.replace('.', ',');
	return output;
}

function stripLoon(value_s)
{
	output = value_s;
	output = output.replace('.', '');
	output = output.replace(',', '.');

	return Math.round(output);
}

