$(document).ready(function(){
/* Login form */	
	$("#login").ajaxForm({
		beforeSubmit: function(formData) {
		},
//		resetForm: 'true',
		dataType: 'json',
		success: function(json){
			var data = json.validate;
			if(data != true) {
				$(".errors").each(function(){$(this).remove()});
				$.each(data, function(field, valid){
					$.each(valid, function(error, mesg){
						$("#"+field).after("<ul class='errors'><li>"+mesg+"</li></ul>");
					});
				});
			} else {
				var return_url = json.return_url;
				window.location.href = baseUrl + return_url;
			}
		}		
	});
});

