function show_other(obj)
{
	document.getElementById("othercontainer").style.display = (obj.value == "Other") ? "" : "none";
}
	
function validate_text_field(val)
{
	return (val.value.length != 0);
}



function validate_email_field(val)
{
	//simple email validation, just checks for an @ and a .
	//remove space
	var value = val.value.replace(/^\s*|\s*$/g,"");
	if (value.length < 5)
	{
		return false;
	}
	var valid = false;
	if ((value.indexOf('@') != -1) && (value.indexOf('.') != -1))
	{
		valid = true;
	}
	return valid;
}
			
function validate_select_field(val)
{
	return (val.value != '');
}

function validateLogin(form){
	var e_msg = "";
	if(!validate_text_field(form.user_username)) 
	{
		alert("Type in your email address"); 
		form.user_username.focus();
		return false;
	}
	if(!validate_text_field(form.user_password)) 
	{
		alert("Type in your password"); 
		form.user_password.focus();
		return false;
	}
}

function validate(form)
{
	var e_msg = "";
	if(!validate_text_field(form.name)) 
	{
		alert("You must specify a name"); 
		form.name.focus();
		return false;
	}
	if(!validate_text_field(form.company)) 
	{
		alert("You must specify a company"); 
		form.company.focus();
		return false;
	}
	if(!validate_select_field(form.businessType)) 
	{
		alert("You must specify your business"); 
		form.businessType.focus();
		return false;
	}
	
	if(form.businessType.value == 'Other' && form.other.value == '') 
	{
		alert("You must specify other"); 
		form.other.focus();
		return false;
	}
	
	if(!validate_text_field(form.phone)) 
	{
		alert("You must specify your phone"); 
		form.phone.focus();
		return false;
	}
	if(!validate_email_field(form.email)) 
	{
		alert("You must specify an email address"); 
		form.email.focus();
		return false;
	}
	
	if(form.password.value != form.confirmPassword.value) 
	{
		alert("Passwords do not match"); 
		form.password.focus();
		return false;
	}
	
	return true;
}