
function validateRegister() {
	if(yuiDom.get('in_UserName').value.length <= 0) {
		alert('please enter a user name.');
		return false;
	}
	if(yuiDom.get('in_EmailAddress').value.length<=0) {
		alert('please enter an email address');
		yuiDom.get('in_EmailAddress').focus();
		return false;
	}
	if(!validateEmail(yuiDom.get('in_EmailAddress').value)) {
		alert('The email address you have entered seems to be invalid, please try again.');
		return false;
	}
	if(yuiDom.get('in_EmailAddress').value != yuiDom.get('in_EmailAddressConfirm').value){
		alert('please make sure the email address matches in the "Confirm Email" field.');
		return false;
	}
	if(yuiDom.get('in_Password').value.length<=6) {
		alert('please enter a password that\'s at least 7 characters long');
		yuiDom.get('in_Password').focus();
		return false;
	}
	if(yuiDom.get('in_ConfirmPassword').value.length<=0) {
		alert('please confirm your password');
		yuiDom.get('in_ConfirmPassword').focus();
		return false;
	}
	if(yuiDom.get('in_ConfirmPassword').value != yuiDom.get('in_Password').value) {
		alert('The password and confirmation password does not match, please try again.');
		yuiDom.get('in_Password').focus();
		return false;
	}
	if(!yuiDom.get('in_Agree').checked) {
		alert('You must agree to our Terms of Service in order to register.');
		return false;
	}
	if(yuiDom.get('in_ChildrenCount').value.length>0) {
		var numberOfChildren = parseInt(yuiDom.get('in_ChildrenCount').value);
		if(isNaN(numberOfChildren)) {
			return false;
		}
	}
	return true;
}
function validateEmail(emailAddress) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(emailAddress)) {
		return true;
	}
	return false;				
}
function toggleStatesSelect() {
	if(yuiDom.get('in_Country').value == 'US') {
		yuiDom.get('StateSelect').style.display = 'block';
		yuiDom.get('in_State').disabled = false;
		yuiDom.get('StateText').style.display = 'none';
		yuiDom.get('in_StateText').disabled = true;
	}
	else {
		yuiDom.get('StateSelect').style.display = 'none';
		yuiDom.get('in_State').disabled = true;
		yuiDom.get('StateText').style.display = 'block';
		yuiDom.get('in_StateText').disabled = false;
		yuiDom.get('in_StateText').value = yuiDom.get('in_State').value;
	}
}
