

function showCalculator(){
	var divGasPriceCalculator = document.getElementById("divGasPriceCalculator");
	DOMFunctions.changeElementVisibility(divGasPriceCalculator, "visible");
}

function hideCalculator(){
	var divGasPriceCalculator = document.getElementById("divGasPriceCalculator");
	DOMFunctions.changeElementVisibility(divGasPriceCalculator, "hidden");
}


function calculatePrice(){
	var tdGasPriceCalculatorResult = document.getElementById("tdGasPriceCalculatorResult");
	
	var tripDistance = document.getElementById("txtTripDistance").value;
	if(!StringFunctions.checkPositiveNumeric(tripDistance)){
		alert("Please enter a positive numeric value for Trip Distance!");
		return
	}
	else {
		tripDistance = parseFloat(tripDistance);
	}
	
	var milesPerGallon = document.getElementById("txtMilesPerGallon").value;
	if(!StringFunctions.checkPositiveNumeric(milesPerGallon)){
		alert("Please Enter a positive numeric value for Miles Per Gallon!");
		return
	}
	else {
		milesPerGallon = parseFloat(milesPerGallon);
	}
	
	var costPerGallon = document.getElementById("txtCostPerGallon").value;
	if(!StringFunctions.checkPositiveNumeric(costPerGallon)){
		alert("Please Enter a positive numeric value for Cost Per Gallon!");
		return
	}
	else {
		costPerGallon = parseFloat(costPerGallon);
	}
	
	cost = (tripDistance/milesPerGallon) * costPerGallon;
	
	
	tdGasPriceCalculatorResult.className = "gasPriceCalculatorResult";
	DOMFunctions.removeAllChildren(tdGasPriceCalculatorResult);
	
	var span = document.createElement("span");
	span.className = "gasPriceCalculatorResultText";
	span.appendChild(document.createTextNode("Your Trip Will Cost: "));
	tdGasPriceCalculatorResult.appendChild(span);
	span = document.createElement("span");
	span.className = "gasPriceCalculatorResultPrice";
	span.appendChild(document.createTextNode(StringFunctions.formatCurrency(cost)));
	tdGasPriceCalculatorResult.appendChild(span);
	
	
	
}
