function preFormValidation(){

	// both values are identical OR both values are empty
	if($j("#_password1").val() == $j("#_password2").val()){
		
		var bEmailValidation = false;
		var strMessage = "";
		
		$j.ajax({
				async: false,
				type: "POST",
				dataType: "html",
				url: "index.php?name=Register&method=validateEmail",
				data: $j("#registerForm :input"),
				success: function(result){
					bEmailValidation = result == "passed" ? true : false;
					strMessage = result;
				},
				error: function(){
					bEmailValidation = false;
				}
			});
		if(bEmailValidation)
			return bEmailValidation;
		else{
			// email is used already
			return strMessage;
		}
	}	
	else{
		// password and retypepassword are not identical
		return trMessage;
	}
}

function change_account_type(obj){
	if(obj.id == "personaccount"){
		$j('.personaccount_row').show();
		$j('.personaccount_input').addClass('validator-required').each(function(){
			$j(this).attr('disabled',false);
		});
		$j('.companyaccount_row').hide();
		$j('.companyaccount_input').removeClass('validator-required').each(function(){
			$j(this).attr('disabled',true);
		});
	}	
	else if(obj.id == "companyaccount"){
		$j('.companyaccount_row').show();
		$j('.companyaccount_input').addClass('validator-required').each(function(){
			$j(this).attr('disabled',false);
		});
		$j('.personaccount_row').hide();
		$j('.personaccount_input').removeClass('validator-required').each(function(){
			$j(this).attr('disabled',true);
		});
	}		
}

