( function($) {
	$( function() {
		
		// bind click to the submit button
		$("#updateUserForm #updateBtn").click( function() {
		});
		
		// bind event to the reset button
		$("#updateUserForm #reset").bind("click", function() {
			if (confirm("Are you sure you want to cancel?")) {
				//$("#updateUserForm").resetForm();
				//$("#updateUserForm #message").html("");
				//$("#updateUserForm #oldEmail").attr("value", $("#updateUserForm #userName").val());
				//$("#updateUserForm #confirmEmail").attr("disabled", "true");
				//$("#updateUserForm .general").css("color", "rgb(116, 108, 97)");
				//$("#updateUserForm td").css("background-color", null);
				//$("#updateUserForm .red").hide();
				//$("#error-alert").hide();
				return true;
			} else {
				return false;
			}
		});
		
		// for enter keyboard submit
		$("#updateUserForm :input").each( function() {
			$(this).keypress( function(e) {
				var key = window.event ? e.keyCode : e.which;
				if (key.toString() == "13") {
					$("#updateUserForm").submit();
				}
			});
		});

		// add keyup event to the elements below
		$("#updateUserForm #confirmEmail").bind("keyup", function() {
			$("#updateUserForm #confirmEmail").addClass("zip-input");
		});
		
		$("#updateUserForm #phoneOne").keyup( function() {
			if ($("#updateUserForm #phoneOne").val().length == 3)
				$("#updateUserForm #phoneSecond").focus();
		});
		
		$("#updateUserForm #phoneSecond").keyup( function() {
			if ($("#updateUserForm #phoneSecond").val().length == 3)
				$("#updateUserForm #phoneThird").focus();
		});
		
		$("#updateUserForm #userName").bind("keydown", function() {
			$("#updateUserForm").find("input[id='userName']").addClass("zip-input");
			$("#updateUserForm #confirmEmail").attr("disabled", "");
			$("#updateUserForm").find("input[id='confirmEmail']").addClass("zip-input");
		});
		
		// add changed style to each input
		$("#updateUserForm #address1").keydown( function() {
			$("#updateUserForm #address1").addClass("zip-input");
		});

		$("#updateUserForm #address2").keydown( function() {
			$("#updateUserForm #address2").addClass("zip-input");
		});

		$("#updateUserForm #zip").keydown( function() {
			$("#updateUserForm #zip").addClass("zip-input");
		});

		$("#updateUserForm #city").keydown( function() {
			$("#updateUserForm #city").addClass("zip-input");
		});

		$("#updateUserForm #phoneOne").keydown( function() {
			$("#updateUserForm").find("input[id='phoneOne']").addClass("change-input");
		});

		$("#updateUserForm #phoneSecond").keydown( function() {
			$("#updateUserForm").find("input[id='phoneSecond']").addClass("change-input");
		});

		$("#updateUserForm #phoneThird").keydown( function() {
			$("#updateUserForm").find("input[id='phoneThird']").addClass("change-input");
		});

		$("#updateUserForm select[id='registrationProfile.specialtyId']").change( function() {
			$("#updateUserForm").find("select[id='registrationProfile.specialtyId']").addClass("select-change");
		});

		$("#updateUserForm select[id='registrationProfile.roleId']").change( function() {
			$("#updateUserForm").find("select[id='registrationProfile.roleId']").addClass("select-change");
		});

		$("#updateUserForm select[id='registrationProfile.state']").change( function() {
			$("#updateUserForm").find("select[id='registrationProfile.state']").addClass("select-change");
		});

		/* zhenwei.liu add */
		var changecolor = function(){
			$(this).css('color', '#000').unbind('keyup', changecolor);
		}
		$('#content-container div.profile-cotainer input.input').bind('keyup', changecolor);
		$('#content-container div.profile-cotainer select').bind('change', function(){
			$(this).css('color', '#000');
		});
		/* add end */
	});
})(jQuery);
