$(function() 
{
	unlockuser = function(recordid, recordversion)
	{
		$("#servererrormessage").html('');
		
		$.ajax
		(
			{
				url: "systemuseraccountunlock.php",
				async: true, 
				type: "POST",
				dataType: "json",
				data: {userid: recordid, userversion: recordversion},
				success: function(json)
				{
					if(json[0].isopen == 0)
					{
						$("#servererrormessage").html(json[0].message);
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					}
					else
					{
						$("#servererrormessage").html(json[0].message);
						location.href="systemusers.php";
					}
				},
				error: function(jqXHR, exception)
				{								
					if (jqXHR.status === 0) 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Not Connected Verify Network.</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					} 
					else if (jqXHR.status == 404) 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Requested Operation Not Found.</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					} 
					else if (jqXHR.status == 500) 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Internal Server Error.</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					} 
					else if (exception === 'parsererror') 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Requested JSON Parse Failed.</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					} 
					else if (exception === 'timeout') 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Time Out Error.</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					} 
					else if (exception === 'abort') 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Ajax Request Aborted.</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					} 
					else 
					{
						$("#servererrormessage").html("<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"aria-hidden=\"true\">&times;</button>Uncaught Error " + jqXHR.responseText + ".</div>");
						$('html, body').animate({ scrollTop: $("#servererrormessage").offset().top }, 'slow');
					}
				}
			}
		);
	}
});