function validate()
{
	var count = 0;
	var count2 = 0
	
	emailCheck = /^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/;
	zipReg = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	cvsReg = new RegExp(/(^\d{3}$)|(^\d{4}$)/);
	credReg = new RegExp(/(^\d{15}$)|(^\d{16}$)/);
	phoneReg = new RegExp(/^\d{10}$/);
	
	if(document.theForm.phone.value.search(phoneReg) == -1)
	{
		alert('This phone number is not valid');
		return false;
	}
	
	if(document.theForm.creditCardType.value == 'Select a Credit Card')
	{
		alert('You Left the Credit Card Field Empty. Please go fill it in.');
		return false;
	}
	if(document.theForm.creditCardNumber.value.length != 15 && document.theForm.creditCardNumber.value.length != 16)
	{
		alert('You did not properly fill in the Credit Card Number Field. Please go correct it.');
		return false;
	}
	if(document.theForm.creditCardNumber.value.search(credReg) == -1)
	{
		alert('Please enter a valid Credit Card Number.');
		return false;
	}
	
	if(document.theForm.expDateMonth.value == 'Month')
	{
		alert('You Left the Expiration Month Field Empty. Please go fill it in.');
		return false;
	}
	if(document.theForm.expDateYear.value == 'Year')
	{
		alert('You Left the Expiration Year Field Empty. Please go fill it in.');
		return false;
	}
	
	if(document.theForm.cvv2Number.value.length != 3 && document.theForm.cvv2Number.value.length != 4)
	{
		alert('You Left the cvv2 Number Field Empty. Please go fill it in.');
		return false;
	}
	if(document.theForm.cvv2Number.value.search(cvsReg) == -1)
	{
		alert('Please enter a valid cvv2 Number.');
		return false;
	}
	
	if(document.theForm.firstName.value == '')
	{
		alert('You Left the First Name Field Empty. Please go fill it in.');
		return false;
	}
	if(document.theForm.lastName.value == '')
	{
		alert('You Left the Last Name Field Empty. Please go fill it in.');
		return false;
	}
	
	if(document.theForm.email.value.search(emailCheck) == -1)
	{
		alert('Please enter a valid e-mail address.');
		return false;
	}
	if(document.theForm.email.value == '')
	{
		alert('You left the E-mail Field Empty. Pleae go fill it in.');
		return false;
	}
	
	if(document.theForm.address1.value == '')
	{
		alert('You Left the Billing Address Field Empty. Please go fill it in.');
		return false;
	}
	else
	{
		address = document.theForm.address1.value.split(" ");
		
		if(address.length > 1)
		{
			//alert('Valid Address');
		}
		else
		{
			alert('This is an Invalid Address');
			return false;
		}
	}
	
	if(document.theForm.city.value == '')
	{
		alert('You Left the City Field Empty. Please go fill it in.');
		return false;
	}
	if(document.theForm.state.value == 'Select a State:')
	{
		alert('You Left the State Field Empty. Please go fill it in.');
		return false;
	}
	
	if(document.theForm.zip.value.length != 5 && document.theForm.zip.value.length != 9)
	{
		alert('Your Zip Code is not valid. Please go back and fix it.');
		return false;
	}
	if(document.theForm.zip.value.search(zipReg) == -1)
	{
		alert('Your Zip Code is not valid. Please go back and fix it.');
		return false;
	}

	if(!document.getElementById('same').checked)
	{
		if(document.theForm.firstNameShip.value == '')
		{
			alert('You Left the First Name Field Empty. Please go fill it in.');
			return false;
		}
		if(document.theForm.lastNameShip.value == '')
		{
			alert('You Left the Last Name Field Empty. Please go fill it in.');
			return false;
		}
		if(document.theForm.address1Ship.value == '')
		{
			alert('You Left the Billing Address Field Empty. Please go fill it in.');
			return false;
		}
		if(document.theForm.cityShip.value == '')
		{
			alert('You Left the City Field Empty. Please go fill it in.');
			return false;
		}
		if(document.theForm.stateShip.value == 'Select a State')
		{
			alert('You Left the State Field Empty. Please go fill it in.');
			return false;
		}
		if(document.theForm.zipShip.value == '')
		{
			alert('You Left the Zip Code Field Empty. Please go fill it in.');
			return false;
		}
		if(document.theForm.zipShip.value.length != 5 && document.theForm.zipShip.value.length != 9)
		{
			alert('Your Zip Code is not valid. Please go back and fix it.');
			return false;
		}
		if(document.theForm.zipShip.value.search(zipReg) == -1)
		{
			alert('Your Zip Code is not valid. Please go back and fix it.');
			return false;
		}
	}
}

function shippingUpdate(x)
{
	var total = 0;
	
	var tax = 0; 
	
	pill1 = document.theForm.pill1;
	pill10 = document.theForm.pill10;
	pill24 = document.theForm.pill24;
	
	if(pill1.checked == true)
	{
		if( document.theForm.amount1.value == '')
		{
			document.theForm.amount1.value = 1;
		}
		total = (pill1.value * Math.round(document.theForm.amount1.value));
	}
	else
	{
		document.theForm.amount1.value = '';
	}
	if(pill10.checked == true)
	{
		if( document.theForm.amount10.value == '')
		{
			document.theForm.amount10.value = 1;
		}
		total = (pill10.value * Math.round(document.theForm.amount10.value)) + total;
	}
	else
	{
		document.theForm.amount10.value = '';
	}
	if(pill24.checked == true)
	{	
		if( document.theForm.amount24.value == '')
		{
			document.theForm.amount24.value = 1;
		}	
		total = (pill24.value * Math.round(document.theForm.amount24.value)) + total;
	}
	else
	{
		document.theForm.amount24.value = '';
	}
	
	switch(x)
	{
		case 'regular':
		{
			if(total <= 6)
			{
				tax = 2.99;
			}
			else if(total <= 45)
			{
				tax = 8.99;
			}
			else if(total <= 95)
			{
				tax = 11.99;
			}
			else if(total <= 150)
			{
				tax = 18.99;
			}
			else
			{
				tax = 25.99;
			}
			break;
		}
		case 'express':
		{
			if(total <= 6)
			{
				tax = 5.99;
			}
			else if(total <= 45)
			{
				tax = 9.99;
			}
			else if(total <= 95)
			{
				tax = 13.99;
			}
			else if(total <= 145)
			{
				tax = 19.99;
			}
			else
			{
				tax = 25.99;
			}
			break;
		}
		default:
		{
			break;
		}
	}
	
	document.theForm.totTax.value = tax; 
	
	return tax;
}