function updateCost() {
	var outerDiameter = document.getElementById("outer_diameter").value;
	var innerDiameter = document.getElementById("inner_diameter").value;
	var ringThickness = document.getElementById("ring_thickness").value;
	var ringQuantity = document.getElementById("ring_quantity").value;

	// Make sure the quantity is valid
	if (!(ringQuantity > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The ring quantity must be at least 1.");
		return;
	}

	// Make sure the quantity is valid
	if (ringQuantity > 50) ringQuantity = 50;
	document.getElementById("ring_quantity").value = ringQuantity;

	// Make sure the quantity is valid
	if (!(outerDiameter > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The outer diameter must be valid.");
		return;
	}

	// Make sure the quantity is valid
	if (!(innerDiameter > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The inner diameter must be valid.");
		return;
	}

	// Make sure the outer size is reasonable
	if (outerDiameter > 40) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The outer diameter must be less than 40\".");
		return;
	}

	// Make sure the inner size is less than the outer - .5
	if (innerDiameter > outerDiameter - .5) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The inner diameter must be at least 1/2\" smaller than the outer diameter.");
		return;
	}

	// Enable the submit button
	document.getElementById("create_rings").disabled = false;

	ringCostIndividual = ringPrice(outerDiameter, innerDiameter, ringThickness);

	roundedRingCostIndividual = Math.round(ringCostIndividual * 100) / 100;

	document.getElementById("ring_price_individual").innerHTML = roundedRingCostIndividual;
	document.getElementById("ring_price_quantity").innerHTML = ringQuantity;
	document.getElementById("ring_price_total").innerHTML = Math.round(ringCostIndividual * ringQuantity * 100) / 100;

	clearMessage();
}

function updateTwoLayerCost() {
	var outerDiameter = document.getElementById("outer_diameter").value;
	var innerDiameter = document.getElementById("inner_diameter").value;
	var ringThickness = document.getElementById("ring_thickness").value;
	var ringQuantity = document.getElementById("ring_quantity").value;
	var outerDiameter2 = document.getElementById("outer_diameter2").value;
	var innerDiameter2 = document.getElementById("inner_diameter2").value;
	var ringThickness2 = document.getElementById("ring_thickness2").value;

	// Inner diameter of ring 1 must be GE than ID of ring 2 Commented out until bug with innerDiameter > 10 is fixed.
//	if (innerDiameter < innerDiameter2) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play;)
//		document.getElementById("create_rings").disabled = true;

//		displayMessage("The inner diameter of RING ONE must be greater than or equal to the inner diameter of RING TWO.");
//		return;
//	}




	//---- RING ONE
	// Make sure the quantity is valid
	if (!(ringQuantity > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The ring quantity must be at least 1.");
		return;
	}

	// Make sure the quantity is valid
	if (ringQuantity > 50) ringQuantity = 50;
	document.getElementById("ring_quantity").value = ringQuantity;

	// Make sure the outer diameter is valid
	if (!(outerDiameter > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The outer diameter of RING ONE must be valid.");
		return;
	}

	// Make sure the inner diameter is valid
	if (!(innerDiameter > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The inner diameter of RING ONE must be valid.");
		return;
	}

	// Make sure the outer size is reasonable
	if (outerDiameter > 40) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The outer diameter on RING ONE must be less than 40\".");
		return;
	}

	// Make sure the inner size is less than the outer - .5
	if (innerDiameter > outerDiameter - .5) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The inner diameter on RING ONE must be at least 1/2\" smaller than the outer diameter.");
		return;
	}





	//---- RING TWO
	// Make sure the outer diameter is valid
	if (!(outerDiameter2 > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The outer diameter of RING TWO must be valid.");
		return;
	}

	// Make sure the inner diameter is valid
	if (!(innerDiameter2 > 0)) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The inner diameter of RING TWO must be valid.");
		return;
	}

	// Make sure the outer size is reasonable
	if (outerDiameter2 > 40) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The outer diameter on RING TWO must be less than 40\".");
		return;
	}

	// Make sure the inner size is less than the outer - .5
	if (innerDiameter2 > outerDiameter2 - .5) {
		// Disable the submit button -- anyone looking at this and hopes to bypass error checking, think again... this is just child's play ;)
		document.getElementById("create_rings").disabled = true;

		displayMessage("The inner diameter on RING TWO must be at least 1/2\" smaller than the outer diameter.");
		return;
	}


	
	// Enable the submit button
	document.getElementById("create_rings").disabled = false;

	// Calculate the cost
	ringCostIndividual = ringPrice(outerDiameter, innerDiameter, ringThickness) + ringPrice(outerDiameter2, innerDiameter2, ringThickness2);
	roundedRingCostIndividual = Math.round(ringCostIndividual * 100) / 100;

	// Display the results
	document.getElementById("ring_price_individual").innerHTML = roundedRingCostIndividual;
	document.getElementById("ring_price_quantity").innerHTML = ringQuantity;
	document.getElementById("ring_price_total").innerHTML = Math.round(ringCostIndividual * ringQuantity * 100) / 100;

	clearMessage();
}

function ringPrice(outerDiameter, innerDiameter, ringThickness) {
		var ringCostIndividual = ((outerDiameter / 2) * (outerDiameter / 2)) * 3.14 * .08;

		if (ringCostIndividual < 7.5) {
			ringCostIndividual = 7.5;
		}

		if (ringThickness == 2)
			ringCostIndividual = ringCostIndividual * 1.25;
		else if (ringThickness == 3)
			ringCostIndividual = ringCostIndividual * 1.15;	

		return ringCostIndividual;
}

function displayMessage(message) {
	var messageBox = document.getElementById("message_box");
	var theMessage = document.getElementById("the_message");

	if (messageBox.style.display == "none")
		messageBox.style.display = "block";

	theMessage.innerHTML = message;
}

function clearMessage() {
	var messageBox = document.getElementById("message_box");
	var theMessage = document.getElementById("the_message");

	messageBox.style.display = "none";

	theMessage.innerHTML = "";
}