// JavaScript Document

function check_reg_form(){
	var error_msg = "";
	if(!checkField('first')){
		error_msg += "You must enter your first name.\n";
	}
	if(!checkField('last')){
		error_msg += "You must enter your last name.\n";
	}
	if(!checkField('title')){
		error_msg += "You must enter your title.\n";
	}
	if(!checkField('company')){
		error_msg += "You must enter your company name.\n";
	}
	if(!checkField('address')){
		error_msg += "You must enter your address.\n";
	}
	if(!checkField('city')){
		error_msg += "You must enter your city name.\n";
	}
	if(!checkField('state')){
		error_msg += "You must select your state.\n";
	}
	if(!checkField('zip')){
		error_msg += "You must enter your zip code.\n";
	}
	if(!checkField('phone')){
		error_msg += "You must enter your phone number.\n";
	}
	if(!checkField('email')){
		error_msg += "You must enter your email address.\n";
	}
	if(!checkField('tax')){
		error_msg += "You must enter your tax id.\n";
	}
	if(!checkField('reg-username')){
		error_msg += "You must enter a username.\n";
	}
	if(!checkField('reg-password')){
		error_msg += "You must enter a password.\n";
	}
	if(!checkField('password_confirm')){
		error_msg += "You must confirm your password.\n";
	}
	if(checkField('reg-password') && checkField('password_confirm') && document.getElementById('reg-password').value !=document.getElementById('password_confirm').value){
		error_msg += "Your passwords do not match.\n";
	}

	if(error_msg!=""){
		alert("Error submitting your registration.\n\n" + error_msg);
		return(false);
	}else{
		return(true);	
	}

}

function checkField(field){
	if(document.getElementById(field)==null){
		return(false);
	}
	if(document.getElementById(field).value==""){
		return(false);
	}
	return(true);
}