function checkForm() {
	var inFields = document.getElementById('requiredfields').value;
	var checkArray = inFields.split(',');
	var counter = 0;
	while (counter < checkArray.length) {
		if (document.getElementById(checkArray[counter]).value == "") {
			jQuery.facebox('Please fill out all required fields.');
			return false;
		}
		counter++;
	}

	return true;
}

function sameAs() {
	if (document.getElementById('sameas').checked) {
		document.getElementById('shipname').value = document.getElementById('billingname').value;
		document.getElementById('shipaddress').value = document.getElementById('billingaddress').value;
		document.getElementById('shipaddress2').value = document.getElementById('billingaddress2').value;
		document.getElementById('shipcity').value = document.getElementById('billingcity').value;
		document.getElementById('shipstate').value = document.getElementById('billingstate').value;
		document.getElementById('shipzip').value = document.getElementById('billingzip').value;
	} else {
		document.getElementById('shipname').value = "";
		document.getElementById('shipaddress').value = "";
		document.getElementById('shipaddress2').value = "";
		document.getElementById('shipcity').value = "";
		document.getElementById('shipstate').value = "";
		document.getElementById('shipzip').value = "";
	}
}

function grandTotal(inID, inValue) {
	var price = 0;
	var previousTotal = document.getElementById('grandtotal').value;
	if (document.getElementById(inID).checked == true) {
		price = inValue.split('-');
		price = parseFloat(price[1]);
		grandTotalPrice = parseFloat(previousTotal) + parseFloat(price);
		document.getElementById('grandtotal').value = grandTotalPrice.toFixed(2);
		document.getElementById('showPrice').innerHTML = grandTotalPrice.toFixed(2);
	} else {
		price = inValue.split('-');
		price = parseFloat(price[1]);
		grandTotalPrice = parseFloat(previousTotal) - parseFloat(price);
		document.getElementById('grandtotal').value = grandTotalPrice.toFixed(2);
		document.getElementById('showPrice').innerHTML = grandTotalPrice.toFixed(2);
	}
}
