$().ready(function() {
	$('#TitleOther').attr("disabled", true);
	$('#TitleOther').hide();
	
	$('#Placeofwork_Other').attr("disabled", true);
	$('#Placeofwork_Other').hide();

	$('#Occupation_Other').attr("disabled", true);
	$('#Occupation_Other').hide();

	$('#Title').change(function(){						
			disableOther($('#Title'), $('#TitleOther'));		
	});

	$('#Placeofwork').change(function(){						
			disableOther($('#Placeofwork'), $('#Placeofwork_Other'));		
	});

	$('#Occupation_').change(function(){						
			disableOther($('#Occupation_'), $('#Occupation_Other'));		
	});
	
	/*
	$("#signupForm").submit(function() {
		 disableIfOther($('#Title'), $('#TitleOther'));
		 disableIfOther($('#Placeofwork'), $('#Placeofwork_Other'));
		 disableIfOther($('#Occupation_'), $('#Occupation_Other'));	
	});*/
	
				   
	// validate signup form on keyup and submit
	$("#signupForm").validate({
		rules: {
			Firstname: "required",
			Lastname: "required",
			Phone_Office_: "required",	
			Placeofwork: "required",
			Occupation_: "required",
			Address_1_: "required",
			City_Town_: "required",
			State_Province_: "required",
			Postal_Code_: "required",
			Country_: "required",
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			Firstname: "Please enter your first name",
			Lastname: "Please enter your last name",
			email: "Please enter a valid email address"
		}
	});	
});

function disableIfOther(control, controlOther)
{
		var selected = control.val();
								
		if (selected == "Other")
		{
			control.attr("disabled", true);
		}	
}

function disableOther(control, controlOther)
	{
		var selected = control.val();
								
		if (selected == "Other")
		{
			controlOther.attr("disabled", false);
			controlOther.fadeIn();
		}
		else
		{
			controlOther.attr("disabled", true);
			controlOther.fadeOut();
			controlOther.val('');
		}		
	}
