

	  $(document).ready(function(){		
		$.fn.clearForm = function() {
		  return this.each(function() {
			var type = this.type, tag = this.tagName.toLowerCase();
			if (tag == 'form')
			  return $(':input',this).clearForm();
			if (type == 'text' || type == 'password' || tag == 'textarea')
			  this.value = '';
			else if (type == 'checkbox' || type == 'radio')
			  this.checked = false;
			else if (tag == 'select')
			  this.selectedIndex = -1;
		  });
		};
		
	    $('#crpalumni').validate({
				messages: {
					firstname: {
						required: "Please enter your first name",
					},
					lastname: {
						required: "Please enter your last name",
					}
					
				}
		});
		
	
	$('#crpalumni').submit(function() { 
		var inputs=[];			
		$(":input").each(function() {
			inputs.push(this.name + '=' + escape(this.value));
		});	
	

		$.ajax({
			data:inputs.join('&'),
			type: "POST",
			url: "/crp/updater.php",
			dataType: "json",
			success: function(json) {
					$('#updatemsg').replaceWith(json.msg);
					$('#crpalumni').clearForm().hide("fast");
			}
		});
		return false;
		});
	});
		
