//validates the description boxes to make sure there is something in each box
function checkValidate() {	
	//local vars
	var total_qty;
	var bells;
	var church;
	var book;
	var mug;
	var plate;
	var cookbook;
	var yellow_plate;
	var white_plate;
	
	bells = document.main.bells.value;
	church = document.main.church.value;
	book = document.main.book.value;
	mug = document.main.mug.value;
	plate = document.main.plate.value;
	cookbook = document.main.cookbook.value;
	yellow_plate = document.main.yellow_plate.value;
	white_plate = document.main.white_plate.value;
	
	total_qty = 0;
	total_qty = bells + church + book + mug + plate + cookbook + yellow_plate + white_plate;
	
	if (bells < 0 || church < 0 || book < 0 || mug < 0 || plate < 0 || cookbook < 0 || yellow_plate < 0 || white_plate < 0  )
	{
		alert("Cannot have a negative quantity for the item amount");
	}
	else if(total_qty <= 0)
	{
		alert("Must order at least one item before you can continue");
	}
	else if(document.main.name.value == "")
	{
		alert("A name for shipping is required please try again.");
	}
	else if(document.main.address.value =="")
	{
		alert("The address is required please try again.");
	}
	else if(document.main.city.value =="")
	{
		alert("The city is required please try again.");
	}
	else if(document.main.state.value =="")
	{
		alert("The state is required please try again.");
	}
	else if(document.main.zip.value =="")
	{
		alert("The zip is required please try again.");
	}
	else if(document.main.phone_home1.value =="" || document.main.phone_home2.value =="" || document.main.phone_home3.value =="" )
	{
		alert("The home phone is required please try again.");
	}
	else if(document.main.email.value =="")
	{
		alert("An email is required please try again.");
	}
	else
	{
		//Submit the form
		document.main.total_amount.value = calculateTotalAmount();
		document.main.formsubmit.value = "1";
		document.main.submit();
	}
}

function calculateTotalAmount()
{
	var totalamount;
	var bells_qty;
	var church_qty;
	var book_qty;
	var mug_qty;
	var plate_qty;
	var cookbook_qty;
	var yellow_plate_qty;
	var white_plate_qty;
	
	totalamount = 0;
	
	if (document.main.bells.value == "")
	{
		bells_qty = 0;
	}
		else
		{
			bells_qty = parseInt(document.main.bells.value);
		}
	
	if (document.main.church.value == "")
	{
		church_qty = 0;
	}
		else
		{
			church_qty = parseInt(document.main.church.value);
		}
			
	if (document.main.book.value == "")
	{
		book_qty= 0;
	}
		else
		{
			book_qty= parseInt(document.main.book.value);
		}
	
	if (document.main.mug.value == "")
	{
		mug_qty = 0;
	}
		else
		{
			mug_qty = parseInt(document.main.mug.value);
		}
		
	if (document.main.plate.value =="")
	{
		plate_qty = 0;
	}
		else
		{
			plate_qty = parseInt(document.main.plate.value);
		}
		
	if (document.main.cookbook.value == "")
	{
		cookbook_qty = 0;
	}
		else 
		{
			cookbook_qty = parseInt(document.main.cookbook.value);
		}
		
	if (document.main.yellow_plate.value == "")
	{
		yellow_plate_qty = 0;
	}
		else
		{
			yellow_plate_qty = parseInt(document.main.yellow_plate.value);
		}
	
	if (document.main.white_plate.value == "")
	{
		white_plate_qty = 0;
	}
		else
		{
			white_plate_qty = parseInt(document.main.white_plate.value);
		}
	
	totalamount = totalamount + (bells_qty * 18)
	totalamount = totalamount + (church_qty * 17)
	totalamount = totalamount + (book_qty * 11)
	totalamount = totalamount + (mug_qty * 9)
	totalamount = totalamount + (plate_qty * 26)
	totalamount = totalamount + (cookbook_qty * 26)
	totalamount = totalamount + (yellow_plate_qty * 16)
	totalamount = totalamount + (white_plate_qty * 26)
		
	return totalamount;
}
	