var taxExempt;
var fullCheck;
var cspCheck;
var alpCheck;

var programCost;
var ttlCost;
var shipCost;

// Formats a numeric value as USD
function FormatCurrency(amount)
{
	var curVal = new Number(amount).toFixed(2);
	return "$" + curVal.toString();
}

// Removes leading and trailing spaces from a string
function Trim(value)
{
	var trimmedValue = value.replace(/^\s*/, "");
	trimmedValue = trimmedValue.replace(/\s*$/, "");
	return trimmedValue;
}

// Clears the values of the cost fields
function ResetCost()
{
	programCost.value = "";
	ttlCost.value = "";
}
		
// Calculates the total cost for the order
function GetTotalCost()
{
	ResetCost();
	var exempt = (Trim(taxExempt.value) != "");

	var prodCost = 53.00;
	if(Trim(taxExempt.value) != "")
		prodCost = 50.00;

	var total = 0;
	if(true == fullCheck.checked)
		total = (exempt ? 100 : 106);
	else
		total = (exempt ? 50 : 53);

	programCost.value = FormatCurrency(total);

	if(total > 0)
	{
		//alert(shipCost.value.substring(1));
		total += new Number(shipCost.value.substring(1));
		ttlCost.value = FormatCurrency(total);
	}
}

function Page_Load()
{
	taxExempt = document.getElementById("taxExemptNumber");
	fullCheck = document.getElementById("FULL");
	cspCheck = document.getElementById("CSP");
	alpCheck = document.getElementById("ALP");

	programCost = document.getElementById("programCost");
	ttlCost = document.getElementById("ttlCost");
	shipCost = document.getElementById("shipCost");

	fullCheck.checked = true;
	GetTotalCost();
}