function $(id){
	return document.getElementById(id);
}

function setActivePaymentMethod(value){
	var els = $('billing_form').payment_method;
	for(var i=0, el; el=els[i]; i++){
		el.parentNode.parentNode.className = (el.value == value) ? "active" : "";
	}
}
function validateShipping(form){
	var errors = [];
	if(!form.first_name.value)
		errors.push('Please enter your first name.');
	if(!form.last_name.value)
		errors.push('Please enter your last name.');
	if(!form.email.value)
		errors.push('Please enter your email address.');
	if(!form.street_address1.value)
		errors.push('Please enter your street address.');
	if(!form.city.value)
		errors.push('Please enter your city.');
	if(!form.state.value)
		errors.push('Please enter your state.');
	if(!form.zip.value)
		errors.push('Please enter your zip code.');
	
	if(errors.length){
		alert('Please correct the following errors:\n\n'+errors.join('\n\n'));
		return false;
	} else{
		return true;
	}
}
function validateConfirmation(form){
	if(!form.agree_to_terms.checked){
		alert('Please check the box in the bottom left to agree to our terms and conditions.');
		return false;
	}
	return true;
}