function checkReg() {
	
	var pass1 = document.register.user_password;
	var pass2 = document.register.user_password_verify;
	var email = document.register.user_email;
	var action = document.register.user_complete_registration;
	
	var submittable = true;
	
	if(email.value.search(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)!=-1) {
		email.style.backgroundColor="#ddffdd";
	} else {
		submittable = false;
		email.style.backgroundColor="#ffdddd";
	}

	if(pass1.value==pass2.value && pass1.value.length>0) {
		pass1.style.backgroundColor="#ddffdd";
		pass2.style.backgroundColor="#ddffdd";
	} else if(pass1.value.length<1) {
		submittable = false;
		pass1.style.backgroundColor="#ffdddd";
		pass2.style.backgroundColor="#ffffff";
	} else {
		submittable = false;
		pass1.style.backgroundColor="#ddffdd";
		pass2.style.backgroundColor="#ffdddd";
	}
	
	if(submittable == true) {
		action.disabled = false;
	} else {
		action.disabled = true;
	}

}

function hideBillingInfo() {

	var checkbox = document.getElementById("same_shipping_and_billing");
	var billing_info = document.getElementById("billing_information");
	
	
	if(checkbox.checked == true) {
		billing_info.style.display="none";
	} else {
		billing_info.style.display="block";
	}

}

function showHideReferenceOther(element) {

	var ref_other_box = document.getElementById("reference_other");

	if(element.selectedIndex == element.options.length-1) {
		ref_other_box.style.display = "block";
	} else {
		ref_other_box.style.display = "none";
	}
	
}

function registrationLoaded() {

	checkReg();
	hideBillingInfo();

}
