function Calculate_CREDIT()
{
	var d=document,f=d.forms[0];

	var DonationAmount = my_round(parseFloat(f['DonationAmount'].value));

	if(DonationAmount<200)
	{
		d.getElementById('lt200_Alberta').innerHTML		= my_round(DonationAmount*0.255);
		d.getElementById('lt200_BC').innerHTML			= my_round(DonationAmount*0.2155);
		d.getElementById('lt200_Manitoba').innerHTML	= my_round(DonationAmount*0.264);
		d.getElementById('lt200_NB').innerHTML			= my_round(DonationAmount*0.2518);
		d.getElementById('lt200_NL').innerHTML			= my_round(DonationAmount*0.2607);
		d.getElementById('lt200_NWT').innerHTML			= my_round(DonationAmount*0.214);
		d.getElementById('lt200_NS').innerHTML			= my_round(DonationAmount*0.2429);
		d.getElementById('lt200_Nunavut').innerHTML		= my_round(DonationAmount*0.195);
		d.getElementById('lt200_ON').innerHTML			= my_round(DonationAmount*0.2155);
		d.getElementById('lt200_PEI').innerHTML			= my_round(DonationAmount*0.253);
		d.getElementById('lt200_QC').innerHTML			= my_round(DonationAmount*0.355);
		d.getElementById('lt200_Saskatchewan').innerHTML= my_round(DonationAmount*0.265);
		d.getElementById('lt200_Yukon').innerHTML		= my_round(DonationAmount*0.2254);
	}
	else {
		d.getElementById('lt200_Alberta').innerHTML		= my_round(200*0.255);
		d.getElementById('lt200_BC').innerHTML			= my_round(200*0.2155);
		d.getElementById('lt200_Manitoba').innerHTML	= my_round(200*0.264);
		d.getElementById('lt200_NB').innerHTML			= my_round(200*0.2518);
		d.getElementById('lt200_NL').innerHTML			= my_round(200*0.2607);
		d.getElementById('lt200_NWT').innerHTML			= my_round(200*0.214);
		d.getElementById('lt200_NS').innerHTML			= my_round(200*0.2429);
		d.getElementById('lt200_Nunavut').innerHTML		= my_round(200*0.195);
		d.getElementById('lt200_ON').innerHTML			= my_round(200*0.2155);
		d.getElementById('lt200_PEI').innerHTML			= my_round(200*0.253);
		d.getElementById('lt200_QC').innerHTML			= my_round(200*0.355);
		d.getElementById('lt200_Saskatchewan').innerHTML= my_round(200*0.265);
		d.getElementById('lt200_Yukon').innerHTML		= my_round(200*0.2254);
	}

	if(DonationAmount>200)
	{
		d.getElementById('gt200_Alberta').innerHTML		= my_round((DonationAmount-200)*0.5);
		d.getElementById('gt200_BC').innerHTML			= my_round((DonationAmount-200)*0.437);
		d.getElementById('gt200_Manitoba').innerHTML		= my_round((DonationAmount-200)*0.464);
		d.getElementById('gt200_NB').innerHTML			= my_round((DonationAmount-200)*0.4684);
		d.getElementById('gt200_NL').innerHTML			= my_round((DonationAmount-200)*0.4702);
		d.getElementById('gt200_NWT').innerHTML			= my_round((DonationAmount-200)*0.4305);
		d.getElementById('gt200_NS').innerHTML			= my_round((DonationAmount-200)*0.465);
		d.getElementById('gt200_Nunavut').innerHTML		= my_round((DonationAmount-200)*0.405);
		d.getElementById('gt200_ON').innerHTML			= my_round((DonationAmount-200)*0.4016);
		d.getElementById('gt200_PEI').innerHTML			= my_round((DonationAmount-200)*0.457);
		d.getElementById('gt200_QC').innerHTML			= my_round((DonationAmount-200)*0.53);
		d.getElementById('gt200_Saskatchewan').innerHTML	= my_round((DonationAmount-200)*0.44);
		d.getElementById('gt200_Yukon').innerHTML		= my_round((DonationAmount-200)*0.4176);
	}
	else {
		d.getElementById('gt200_Alberta').innerHTML=
		d.getElementById('gt200_BC').innerHTML=
		d.getElementById('gt200_Manitoba').innerHTML=
		d.getElementById('gt200_NB').innerHTML=
		d.getElementById('gt200_NL').innerHTML=
		d.getElementById('gt200_NWT').innerHTML=
		d.getElementById('gt200_NS').innerHTML=
		d.getElementById('gt200_Nunavut').innerHTML=
		d.getElementById('gt200_ON').innerHTML=
		d.getElementById('gt200_PEI').innerHTML=
		d.getElementById('gt200_QC').innerHTML=
		d.getElementById('gt200_Saskatchewan').innerHTML=
		d.getElementById('gt200_Yukon').innerHTML		=0
	}

	d.getElementById('TaxCredit_Alberta').innerHTML=my_round(parseFloat(d.getElementById('gt200_Alberta').innerHTML)+parseFloat(d.getElementById('lt200_Alberta').innerHTML))

	d.getElementById('TaxCredit_BC').innerHTML=my_round(parseFloat(d.getElementById('gt200_BC').innerHTML)+parseFloat(d.getElementById('lt200_BC').innerHTML))

	d.getElementById('TaxCredit_Manitoba').innerHTML=my_round(parseFloat(d.getElementById('gt200_Manitoba').innerHTML)+parseFloat(d.getElementById('lt200_Manitoba').innerHTML))

	d.getElementById('TaxCredit_NB').innerHTML=my_round(parseFloat(d.getElementById('gt200_NB').innerHTML)+parseFloat(d.getElementById('lt200_NB').innerHTML))

	d.getElementById('TaxCredit_NL').innerHTML=my_round(parseFloat(d.getElementById('gt200_NL').innerHTML)+parseFloat(d.getElementById('lt200_NL').innerHTML))

	d.getElementById('TaxCredit_NWT').innerHTML=my_round(parseFloat(d.getElementById('gt200_NWT').innerHTML)+parseFloat(d.getElementById('lt200_NWT').innerHTML))

	d.getElementById('TaxCredit_NS').innerHTML=my_round(parseFloat(d.getElementById('gt200_NS').innerHTML)+parseFloat(d.getElementById('lt200_NS').innerHTML))

	d.getElementById('TaxCredit_Nunavut').innerHTML=my_round(parseFloat(d.getElementById('gt200_Nunavut').innerHTML)+parseFloat(d.getElementById('lt200_Nunavut').innerHTML))

	d.getElementById('TaxCredit_ON').innerHTML=my_round(parseFloat(d.getElementById('gt200_ON').innerHTML)+parseFloat(d.getElementById('lt200_ON').innerHTML))

	d.getElementById('TaxCredit_PEI').innerHTML=my_round(parseFloat(d.getElementById('gt200_PEI').innerHTML)+parseFloat(d.getElementById('lt200_PEI').innerHTML))

	d.getElementById('TaxCredit_QC').innerHTML=my_round(parseFloat(d.getElementById('gt200_QC').innerHTML)+parseFloat(d.getElementById('lt200_QC').innerHTML))

	d.getElementById('TaxCredit_Saskatchewan').innerHTML=my_round(parseFloat(d.getElementById('gt200_Saskatchewan').innerHTML)+parseFloat(d.getElementById('lt200_Saskatchewan').innerHTML))

	d.getElementById('TaxCredit_Yukon').innerHTML=my_round(parseFloat(d.getElementById('gt200_Yukon').innerHTML)+parseFloat(d.getElementById('lt200_Yukon').innerHTML))

	d.getElementById('DonationCost_Alberta').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_Alberta').innerHTML))

	d.getElementById('DonationCost_BC').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_BC').innerHTML))

	d.getElementById('DonationCost_Manitoba').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_Manitoba').innerHTML))

	d.getElementById('DonationCost_NB').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_NB').innerHTML))

	d.getElementById('DonationCost_NL').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_NL').innerHTML))

	d.getElementById('DonationCost_NWT').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_NWT').innerHTML))

	d.getElementById('DonationCost_NS').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_NS').innerHTML))

	d.getElementById('DonationCost_Nunavut').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_Nunavut').innerHTML))

	d.getElementById('DonationCost_ON').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_ON').innerHTML))

	d.getElementById('DonationCost_PEI').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_PEI').innerHTML))

	d.getElementById('DonationCost_QC').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_QC').innerHTML))

	d.getElementById('DonationCost_Saskatchewan').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_Saskatchewan').innerHTML))

	d.getElementById('DonationCost_Yukon').innerHTML=my_round(DonationAmount-parseFloat(d.getElementById('TaxCredit_Yukon').innerHTML))
	
	var perc=new Array();
	
	
	d.getElementById('PercentageSaved_Alberta').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_Alberta').innerHTML)/DonationAmount)*100)
	perc[0]=parseFloat(d.getElementById('PercentageSaved_Alberta').innerHTML);
	
	d.getElementById('PercentageSaved_BC').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_BC').innerHTML)/DonationAmount)*100)
	perc[1]=parseFloat(d.getElementById('PercentageSaved_BC').innerHTML);
	
	d.getElementById('PercentageSaved_Manitoba').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_Manitoba').innerHTML)/DonationAmount)*100)
	perc[2]=parseFloat(d.getElementById('PercentageSaved_Manitoba').innerHTML);
	
	d.getElementById('PercentageSaved_NB').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_NB').innerHTML)/DonationAmount)*100)
	perc[3]=parseFloat(d.getElementById('PercentageSaved_NB').innerHTML);
	
	d.getElementById('PercentageSaved_NL').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_NL').innerHTML)/DonationAmount)*100)
	perc[4]=parseFloat(d.getElementById('PercentageSaved_NL').innerHTML);
	
	d.getElementById('PercentageSaved_NWT').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_NWT').innerHTML)/DonationAmount)*100)
	perc[5]=parseFloat(d.getElementById('PercentageSaved_NWT').innerHTML);
	
	d.getElementById('PercentageSaved_NS').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_NS').innerHTML)/DonationAmount)*100)
	perc[6]=parseFloat(d.getElementById('PercentageSaved_NS').innerHTML);
	
	d.getElementById('PercentageSaved_Nunavut').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_Nunavut').innerHTML)/DonationAmount)*100)
	perc[7]=parseFloat(d.getElementById('PercentageSaved_Nunavut').innerHTML);
	
	d.getElementById('PercentageSaved_ON').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_ON').innerHTML)/DonationAmount)*100)
	perc[8]=parseFloat(d.getElementById('PercentageSaved_ON').innerHTML);
	
	d.getElementById('PercentageSaved_PEI').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_PEI').innerHTML)/DonationAmount)*100)
	perc[9]=parseFloat(d.getElementById('PercentageSaved_PEI').innerHTML);
	
	d.getElementById('PercentageSaved_QC').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_QC').innerHTML)/DonationAmount)*100)
	perc[10]=parseFloat(d.getElementById('PercentageSaved_QC').innerHTML);
	
	d.getElementById('PercentageSaved_Saskatchewan').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_Saskatchewan').innerHTML)/DonationAmount)*100)
	perc[11]=parseFloat(d.getElementById('PercentageSaved_Saskatchewan').innerHTML);
	
	d.getElementById('PercentageSaved_Yukon').innerHTML=roundNumber((parseFloat(d.getElementById('TaxCredit_Yukon').innerHTML)/DonationAmount)*100)
	perc[12]=parseFloat(d.getElementById('PercentageSaved_Yukon').innerHTML);
	
	d.getElementById('from_perc').innerHTML=Math.min.apply( Math, perc );;
	d.getElementById('to_perc').innerHTML=Math.max.apply( Math, perc );;
	
}


function check_INPUT(obj)
{
	var value=parseFloat(obj.value),name=obj.name;
	var error="Error! "+obj.value+" is not a number."
	if(isNaN(value))
	{
		alert(error);
		obj.value=0;
	} else obj.value=my_round(value);
}

function my_round(num)
{
	num=Math.round(num*100)/100;

	num=num.toFixed(2)

	if (isNaN(num)) num='';
	return num;
}


function roundNumber(number) {
	decimal_points=2;
	if(number == 0) {
		var decimals = "";
		for(var i=0;i<decimal_points;i++) decimals += "0";
		return "0."+decimals;
	}
	var exponent = Math.pow(10,decimal_points);
	var num = Math.round((number * exponent)).toString();
	return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)
}