function init()
{
	calculate();
}

function hideRates()

{

  var txtBox;
  var txtBox1;

  if(document.getElementById("taxyear").value == "2010")

 {

    txtBox = document.getElementById("prsi");
    txtBox1 = document.getElementById("healthLevy");

    txtBox.disabled = false;
    txtBox1.disabled = false;

    txtBox.className = "enabledClass";
    txtBox1.className = "enabledClass";

 }
  else
	  {
	  if(document.getElementById("taxyear").value == "2011")
		  {
		    txtBox = document.getElementById("prsi");
		    txtBox1 = document.getElementById("healthLevy");

		    txtBox.disabled = true;
		    txtBox1.disabled = true;

		    txtBox.className = "disabledClass";
		    txtBox1.className = "disabledClass";
		  }
	  }
}


function calculateTax(amount)
{	
	  if(document.getElementById("taxyear").value == "2010")
		  {
	var paye = document.getElementById('payee').options[document.getElementById('payee').selectedIndex].value;
	var prsi = document.getElementById('prsi').options[document.getElementById('prsi').selectedIndex].value;
	var taxyear = document.getElementById('taxyear').options[document.getElementById('taxyear').selectedIndex].value;
	var healthlevy = document.getElementById('healthLevy').options[document.getElementById('healthLevy').selectedIndex].value;

	var precentage = parseFloat(paye) + parseFloat(prsi) + parseFloat(healthlevy);
	
	var total = amount / ((100 - precentage)/100);
	

	return total;
		  }
	  			else
	  			{
	  				var paye = document.getElementById('payee').options[document.getElementById('payee').selectedIndex].value;
	  				
					var total = amount/((100 - paye)/100);
					
					return total;	
	}
}

function calculate()  
{
	document.getElementById('errornoamount').style.display='none';
	
	var taxyear = document.getElementById('taxyear').options[document.getElementById('taxyear').selectedIndex].value;
	var amount = document.getElementById('amountToContribute').value
	
	//common object
	var format = new Format();
	
	//fix up the number
	amount = format.removeComma(amount)

	if(amount.lenght == 0 || amount == "" || isNaN(amount))
	{
	
		document.getElementById('netcosttoyou').innerHTML = "";
		
		document.getElementById('errornoamount').style.display='block';
		
		return;
	}
	
	var total = calculateTax(amount);
	
	var netcost = 	total;
	  
	//for rounding
	  
	var netcostOutput = format.addComma(netcost.toFixed(2));  
	var totalTaxOutput = format.addComma(total.toFixed(2));
	
	//add commas in common
	//document.getElementById('totalTax').innerHTML = "&euro;"+totalTaxOutput ;
	document.getElementById('taxyear1').innerHTML = taxyear;
	document.getElementById('netcosttoyou').innerHTML = "&euro;"+netcostOutput;
	document.getElementById('contributiontext').innerHTML = "&euro;"+totalTaxOutput;
	document.getElementById('costtext').innerHTML = "&euro;"+format.addComma(amount);	


}
