//  Filename: calc_vat.js  //  Function: function to calculate the amount of VAT on amounts where the VAT is both inclusive and exclusive  //  Author: Barry Hood -- design@delinear.co.uk  //  Date: 2005.05.06
function vat_calculator(form_name)
{
	var calc_amount=strip_common_elements(document.getElementById(form_name).calc_amount.value);
	var vat_already_added=document.getElementById(form_name).vat_already_added.value;var net_amount=0;
	var vat_amount=0;
	var gross_amount=0;
	
	if(!check_number_valid(calc_amount))
	{
		alert("You must fill out the amount you wish to calculate VAT on before you click submit");
		return false;
	}
	
	if(vat_already_added=="yes")
	{
		gross_amount=calc_amount;
		net_amount=((calc_amount/117.5)*100);
		vat_amount=(gross_amount-net_amount);
	}else if(vat_already_added=="no")
	{
		net_amount=calc_amount;
		vat_amount=((calc_amount/100)*17.5);
		gross_amount=(calc_amount*=1.175);
	}
	
	document.getElementById(form_name).output_net.value=format_number_output(net_amount,2,',','£');
	document.getElementById(form_name).output_vat.value=format_number_output(vat_amount,2,',','£');
	document.getElementById(form_name).output_gross.value=format_number_output(gross_amount,2,',','£');
	return false;
}